Sha256: 43c6e76eecb1db79d502abd0c9ecdc3dd871c579cb9411c4315cec7b3b26471c

Contents?: true

Size: 839 Bytes

Versions: 28

Compression:

Stored size: 839 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
      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

28 entries across 28 versions & 1 rubygems

Version Path
onebox-1.8.17 lib/onebox/web.rb
onebox-1.8.16 lib/onebox/web.rb
onebox-1.8.15 lib/onebox/web.rb
onebox-1.8.14 lib/onebox/web.rb
onebox-1.8.13 lib/onebox/web.rb
onebox-1.8.12 lib/onebox/web.rb
onebox-1.8.11 lib/onebox/web.rb
onebox-1.8.10 lib/onebox/web.rb
onebox-1.8.9 lib/onebox/web.rb
onebox-1.8.8 lib/onebox/web.rb
onebox-1.8.7 lib/onebox/web.rb
onebox-1.8.6 lib/onebox/web.rb
onebox-1.8.5 lib/onebox/web.rb
onebox-1.8.4 lib/onebox/web.rb
onebox-1.8.3 lib/onebox/web.rb
onebox-1.8.2 lib/onebox/web.rb
onebox-1.8.1 lib/onebox/web.rb
onebox-1.8.0 lib/onebox/web.rb
onebox-1.7.9 lib/onebox/web.rb
onebox-1.7.8 lib/onebox/web.rb