Sha256: b4022085a9b73fdcf0c5daf9b2f80ffb8426b3e9a567edff91fa1793f57c5358

Contents?: true

Size: 779 Bytes

Versions: 54

Compression:

Stored size: 779 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" }

    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

54 entries across 54 versions & 1 rubygems

Version Path
onebox-1.6.9 lib/onebox/web.rb
onebox-1.6.8 lib/onebox/web.rb
onebox-1.6.7 lib/onebox/web.rb
onebox-1.6.6 lib/onebox/web.rb
onebox-1.6.5 lib/onebox/web.rb
onebox-1.6.4 lib/onebox/web.rb
onebox-1.6.3 lib/onebox/web.rb
onebox-1.6.2 lib/onebox/web.rb
onebox-1.6.1 lib/onebox/web.rb
onebox-1.6.0 lib/onebox/web.rb
onebox-1.5.65 lib/onebox/web.rb
onebox-1.5.64 lib/onebox/web.rb
onebox-1.5.63 lib/onebox/web.rb
onebox-1.5.62 lib/onebox/web.rb
onebox-1.5.61 lib/onebox/web.rb
onebox-1.5.60 lib/onebox/web.rb
onebox-1.5.50 lib/onebox/web.rb
onebox-1.5.49 lib/onebox/web.rb
onebox-1.5.48 lib/onebox/web.rb
onebox-1.5.47 lib/onebox/web.rb