Sha256: cfba8ec7b4b983ff4111469291dddcea0c0c03e0d696fd8a14266353347c84fc
Contents?: true
Size: 1.29 KB
Versions: 6
Compression:
Stored size: 1.29 KB
Contents
require 'sequel' require 'sqlite3' require 'sprockets' require 'ballonizer' path_rake_to_app = 'examples/ballonizer_app/' db_name = 'test.db' db_path = "#{path_rake_to_app}#{db_name}" db_uri = "sqlite://#{db_path}" html_name = 'index.html' html = File.read("#{path_rake_to_app}#{html_name}") ballonizer = Ballonizer.new(db_uri, { img_to_ballonize_css_selector: '#comic img', create_tables_if_none: true, form_handler_url: '/request_handler', add_required_css: true, css_asset_path_for_link: '/assets/', add_required_js_libs_for_edition: true, js_asset_path_for_link: '/assets/' }) app = Rack::Builder.new do map '/' do run(lambda do | env | # the url is needed to make relative paths to images absolute request = Rack::Request.new(env) mime_type = 'application/xhtml+xml' ballonized_page = ballonizer.ballonize_page(html, request.url, mime_type) [200, { 'content-type' => mime_type }, [ballonized_page]] end) end map '/assets' do run Ballonizer.assets_app end map '/request_handler' do run(lambda do | env | begin ballonizer.process_submit(env) [200, {}, ['your changes have been stored successfully']] rescue Ballonizer::SubmitError => e [200, {}, [e.message]] end end) end end run app
Version data entries
6 entries across 6 versions & 1 rubygems