summaryrefslogtreecommitdiff
path: root/lib/page_tag.rb
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-09 19:19:19 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-09 19:19:19 -0500
commitf1b364abf455b3654580718972a77572ca29be02 (patch)
tree875108b3c8c3ca8af7c8430f37f78be00a91684f /lib/page_tag.rb
parent955387e6af782e1dabd4d68ad12904263c4e8023 (diff)
Implement tag pages (finally!)
Diffstat (limited to 'lib/page_tag.rb')
-rw-r--r--lib/page_tag.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/page_tag.rb b/lib/page_tag.rb
new file mode 100644
index 0000000..01ef31d
--- /dev/null
+++ b/lib/page_tag.rb
@@ -0,0 +1,60 @@
+# coding: utf-8
+require 'category'
+require 'page_index'
+require 'page_remote'
+require 'sitegen'
+
+class TagPage < IndexPage
+ def initialize(abbr)
+ @category = Category::new(abbr)
+ super("src/tags/#{@category.abbr}.phony")
+ end
+ def atom_title
+ return "Tag: #{@category.name}"
+ end
+ def index_pages
+ return Sitegen::pages
+ .select{|p|!p.is_a?(IndexPage)}
+ .select{|p|p.atom_categories.any?{|c|c.abbr == @category.abbr}}
+ .to_set
+ end
+ def local_outfile
+ return "out/tags/#{@category.abbr}.html"
+ end
+ def index_depends
+ if @depends.nil?
+ deps = Set['config.yaml']
+ Sitegen::pages.select{|p|!p.is_a?(RemotePage)}.each{|p|deps.merge(p.local_depends[''])}
+ @depends = deps
+ end
+ @depends
+ end
+ def local_depends
+ return {
+ '' => index_depends,
+ local_outfile => index_depends.clone.merge(["tmpl/index.md.erb", "tmpl/page.html.erb"]),
+ }
+ end
+end
+
+class TagIndexPage < IndexPage
+ def initialize
+ super("src/tags")
+ end
+ def atom_title
+ return "Tags"
+ end
+ def index_pages
+ return Sitegen::pages
+ .select{|p|p.is_a?(TagPage)}
+ .to_set
+ end
+ def index_depends
+ if @depends.nil?
+ deps = Set[]
+ Sitegen::pages.select{|p|p.is_a?(LocalPage)}.each{|p|deps.merge(p.local_depends[''])}
+ @depends = deps
+ end
+ @depends
+ end
+end