class Object

Public Instance Methods

get_all_items(site, collection_name, filter_func) click to toggle source
# 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) click to toggle source

Recursively go through given list of nav_items, including any nested items, and return a flat array containing navigation items with path specified.

# 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 = []

  nav_items.each do |item|
    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

  items_with_path
end
is_sparse_checkout_error(err, subtrees) click to toggle source
# File lib/jekyll-theme-open-project-helpers/project_data_reader.rb, line 351
def is_sparse_checkout_error(err, subtrees)
  if err.message.include? "Sparse checkout leaves no entry on working directory"
    Jekyll.logger.debug("OPF: It looks like sparse checkout of these directories failed:", subtrees.to_s)
    true
  else
    false
  end
end
process_author(author) click to toggle source
# File lib/jekyll-theme-open-project-helpers/blog_index.rb, line 1
def process_author(author)
  email = author['email']
  hash = Digest::MD5.hexdigest(email)
  author['email'] = hash
  author['plaintext_email'] = email
  author
end