Class: RailsSiteEngine::ProfileDefaults
- Inherits:
-
Object
- Object
- RailsSiteEngine::ProfileDefaults
- Defined in:
- lib/rails_site_engine/profile_defaults.rb
Instance Method Summary collapse
-
#initialize(profile:, business_name:, site_profiles: nil) ⇒ ProfileDefaults
constructor
A new instance of ProfileDefaults.
- #page_content(page_id) ⇒ Object
- #page_ids ⇒ Object
- #profile_key ⇒ Object
- #site_config ⇒ Object
- #theme_config ⇒ Object
Constructor Details
#initialize(profile:, business_name:, site_profiles: nil) ⇒ ProfileDefaults
Returns a new instance of ProfileDefaults.
7 8 9 10 11 12 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 7 def initialize(profile:, business_name:, site_profiles: nil) @profile = profile.to_s.strip @business_name = business_name.to_s @site_profiles = site_profiles || RailsSiteEngine::SiteProfiles.new(path: RailsSiteEngine::Engine.root.join("config/site_profiles.yml")) end |
Instance Method Details
#page_content(page_id) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 34 def page_content(page_id) path = pages_root.join("#{page_id}.md") return nil unless path.file? render_template(path.read) end |
#page_ids ⇒ Object
28 29 30 31 32 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 28 def page_ids return [] unless pages_root.directory? pages_root.glob("*.md").map { |path| path.basename(".md").to_s }.sort end |
#profile_key ⇒ Object
14 15 16 17 18 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 14 def profile_key return @profile if @site_profiles.valid_concrete_profile?(@profile) @site_profiles.fallback_concrete_profile end |
#site_config ⇒ Object
20 21 22 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 20 def site_config @site_config ||= load_yaml_from_template("content/site.yml") end |
#theme_config ⇒ Object
24 25 26 |
# File 'lib/rails_site_engine/profile_defaults.rb', line 24 def theme_config @theme_config ||= load_yaml_from_template("config/theme.yml") end |