Class: Trifle::Docs::PageController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Trifle::Docs::PageController
- Defined in:
- lib/trifle/docs/engine.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #docs_layout ⇒ Object
- #render_content(url:, meta:) ⇒ Object
- #render_file(meta:) ⇒ Object
- #render_not_found ⇒ Object
- #show ⇒ Object
Instance Method Details
#configuration ⇒ Object
28 29 30 |
# File 'lib/trifle/docs/engine.rb', line 28 def configuration params[:configuration] || Trifle::Docs.default end |
#docs_layout ⇒ Object
32 33 34 |
# File 'lib/trifle/docs/engine.rb', line 32 def docs_layout "layouts/trifle/docs/#{configuration.layout}" end |
#render_content(url:, meta:) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/trifle/docs/engine.rb', line 53 def render_content(url:, meta:) render (['template'] || 'page'), locals: { sitemap: Trifle::Docs.sitemap(config: configuration), collection: Trifle::Docs.collection(url: url, config: configuration), content: Trifle::Docs.content(url: url, config: configuration), meta: , url: url } end |
#render_file(meta:) ⇒ Object
49 50 51 |
# File 'lib/trifle/docs/engine.rb', line 49 def render_file(meta:) send_file(['path']) end |
#render_not_found ⇒ Object
45 46 47 |
# File 'lib/trifle/docs/engine.rb', line 45 def render_not_found render text: 'Not Found', status: 404 end |
#show ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/trifle/docs/engine.rb', line 36 def show url = [params[:url], params[:format]].compact.join('.') = Trifle::Docs.(url: url, config: configuration) render_not_found and return if .nil? render_file(meta: ) and return if ['type'] == 'file' render_content(url: url, meta: ) end |