| In: |
app/models/page.rb
|
| Parent: | Object |
| CONTINOUS_REVISION_PERIOD | = | 30 * 60 |
| name | [R] | |
| revisions | [R] | |
| web | [R] |
# File app/models/page.rb, line 14
14: def initialize(web, name, content, created_at, author)
15: @web, @name, @revisions = web, name, []
16: revise(content, created_at, author)
17: end
# File app/models/page.rb, line 73
73: def author_link(options = {})
74: web.make_link(author, nil, options)
75: end
# File app/models/page.rb, line 56
56: def authors
57: revisions.collect { |rev| rev.author }
58: end
# File app/models/page.rb, line 52
52: def categories
53: display_content.find_chunks(Category).map { |cat| cat.list }.flatten
54: end
# File app/models/page.rb, line 48
48: def in_category?(cat)
49: cat.nil? || cat.empty? || categories.include?(cat)
50: end
# File app/models/page.rb, line 69
69: def link(options = {})
70: web.make_link(name, nil, options)
71: end
# File app/models/page.rb, line 44
44: def pretty_revised_on
45: DateTime.new(revised_on.year, revised_on.mon, revised_on.day).strftime "%B %e, %Y"
46: end
# File app/models/page.rb, line 60
60: def references
61: web.select.pages_that_reference(name)
62: end
# File app/models/page.rb, line 19
19: def revise(content, created_at, author)
20: if !@revisions.empty? && continous_revision?(created_at, author)
21: @revisions.last.created_at = Time.now
22: @revisions.last.content = content
23: @revisions.last.clear_display_cache
24: else
25: @revisions << Revision.new(self, @revisions.length, content, created_at, author)
26: end
27:
28: web.refresh_pages_with_references(name) if @revisions.length == 1
29: end