Module: Pubba::Site
Instance Attribute Summary collapse
-
#asset_configuration ⇒ Object
readonly
Returns the value of attribute asset_configuration.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Instance Method Summary collapse
- #add_page(name, hsh) ⇒ Object
- #configure ⇒ Object
- #configure_asset_handler ⇒ Object
- #maybe_init_r18n ⇒ Object
- #page(name) ⇒ Object
- #pages ⇒ Object
- #process ⇒ Object
Instance Attribute Details
#asset_configuration ⇒ Object (readonly)
Returns the value of attribute asset_configuration.
12 13 14 |
# File 'lib/pubba/site.rb', line 12 def asset_configuration @asset_configuration end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
12 13 14 |
# File 'lib/pubba/site.rb', line 12 def locale @locale end |
Instance Method Details
#add_page(name, hsh) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/pubba/site.rb', line 78 def add_page(name, hsh) p = Page.new(name, @asset_configuration.global_config!) p.add_asset('styles', hsh['styles']) if hsh['styles'] p.add_asset('scripts', hsh['scripts']) if hsh['scripts'] p.tagify pages[name] = p end |
#configure ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pubba/site.rb', line 14 def configure Statica.root_dir = Pubba.public_folder maybe_init_r18n # Load pubba_config @asset_configuration = Pubba::Assets::Configuration.new(Pubba.config_file) # Set assset handler configure_asset_handler # Set pages to empty hash @pages = {} # Process the remaining @pubba_config sections asset_configuration.process do |p, config| add_page(p, config) end end |
#configure_asset_handler ⇒ Object
64 65 66 67 68 |
# File 'lib/pubba/site.rb', line 64 def configure_asset_handler Pubba.asset_handler.asset_paths Pubba.asset_folder, File.join(Pubba.asset_folder, Pubba.style_folder), File.join(Pubba.asset_folder, Pubba.script_folder) end |
#maybe_init_r18n ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pubba/site.rb', line 50 def maybe_init_r18n return unless Pubba.r18n_folder locale = 'en' locale = Pubba.r18n_locale if Pubba.r18n_locale @r18n_folder = Pubba.r18n_folder @r18n_locale = locale require_relative 'locale' @locale = Locale.new end |
#page(name) ⇒ Object
70 71 72 |
# File 'lib/pubba/site.rb', line 70 def page(name) pages[name] end |
#pages ⇒ Object
74 75 76 |
# File 'lib/pubba/site.rb', line 74 def pages @pages ||= {} end |
#process ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pubba/site.rb', line 34 def process pages.each{|name, p| p.assetize } asset_script_folder = File.join(Pubba.asset_folder, 'out', Pubba.script_folder) asset_style_folder = File.join(Pubba.asset_folder, 'out', Pubba.style_folder) public_script_folder = File.join(Pubba.public_folder, Pubba.script_folder) public_style_folder = File.join(Pubba.public_folder, Pubba.style_folder) Pubba.asset_handler.process(asset_script_folder, public_script_folder) Pubba.asset_handler.process(asset_style_folder, public_style_folder) Pubba.asset_minifier.minify(public_script_folder, :js) Pubba.asset_minifier.minify(public_style_folder, :css) end |