Class: Impression::App

Inherits:
FileTree show all
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

#directory

Attributes inherited from Resource

#children, #parent, #path

Instance Method Summary collapse

Methods inherited from FileTree

#call

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.

Parameters:

  • dir (String)

    relative directory

Returns:

  • (Array<Hash>)

    array of page entries



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