summaryrefslogtreecommitdiff
path: root/lib/page_index.rb
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-06 23:18:24 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-06 23:18:24 -0500
commit4a3a404a5cb2a8d5be83e28cec5c539928fa30f4 (patch)
treeb6f636ba3ed0ce486941b1b9ad67cb0973699d6b /lib/page_index.rb
parent7edb003cd1c9b53ffdff11ef85532e39f08db16d (diff)
aaaah
Diffstat (limited to 'lib/page_index.rb')
-rw-r--r--lib/page_index.rb45
1 files changed, 36 insertions, 9 deletions
diff --git a/lib/page_index.rb b/lib/page_index.rb
index 073537e..3e25813 100644
--- a/lib/page_index.rb
+++ b/lib/page_index.rb
@@ -14,7 +14,7 @@ class IndexPage < LocalPage
def _metadata
if @metadata.nil?
- yamlfile = _infile+"/index.yaml"
+ yamlfile = local_infile+"/index.yaml"
if File::exist?(yamlfile)
@metadata = YAML::load(File::read(yamlfile))
else
@@ -24,19 +24,19 @@ class IndexPage < LocalPage
@metadata
end
def _ls
- @ls ||= Dir::entries(_infile)
+ @ls ||= Dir::entries(local_infile)
.select{|fname|not fname.start_with?(".")}
- .map{|fname|"#{_infile}/#{fname}"}
+ .map{|fname|"#{local_infile}/#{fname}"}
.select{|path|Dir::exist?(path) or Config::get.html_suffixes.include?(File::extname(path).gsub(/^[.]/, ''))}
end
- def pages
+ def index_pages
if @pages.nil?
@pages = []
for path in _ls
if Dir::exist?(path)
page = IndexPage::new(path)
@pages.unshift(page)
- @pages += page.pages
+ @pages += page.index_pages
else
@pages.unshift(LocalPage::new(path))
end
@@ -48,16 +48,43 @@ class IndexPage < LocalPage
@pages
end
- def _published
+ def atom_title
+ _metadata['title']
+ end
+
+ def local_outfile
+ local_infile.sub(/^src/, 'out')+"/index.html"
+ end
+ def local_depends
+ if @depends.nil?
+ basename = local_infile.sub(/^src/, 'out')
+ deps = Set[local_infile]
+ yamlfile = local_infile+"/index.yaml"
+ if File::exist?(yamlfile)
+ deps.add(yamlfile)
+ end
+ index_pages.each{|p|deps.merge(p.local_outfile[''])}
+ @depends = {
+ "#{basename}/index.html" => deps.clone.merge(["tmpl/index.md.erb", "tmpl/page.html.erb"]),
+ "#{basename}/index.atom" => deps.clone.merge(["tmpl/index.atom.erb", "tmpl/page.atom.erb"]),
+ }
+ end
+ @depends
+ end
+ def local_srcurl
+ return nil
+ end
+
+ def page_published
return nil
end
- def _updated
+ def page_updated
return nil
end
- def _years
+ def page_years
return Set[]
end
end
ERB::new(File::read("tmpl/index.atom.erb")).def_method(IndexPage, 'atom()', "tmpl/index.atom.erb")
-ERB::new(File::read("tmpl/index.md.erb")).def_method(IndexPage, '_input()', "tmpl/index.md.erb")
+ERB::new(File::read("tmpl/index.md.erb")).def_method(IndexPage, 'local_input()', "tmpl/index.md.erb")