Sha256: 3c2f9beba12041c150bf93f178f128ab28b5aa9bf147cad56312e6f3a2ea6184

Contents?: true

Size: 935 Bytes

Versions: 77

Compression:

Stored size: 935 Bytes

Contents

# frozen_string_literal: true

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

77 entries across 77 versions & 1 rubygems

Version Path
onebox-2.2.19 lib/onebox/web.rb
onebox-2.2.18 lib/onebox/web.rb
onebox-2.2.17 lib/onebox/web.rb
onebox-2.2.16 lib/onebox/web.rb
onebox-2.2.15 lib/onebox/web.rb
onebox-2.2.14 lib/onebox/web.rb
onebox-2.2.13 lib/onebox/web.rb
onebox-2.2.12 lib/onebox/web.rb
onebox-2.2.11 lib/onebox/web.rb
onebox-2.2.10 lib/onebox/web.rb
onebox-2.2.9 lib/onebox/web.rb
onebox-2.2.8 lib/onebox/web.rb
onebox-2.2.6 lib/onebox/web.rb
onebox-2.2.5 lib/onebox/web.rb
onebox-2.2.4 lib/onebox/web.rb
onebox-2.2.2 lib/onebox/web.rb
onebox-2.2.1 lib/onebox/web.rb
onebox-2.2.0 lib/onebox/web.rb
onebox-2.1.9 lib/onebox/web.rb
onebox-2.1.8 lib/onebox/web.rb