Class: Jekyll::Geolexica::MetaPagesGenerator
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::Geolexica::MetaPagesGenerator
- Includes:
- Configuration
- Defined in:
- lib/jekyll/geolexica/meta_pages_generator.rb
Instance Attribute Summary collapse
-
#generated_pages ⇒ Object
readonly
Returns the value of attribute generated_pages.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #add_page(*pages) ⇒ Object
-
#all_pages_pathnames ⇒ Object
Lists all regular files in
base_dir
recursively, and returns them as an Array of Pathname instances, which are relative tobase_dir
. - #base_dir ⇒ Object
-
#generate(site) ⇒ Object
Generates Geolexica meta pages, both HTML and machine-readable.
-
#make_pages ⇒ Object
Processes concepts and yields a bunch of Jekyll::Page instances.
- #skip_page?(pathname) ⇒ Boolean
Methods included from Configuration
#bibliography_path, #concepts_glob, #glossary_format, #glossary_path, #images_metadata_path, #images_path, #localized_concepts_path, #output_html?, #output_json?, #output_jsonld?, #output_tbx?, #output_turtle?, #output_yaml?, #report_issue_url, #suggest_translation_url, #term_languages
Instance Attribute Details
#generated_pages ⇒ Object (readonly)
Returns the value of attribute generated_pages.
11 12 13 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 11 def generated_pages @generated_pages end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
11 12 13 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 11 def site @site end |
Instance Method Details
#add_page(*pages) ⇒ Object
53 54 55 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 53 def add_page *pages self.generated_pages.concat(pages) end |
#all_pages_pathnames ⇒ Object
Lists all regular files in base_dir
recursively, and returns them as an Array of Pathname instances, which are relative to base_dir
.
37 38 39 40 41 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 37 def all_pages_pathnames Dir.glob("**/*", base: base_dir). map { |path| Pathname.new(path) }. reject { |pathname| pathname.(base_dir).directory? } end |
#base_dir ⇒ Object
43 44 45 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 43 def base_dir File.("../../../_pages", __dir__) end |
#generate(site) ⇒ Object
Generates Geolexica meta pages, both HTML and machine-readable.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 14 def generate(site) Jekyll.logger.info("Geolexica:", "Generating meta 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 site.pages.concat(generated_pages) end |
#make_pages ⇒ Object
Processes concepts and yields a bunch of Jekyll::Page instances.
28 29 30 31 32 33 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 28 def make_pages all_pages_pathnames.each do |p| next if skip_page?(p) add_page Page.new(site, base_dir, p.dirname.to_s, p.basename.to_s) end end |
#skip_page?(pathname) ⇒ Boolean
47 48 49 50 51 |
# File 'lib/jekyll/geolexica/meta_pages_generator.rb', line 47 def skip_page?(pathname) (pathname.extname == ".ttl" && !output_turtle?) || (pathname.extname == ".json" && !output_json?) || false end |