Class: Hyde::Page::Css
- Inherits:
-
Object
- Object
- Hyde::Page::Css
- Defined in:
- lib/hyde-page-css.rb,
lib/hyde-page-css.rb
Constant Summary collapse
- VERSION =
"0.7.0"- @@config =
{ "source" => "assets/css", "destination" => "assets/css", "minify" => true, "enable" => true, "keep_files" => true, "livereload" => false, "automatic_inline_threshold" => 4096 }
Instance Method Summary collapse
- #cache ⇒ Object
-
#initialize(page) ⇒ Css
constructor
A new instance of Css.
- #run ⇒ Object
Constructor Details
#initialize(page) ⇒ Css
Returns a new instance of Css.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hyde-page-css.rb', line 57 def initialize(page) @page = page @site = page.site @config = fetch_config @site.data["_hyde_pages_css_cache"] ||= Jekyll::Cache.new("hyde_pages_css") if keep_files? @site.config.fetch("keep_files").push(destination) end end |
Instance Method Details
#cache ⇒ Object
68 69 70 |
# File 'lib/hyde-page-css.rb', line 68 def cache @site.data["_hyde_pages_css_cache"] end |
#run ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/hyde-page-css.rb', line 72 def run css = fetch_css(@page) layout = fetch_layout(fetch_layout_name(@page)) css_groups = parent_layout_css(layout, css).reverse return if css_groups.flatten.empty? for group in css_groups next if group.nil? next if group.empty? lookup_name = names_to_key(group) cache_entry = cache.getset(lookup_name) do data = concatenate_files(group) break if data == "" data = minify(data) break if data == "" generated_file = generate_file(group, data) # place file data into the new file generated_file.file_contents = data if @site.static_files.find { |static_file| static_file.name == generated_file.name }.nil? # assign static file to list for jekyll to render @site.static_files << generated_file end { url: generated_file.url, data: data } end # assign to page.data.css_files for liquid output add_to_urls(cache_entry&.fetch(:url, nil), cache_entry&.fetch(:data, nil)) end end |