Class Nukumi2::Page
In: lib/nukumi2/page.rb
lib/nukumi2/plugins/blogroll.rb
Parent: Object

Methods

breadcumbs   content_type   last_change   new   render   title   to_root   topics   topictree   version  

Attributes

entries  [R] 
flavor  [R] 
path  [R] 
view  [R] 

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

    # 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

[Source]

    # 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

[Source]

     # 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

[Source]

    # File lib/nukumi2/page.rb, line 32
32:     def render
33:       engine(flavor).expand(self)
34:     end

[Source]

    # File lib/nukumi2/page.rb, line 45
45:     def title
46:       blog.topictree.name(path) || path
47:     end

DONT TOUCH THIS. BRITTLE.

[Source]

    # 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

[Source]

    # 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

[Source]

    # File lib/nukumi2/page.rb, line 67
67:     def topictree
68:       topics '/'
69:     end

[Source]

     # File lib/nukumi2/page.rb, line 108
108:     def version
109:       Nukumi2::VERSION
110:     end

[Validate]