Class: Noumenon::Core
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Noumenon::Core
- Defined in:
- lib/noumenon/core.rb
Overview
The core Noumenon web application, responsible for loading content from the repository, and then either rendering it with the appropriate template, or passing it to the specified application.
Instance Method Summary collapse
-
#content ⇒ Noumenon::Repository
Convenience method to access the current content repository.
-
#render_page(page) ⇒ String
Renders a content item within it’s template and layout.
Instance Method Details
#content ⇒ Noumenon::Repository
Convenience method to access the current content repository.
41 42 43 |
# File 'lib/noumenon/core.rb', line 41 def content Noumenon.content_repository end |
#render_page(page) ⇒ String
Renders a content item within it’s template and layout.
If the template or layout is not specified then it will be set to “default”.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/noumenon/core.rb', line 20 def render_page(page) page[:template] ||= "default" page[:layout] ||= "default" begin template = Noumenon.theme.template("#{page[:template]}.nou.html") content = template.render(page) wrap_with_layout(content, page) rescue Noumenon::Template::NotFoundError => e halt 500, "<h1>Missing Template</h1><p>The template '#{page[:template]}' does not exist within the current theme.</p>" rescue Noumenon::Template::MissingContentError => e halt 500, "<h1>Missing Fields</h1><p>#{e}</p>" end end |