Class: Howl::Site
- Inherits:
-
Object
- Object
- Howl::Site
- Defined in:
- lib/howl/site.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
-
#initialize(root) ⇒ Site
constructor
A new instance of Site.
- #output_path(path = '') ⇒ Object
- #pages ⇒ Object
- #pages_path(path = '') ⇒ Object
- #path(path) ⇒ Object
- #posts ⇒ Object
- #posts_path(path = '') ⇒ Object
- #templates ⇒ Object
- #templates_path(path = '') ⇒ Object
- #write_to_disk ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
3 4 5 |
# File 'lib/howl/site.rb', line 3 def root @root end |
#view ⇒ Object
Returns the value of attribute view.
3 4 5 |
# File 'lib/howl/site.rb', line 3 def view @view end |
Instance Method Details
#output_path(path = '') ⇒ Object
26 27 28 |
# File 'lib/howl/site.rb', line 26 def output_path(path = '') root + "generated" + path end |
#pages ⇒ Object
30 31 32 |
# File 'lib/howl/site.rb', line 30 def pages @pages ||= Dir[pages_path "**/*.*"].map { |path| Page.new(path, self) } end |
#pages_path(path = '') ⇒ Object
22 23 24 |
# File 'lib/howl/site.rb', line 22 def pages_path(path = '') root + "site" + path end |
#path(path) ⇒ Object
10 11 12 |
# File 'lib/howl/site.rb', line 10 def path(path) root + path end |
#posts ⇒ Object
34 35 36 |
# File 'lib/howl/site.rb', line 34 def posts @posts ||= Dir[posts_path "**/*.*"].map { |path| Post.new(path, self) }.sort end |
#posts_path(path = '') ⇒ Object
14 15 16 |
# File 'lib/howl/site.rb', line 14 def posts_path(path = '') root + "posts" + path end |
#templates ⇒ Object
38 39 40 41 42 43 |
# File 'lib/howl/site.rb', line 38 def templates @templates ||= Hash[Dir[templates_path('*')].map { |path| [Pathname.new(path).relative_path_from(path "templates").to_s, Template.new(path, self)] }] end |
#templates_path(path = '') ⇒ Object
18 19 20 |
# File 'lib/howl/site.rb', line 18 def templates_path(path = '') root + "templates" + path end |
#write_to_disk ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/howl/site.rb', line 45 def write_to_disk FileUtils.rm_r(output_path) if File.exist?(output_path) (pages + posts).each do |page| FileUtils.makedirs(page.output_path.dirname) if page.path.binary? FileUtils.copy(page.path, page.output_path) else page.output_path.open("w") do |fh| fh.write page.render end end end end |