module CabbageDoc::WebHelper
Public Instance Methods
asset_path(path)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 5 def asset_path(path) [config.asset_path || request.path, path].join('/').gsub(/\/\/+/, '/') end
auth()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 44 def auth @_auth ||= Authentication.new(request) end
collection()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 17 def collection if config.dev && config.auto_generate Generator.perform(:all) @_collection = nil end @_collection ||= Collection.instance.tap do |collection| collection.load! end end
config()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 13 def config Configuration.instance end
eval_with_erb(text)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 36 def eval_with_erb(text) ERB.new(text).result(binding) end
format_json_response(response)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 64 def format_json_response(response) content_type :json response.to_json end
format_tag(tag)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 60 def format_tag(tag) tag.to_s.capitalize end
format_visibility(o)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 56 def format_visibility(o) o.visibility.to_s.capitalize if o.visibility != VISIBILITY.first end
highlighter()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 28 def highlighter @_highlighter ||= Highlighter.new end
markdown()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 32 def markdown @_markdown ||= Markdown.new end
post_request()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 69 def post_request @_post_request ||= Request.new(request, collection) end
response_by_id(id)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 73 def response_by_id(id) response = Worker.get(id) if response.is_a?(Response) format_json_response(response) else status 503 content_type :json { id: id }.to_json end end
tag_visible?(tag)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 52 def tag_visible?(tag) config.tags.size <= 1 || auth.visibility.include?(tag) end
theme_path()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 9 def theme_path asset_path("css/highlight/#{config.theme}.css") end
title()
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 40 def title @_title ||= config.title end
visible?(o)
click to toggle source
# File lib/cabbage_doc/web_helper.rb, line 48 def visible?(o) auth.visibility.include?(o.visibility) end