lib/interpol/documentation_app.rb in interpol-0.0.5 vs lib/interpol/documentation_app.rb in interpol-0.0.6
- old
+ new
@@ -13,11 +13,11 @@
end
def render_static_page(&block)
require 'rack/mock'
app = build(&block)
- status, headers, body = app.call(Rack::MockRequest.env_for "/", method: "GET")
+ status, headers, body = app.call(Rack::MockRequest.env_for "/", :method => "GET")
AssetInliner.new(body.join, app.public_folder).standalone_page
end
# Inlines the assets so the page can be viewed as a standalone web page.
class AssetInliner
@@ -34,17 +34,17 @@
private
def inline_stylesheets
@doc.css("link[rel=stylesheet]").map do |link|
- inline_asset link, "style", link['href'], type: "text/css"
+ inline_asset link, "style", link['href'], :type => "text/css"
end
end
def inline_javascript
@doc.css("script[src]").each do |script|
- inline_asset script, "script", script['src'], type: "text/javascript"
+ inline_asset script, "script", script['src'], :type => "text/javascript"
end
end
def contents_for(asset)
File.read(File.join(@asset_root, asset))
@@ -75,10 +75,19 @@
end
def title
interpol_config.documentation_title
end
+
+ def url_path(*path_parts)
+ [ path_prefix, path_parts ].join("/").squeeze('/')
+ end
+ alias_method :u, :url_path
+
+ def path_prefix
+ request.env['SCRIPT_NAME']
+ end
end
# Private: Builds a stub sinatra app for the given interpol
# configuration.
class Builder
@@ -91,10 +100,11 @@
set :public_folder, "#{dir}/documentation_app/public"
set :interpol_config, config
helpers Helpers
get('/') do
- erb :layout, locals: { endpoints: endpoints, current_endpoint: current_endpoint }
+ erb :layout, :locals => { :endpoints => endpoints,
+ :current_endpoint => current_endpoint }
end
end
end
end
end