Class: Impression::App
- Defined in:
- lib/impression/app.rb
Overview
‘App` implements a resource that maps to a generic app directory.
Constant Summary
Constants inherited from Resource
Resource::FIRST_PATH_SEGMENT_REGEXP
Instance Attribute Summary
Attributes inherited from FileTree
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(**props) ⇒ App
constructor
A new instance of App.
-
#page_list(dir) ⇒ Array<Hash>
Returns a list of pages found in the given directory (relative to the base directory).
Methods inherited from FileTree
Methods inherited from Resource
#absolute_path, #add_child, #call, #each, #html_response, #json_response, #remount, #remove_child, #render_tree_to_static_files, #route, #text_response, #to_proc
Constructor Details
#initialize(**props) ⇒ App
Returns a new instance of App.
16 17 18 19 20 |
# File 'lib/impression/app.rb', line 16 def initialize(**props) super @layouts = {} @file_info_loader = spin { run_file_info_loader } end |
Instance Method Details
#page_list(dir) ⇒ Array<Hash>
Returns a list of pages found in the given directory (relative to the base directory). Each entry containins the absolute file path, the pretty URL, the possible date parsed from the file name, and any other front matter attributes (for .md files). This method will detect only pages with the extensions .html, .md, .rb. The returned entries are sorted by file path.
30 31 32 33 34 35 |
# File 'lib/impression/app.rb', line 30 def page_list(dir) base = File.join(@directory, dir) Dir.glob('*.{html,md}', base: base) .map { |fn| get_path_info(File.join(dir, fn)) }# page_entry(fn, dir) } .sort_by { |i| i[:path] } end |