Class: Spreen::Wiki::Sidebar
- Inherits:
-
Application
- Object
- Application
- Spreen::Wiki::Sidebar
- Defined in:
- lib/spreen/wiki/sidebar.rb,
sig/generated/spreen/wiki/sidebar.rbs
Overview
Generates the wiki _Sidebar.md as a nested list of owners/categories and their wiki pages.
Instance Attribute Summary
Attributes inherited from Application
#base_path, #config, #excluded_paths, #group_by, #home_overflow, #language, #path_to_home, #path_to_sidebar, #paths_to_wikis
Instance Method Summary collapse
- #append_section(namespace, wikis, owned:) ⇒ void
- #run ⇒ void
- #section_heading(namespace, owned:) ⇒ String
- #update_wiki_list ⇒ void
- #wiki_list ⇒ Array[String]
Methods inherited from Application
#initialize, #namespace_for, #no_declaration, #owned_wiki_maps, #parse_home_overflow, #plain_wiki_maps, #populate_namespace, run, #target_paths, #target_regexp, #validate!, #validate_home_overflow!, #wiki_maps_with_namespace
Constructor Details
This class inherits a constructor from Spreen::Wiki::Application
Instance Method Details
#append_section(namespace, wikis, owned:) ⇒ void
This method returns an undefined value.
34 35 36 37 |
# File 'lib/spreen/wiki/sidebar.rb', line 34 def append_section(namespace, wikis, owned:) wiki_list << "#{section_heading(namespace, owned:)}\n" wikis.each { |wiki| wiki_list << " - [[#{wiki.gsub('.md', '')}]]\n" } end |
#run ⇒ void
This method returns an undefined value.
12 13 14 15 |
# File 'lib/spreen/wiki/sidebar.rb', line 12 def run update_wiki_list File.write(, wiki_list.join) end |
#section_heading(namespace, owned:) ⇒ String
42 43 44 45 46 47 |
# File 'lib/spreen/wiki/sidebar.rb', line 42 def section_heading(namespace, owned:) owner_base_url = config.owner_base_url return "- #{namespace}" unless owned && owner_base_url "- [#{namespace}](#{owner_base_url + namespace.delete('@')})" end |
#update_wiki_list ⇒ void
This method returns an undefined value.
25 26 27 28 |
# File 'lib/spreen/wiki/sidebar.rb', line 25 def update_wiki_list owned_wiki_maps.each { |namespace, wikis| append_section(namespace, wikis, owned: true) } plain_wiki_maps.each { |namespace, wikis| append_section(namespace, wikis, owned: false) } end |
#wiki_list ⇒ Array[String]
20 21 22 |
# File 'lib/spreen/wiki/sidebar.rb', line 20 def wiki_list @wiki_list ||= [] end |