Class: Mook::Site
- Inherits:
-
Object
- Object
- Mook::Site
- Defined in:
- lib/mook/site.rb
Instance Attribute Summary collapse
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pages) ⇒ Site
constructor
A new instance of Site.
- #render! ⇒ Object
- #stage! ⇒ Object
Constructor Details
#initialize(pages) ⇒ Site
Returns a new instance of Site.
16 17 18 |
# File 'lib/mook/site.rb', line 16 def initialize(pages) @pages = pages end |
Instance Attribute Details
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
14 15 16 |
# File 'lib/mook/site.rb', line 14 def pages @pages end |
Class Method Details
.load(dir) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/mook/site.rb', line 3 def self.load(dir) pages = [] for page_file in Dir.glob(File.join(dir, "pages", "*")) if MARKDOWN_EXTENSIONS.member?(File.extname(page_file).downcase) pages << Page.load(page_file) end end Site.new(pages.sort_by { |p| p.order }) end |
Instance Method Details
#render! ⇒ Object
20 21 22 23 24 25 |
# File 'lib/mook/site.rb', line 20 def render! renderer = Renderer.new(self) for page in @pages renderer.render!(page) end end |
#stage! ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mook/site.rb', line 27 def stage! FileUtils.mkdir_p("target") FileUtils.rm_rf(File.join("target", "*")) FileUtils.cp_r(Dir.glob(File.join("static", "*")), "target") for page in @pages File.open(File.join("target", "#{page.name}.html"), "w+") do |f| f << page.output end end end |