class Jekyll::Geolexica::ConceptsGenerator
Attributes
generated_pages[R]
site[R]
Public Instance Methods
add_page(*pages)
click to toggle source
# File lib/jekyll/geolexica/concepts_generator.rb, line 67 def add_page *pages self.generated_pages.concat(pages) end
find_page(name)
click to toggle source
# File lib/jekyll/geolexica/concepts_generator.rb, line 71 def find_page(name) site.pages.detect { |page| page.name == name } end
generate(site)
click to toggle source
Generates Geolexica
concept pages, both HTML and machine-readable.
# File lib/jekyll/geolexica/concepts_generator.rb, line 14 def generate(site) Jekyll.logger.info("Geolexica:", "Generating concept pages") # Jekyll does not say why it's a good idea, and whether such approach # is thread-safe or not, but most plugins in the wild do exactly that, # including these authored by Jekyll team. @site = site @generated_pages = [] make_pages sort_pages initialize_collections group_pages_in_collections end
group_pages_in_collections()
click to toggle source
# File lib/jekyll/geolexica/concepts_generator.rb, line 61 def group_pages_in_collections generated_pages.each do |page| site.collections[page.collection_name].docs.push(page) end end
initialize_collections()
click to toggle source
# File lib/jekyll/geolexica/concepts_generator.rb, line 50 def initialize_collections %w[ concepts concepts_json concepts_jsonld concepts_ttl concepts_tbx concepts_yaml ].each do |label| next if site.collections[label] site.config["collections"][label] ||= { "output" => true } site.collections[label] = Jekyll::Collection.new(site, label) end end
make_pages()
click to toggle source
Processes concepts and yields a bunch of Jekyll::Page instances.
# File lib/jekyll/geolexica/concepts_generator.rb, line 30 def make_pages site.glossary.each_concept do |concept| Jekyll.logger.debug("Geolexica:", "building pages for concept #{concept.termid}") concept.pages.replace({ html: (ConceptPage::HTML.new(site, concept) if output_html?), json: (ConceptPage::JSON.new(site, concept) if output_json?), jsonld: (ConceptPage::JSONLD.new(site, concept) if output_jsonld?), tbx: (ConceptPage::TBX.new(site, concept) if output_tbx?), turtle: (ConceptPage::Turtle.new(site, concept) if output_turtle?), yaml: (ConceptPage::YAML.new(site, concept) if output_yaml?), }) add_page(*concept.pages.values.compact) end end
sort_pages()
click to toggle source
# File lib/jekyll/geolexica/concepts_generator.rb, line 46 def sort_pages generated_pages.sort_by! { |p| p.termid } end