Sha256: 4b4daa4d43054c39663812c90620c08f0c54a4c98243a2c7a91eaaef53d92681

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'redcarpet'
require 'sinatra/base'
require 'magic_reveal/slide_renderer'
require 'magic_reveal/index_libber'
require 'magic_reveal/project_config'

begin
  require 'better_errors'
  HAS_BETTER_ERRORS = true
rescue LoadError
  HAS_BETTER_ERRORS = false
end

module MagicReveal
  # The web application
  class App < Sinatra::Base
    if HAS_BETTER_ERRORS
      configure :development do
        use BetterErrors::Middleware
        BetterErrors.application_root = File.expand_path('../../..', __FILE__)
      end
    end

    set :public_folder, Dir.getwd

    get '/' do
      slides = Pathname.pwd + 'slides.md'
      markdown =  SlideRenderer.markdown_renderer
      libber = IndexLibber.new

      libber.author = Identifier.name
      libber.slides = markdown.render slides.read

      config = ProjectConfig.new(Pathname.pwd + 'config.json')
      libber.add_github_forkme config.json['github'] if config.json.key? 'github'

      libber.to_s
    end

    get '/index.js' do
      content_type :js
      config = ProjectConfig.new(Pathname.pwd + 'config.json')
      config.to_js
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_reveal-2.6.1.4 lib/magic_reveal/app.rb