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