Class: Staticpress::Content::Theme
- Extended by:
- ResourceContent, StaticContent
- Includes:
- ResourceContent, StaticContent
- Defined in:
- lib/staticpress/content/theme.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ Theme
constructor
A new instance of Theme.
- #static? ⇒ Boolean
- #template_path ⇒ Object
Methods included from ResourceContent
find_supported_extensions, gather_resources_from, load_resource
Methods included from StaticContent
layout, parse_slug, render_partial, supported_extensions
Methods inherited from Base
#==, #content, #content_type, #exist?, find_by_url_path, #full_title, #layout, #markup_template?, #meta, #optional_param_defaults, #output_path, #published?, #raw, #render, #render_partial, #save, #save!, #template_context, #template_engine_options, #template_extension, #template_path_content, #theme, theme, #title, #to_s, type, #url_path
Methods included from Helpers
#config, #extensionless_basename, #extensionless_path, #hash_from_array, #hash_from_match_data, #paginate, #settings, #spider_map, #titleize
Constructor Details
#initialize(params) ⇒ Theme
Returns a new instance of Theme.
8 9 10 11 |
# File 'lib/staticpress/content/theme.rb', line 8 def initialize(params) super @template_types = find_supported_extensions template_path end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/staticpress/content/theme.rb', line 22 def self.all gather_resources_from Staticpress::Theme.theme.assets end |
.find_by_path(path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/staticpress/content/theme.rb', line 30 def self.find_by_path(path) if path.file? stubs = Staticpress::Route::REGEX_STUBS regex = /#{stubs[:theme].regex}\/assets\/#{stubs[:asset_type].regex}\/#{stubs[:slug].regex}/ # FIXME send parse_slug something more intelligent as second parameter if match = regex.match(parse_slug(path, Staticpress.root + 'themes').first) new hash_from_match_data(match) end end end |
.published ⇒ Object
26 27 28 |
# File 'lib/staticpress/content/theme.rb', line 26 def self.published all end |
Instance Method Details
#static? ⇒ Boolean
13 14 15 |
# File 'lib/staticpress/content/theme.rb', line 13 def static? (Staticpress::Theme.new(params[:theme]).root + 'assets' + params[:asset_type] + params[:slug]).file? end |
#template_path ⇒ Object
18 19 20 |
# File 'lib/staticpress/content/theme.rb', line 18 def template_path Staticpress::Theme.new(params[:theme]).root + 'assets' + params[:asset_type] + "#{params[:slug]}#{template_extension}" end |