Class | Nukumi2::Page |
In: |
lib/nukumi2/page.rb
lib/nukumi2/plugins/blogroll.rb |
Parent: | Object |
entries | [R] | |
flavor | [R] | |
path | [R] | |
view | [R] |
# File lib/nukumi2/page.rb, line 12 12: def initialize(view, flavor) 13: @view = view 14: @path = view.path 15: @entries = view.entries 16: @flavor = flavor 17: end
# File lib/nukumi2/page.rb, line 49 49: def breadcumbs 50: a = [] 51: path.split('/').each { |e| 52: a << a.last.to_s + e + '/' 53: } 54: 55: a = ["/"] if a.empty? 56: 57: r = a.map { |path| 58: title = (blog.topictree.name(path) rescue path) || path.split('/').last 59: linkpath = path.gsub(/\/$/, '') 60: Struct.new(:link, :title, :to_root, :page).new( 61: linkpath, title, to_root, path) 62: } 63: 64: r 65: end
# File lib/nukumi2/page.rb, line 27 27: def content_type 28: # 'text/html; charset=utf-8' 29: engine(flavor).content_type rescue 'text/plain' 30: end
# File lib/nukumi2/page.rb, line 94 94: def last_change 95: unless view.entries.empty? 96: view.entries.map { |e| e.change_time }.max 97: else # XXX Empty page? 98: if view.respond_to? :subtopics 99: view.subtopics.map { |topic, name| 100: blog.topictree[topic] 101: }.flatten.map { |e| e.change_time }.max || Time.now 102: else 103: Time.now 104: end 105: end 106: end
DONT TOUCH THIS. BRITTLE.
# File lib/nukumi2/page.rb, line 37 37: def to_root 38: if path.count('/') < 2 39: '.' 40: else 41: (['..'] * (path.count('/') - 1)).join('/') 42: end 43: end
# File lib/nukumi2/page.rb, line 71 71: def topics(root, depth=1) 72: return "" if blog.topictree.subtopics(root).empty? 73: 74: output = "<dl#{depth > 2 ? " class='compact'" : ''}>\n" 75: 76: blog.topictree.subtopics(root).sort_by { |t| 77: (blog.topictree.name(File.join(root, t)) || t) rescue t 78: }.each { |s| 79: sub = (root + '/' + s).squeeze('/') 80: output << "<dt><a href='#{to_root}#{sub[0..-1]}.#{flavor}'>" 81: output << (blog.topictree.name(sub + "/") || s) 82: output << "</a>" 83: output << "</dt>" 84: 85: unless blog.hidden.any? { |t| sub =~ Topical::TopicTree.path2regexp(t) } 86: output << "<dd>" << topics(sub, depth+1) << "</dd>" 87: end 88: } 89: 90: output << "</dl>\n" 91: output 92: end