Page (Class)

In: app/models/page.rb
Parent: Object

Constants

CONTINOUS_REVISION_PERIOD = 30 * 60

Attributes

name  [R] 
revisions  [R] 
web  [R] 

Included Modules

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

    # File app/models/page.rb, line 73
73:   def author_link(options = {})
74:     web.make_link(author, nil, options)
75:   end

[Source]

    # File app/models/page.rb, line 56
56:   def authors
57:     revisions.collect { |rev| rev.author }
58:   end

[Source]

    # File app/models/page.rb, line 52
52:   def categories
53:     display_content.find_chunks(Category).map { |cat| cat.list }.flatten
54:   end

[Source]

    # File app/models/page.rb, line 48
48:   def in_category?(cat)
49:     cat.nil? || cat.empty? || categories.include?(cat)
50:   end

[Source]

    # File app/models/page.rb, line 69
69:   def link(options = {})
70:     web.make_link(name, nil, options)
71:   end

Returns the original wiki-word name as separate words, so "MyPage" becomes "My Page".

[Source]

    # File app/models/page.rb, line 65
65:   def plain_name
66:     WikiWords.separate(name, web.brackets_only)
67:   end

[Source]

    # 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

[Source]

    # File app/models/page.rb, line 60
60:   def references
61:     web.select.pages_that_reference(name)
62:   end

[Source]

    # 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

[Source]

    # File app/models/page.rb, line 40
40:   def revised_on
41:     created_on
42:   end

[Source]

    # File app/models/page.rb, line 36
36:   def revisions?
37:     revisions.length > 1
38:   end

[Source]

    # File app/models/page.rb, line 31
31:   def rollback(revision_number, created_at, author_ip = nil)
32:     roll_back_revision = @revisions[revision_number].dup
33:     revise(roll_back_revision.content, created_at, Author.new(roll_back_revision.author, author_ip))
34:   end

[Validate]