Sha256: d11445ca3887755a9f03ec40a551bc5ad43257036f415063dd5a1e01507e0a77

Contents?: true

Size: 904 Bytes

Versions: 70

Compression:

Stored size: 904 Bytes

Contents

require 'haml'
require 'yaml'
require 'sinatra/base'
require 'sinatra/reloader'
require 'onebox'
require 'onebox/web_helpers'
require 'multi_json'

module Onebox
  class Web < Sinatra::Base
    set :root, File.expand_path(File.dirname(__FILE__) + "/../../web")
    set :public_folder, Proc.new { "#{root}/assets" }
    set :views, Proc.new { "#{root}/views" }
    configure :development do
      register Sinatra::Reloader
      also_reload 'lib/**/*.rb'
      enable :logging
    end

    helpers WebHelpers

    get '/' do
      haml :index, format: :html5
    end

    get '/onebox' do
      content_type :json
      result = {
          url: params[:url],
          engine: Onebox::Matcher.new(params[:url]).oneboxed.to_s
      }
      onebox = Onebox.preview(params[:url])
      result.merge!(onebox: onebox.to_s, placeholder: onebox.placeholder_html)
      MultiJson.dump(result)
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
onebox-1.8.48 lib/onebox/web.rb
onebox-1.8.47 lib/onebox/web.rb
onebox-1.8.46 lib/onebox/web.rb
onebox-1.8.45 lib/onebox/web.rb
onebox-1.8.44 lib/onebox/web.rb
onebox-1.8.43 lib/onebox/web.rb
onebox-1.8.42 lib/onebox/web.rb
onebox-1.8.41 lib/onebox/web.rb
onebox-1.8.40 lib/onebox/web.rb
onebox-1.8.39 lib/onebox/web.rb
onebox-1.8.38 lib/onebox/web.rb
onebox-1.8.36 lib/onebox/web.rb
onebox-1.8.35 lib/onebox/web.rb
onebox-1.8.34 lib/onebox/web.rb
onebox-1.8.33 lib/onebox/web.rb
onebox-1.8.32 lib/onebox/web.rb
onebox-1.8.31 lib/onebox/web.rb
onebox-1.8.30 lib/onebox/web.rb
onebox-1.8.29 lib/onebox/web.rb
onebox-1.8.28 lib/onebox/web.rb