Sha256: dee45fe05bcc24d612472148728d14c4268b6bde6b02faf2204c3c2d49d47944

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 Bytes

Contents

require 'sinatra/base'
require 'web_tools'
require 'web_tools/support/service_helper'

class WebTools::UI < Sinatra::Base
  PUBLIC_FOLDER = File.expand_path("../../../public", __FILE__)
  include WebTools::Support::ServiceHelper

  helpers do
    def static(file) File.read("#{PUBLIC_FOLDER}/#{file}.html") end
  end

  get '/' do
    static :index
  end

  get '/tools' do
    json "tools" => (WebTools::Tool.subclasses.reject(&:dont_show?).sort_by(&:name).map do |cls|
      { "file" => cls.file_name,
        "name" => cls.display_name,
        "description" => cls.description }
    end)
  end

  get '/*' do
    "#{params[:splat]} not implemented"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
maglev-webtools-1.0.2 lib/web_tools/ui.rb
maglev-webtools-1.0.1 lib/web_tools/ui.rb
maglev-webtools-1.0 lib/web_tools/ui.rb