Top Level Namespace
Defined Under Namespace
Instance Method Summary collapse
- #get_all_items(site, collection_name, filter_func) ⇒ Object
-
#get_nav_items_with_path(nav_items) ⇒ Object
Recursively go through given list of nav_items, including any nested items, and return a flat array containing navigation items with path specified.
- #process_author(author) ⇒ Object
Instance Method Details
#get_all_items(site, collection_name, filter_func) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/jekyll-theme-open-project-helpers/filterable_index.rb', line 131 def get_all_items(site, collection_name, filter_func) # Fetches items of specified type, ordered and prepared for usage in index templates collection = site.collections[collection_name] if collection == nil raise "Collection does not exist: #{collection_name}" end items = collection.docs.select { |item| filter_func.call(item) } default_time = Time.new(1989, 12, 31, 0, 0, 0, "+00:00") items.sort! { |i1, i2| val1 = i1.data.fetch('last_update', default_time) || default_time val2 = i2.data.fetch('last_update', default_time) || default_time (val2 <=> val1) || 0 } if site.config['is_hub'] items.map! do |item| project_name = item.url.split('/')[2] project_path = "_projects/#{project_name}/index.md" item.data['project_name'] = project_name item.data['project_data'] = site.collections['projects'].docs.select { |proj| proj.path.end_with? project_path } [0] item end end return items end |
#get_nav_items_with_path(nav_items) ⇒ Object
Recursively go through given list of nav_items, including any nested items, and return a flat array containing navigation items with path specified.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jekyll-theme-open-project-helpers/spec_builders/png_diagrams.rb', line 5 def get_nav_items_with_path(nav_items) items_with_path = [] for item in nav_items do if item['path'] items_with_path.push(item) end if item['items'] items_with_path.concat(get_nav_items_with_path(item['items'])) end end return items_with_path end |
#process_author(author) ⇒ Object
1 2 3 4 5 6 7 |
# File 'lib/jekyll-theme-open-project-helpers/blog_index.rb', line 1 def () email = ['email'] hash = Digest::MD5.hexdigest(email) ['email'] = hash ['plaintext_email'] = email end |