Class: Web
- Inherits:
-
Object
- Object
- Web
- Defined in:
- app/models/web.rb
Instance Attribute Summary collapse
-
#additional_style ⇒ Object
Returns the value of attribute additional_style.
-
#address ⇒ Object
Returns the value of attribute address.
-
#brackets_only ⇒ Object
Returns the value of attribute brackets_only.
-
#color ⇒ Object
Returns the value of attribute color.
-
#count_pages ⇒ Object
Returns the value of attribute count_pages.
-
#markup ⇒ Object
Default values.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#password ⇒ Object
Returns the value of attribute password.
-
#published ⇒ Object
Returns the value of attribute published.
-
#safe_mode ⇒ Object
Returns the value of attribute safe_mode.
Instance Method Summary collapse
- #add_page(page) ⇒ Object
- #authors ⇒ Object
- #categories ⇒ Object
-
#initialize(name, address, password = nil) ⇒ Web
constructor
A new instance of Web.
-
#make_link(name, text = nil, options = {}) ⇒ Object
Create a link for the given page name and link text based on the render mode in options and whether the page exists in the this web.
-
#refresh_pages_with_references(page_name) ⇒ Object
Clears the display cache for all the pages with references to.
- #refresh_revisions ⇒ Object
- #remove_pages(pages_to_be_removed) ⇒ Object
- #revised_on ⇒ Object
- #select(&accept) ⇒ Object
Constructor Details
#initialize(name, address, password = nil) ⇒ Web
Returns a new instance of Web.
11 12 13 14 |
# File 'app/models/web.rb', line 11 def initialize(name, address, password = nil) @name, @address, @password, @safe_mode = name, address, password, false @pages = {} end |
Instance Attribute Details
#additional_style ⇒ Object
Returns the value of attribute additional_style.
9 10 11 |
# File 'app/models/web.rb', line 9 def additional_style @additional_style end |
#address ⇒ Object
Returns the value of attribute address.
8 9 10 |
# File 'app/models/web.rb', line 8 def address @address end |
#brackets_only ⇒ Object
Returns the value of attribute brackets_only.
9 10 11 |
# File 'app/models/web.rb', line 9 def brackets_only @brackets_only end |
#color ⇒ Object
Returns the value of attribute color.
9 10 11 |
# File 'app/models/web.rb', line 9 def color @color end |
#count_pages ⇒ Object
Returns the value of attribute count_pages.
9 10 11 |
# File 'app/models/web.rb', line 9 def count_pages @count_pages end |
#markup ⇒ Object
Default values
74 75 76 |
# File 'app/models/web.rb', line 74 def markup @markup end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'app/models/web.rb', line 8 def name @name end |
#pages ⇒ Object
Returns the value of attribute pages.
8 9 10 |
# File 'app/models/web.rb', line 8 def pages @pages end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'app/models/web.rb', line 8 def password @password end |
#published ⇒ Object
Returns the value of attribute published.
9 10 11 |
# File 'app/models/web.rb', line 9 def published @published end |
#safe_mode ⇒ Object
Returns the value of attribute safe_mode.
9 10 11 |
# File 'app/models/web.rb', line 9 def safe_mode @safe_mode end |
Instance Method Details
#add_page(page) ⇒ Object
16 17 18 |
# File 'app/models/web.rb', line 16 def add_page(page) @pages[page.name] = page end |
#authors ⇒ Object
32 33 34 |
# File 'app/models/web.rb', line 32 def select. end |
#categories ⇒ Object
36 37 38 |
# File 'app/models/web.rb', line 36 def categories select.map { |page| page.categories }.flatten.uniq.sort end |
#make_link(name, text = nil, options = {}) ⇒ Object
Create a link for the given page name and link text based on the render mode in options and whether the page exists in the this web.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/web.rb', line 43 def make_link(name, text = nil, = {}) page = pages[name] text = text || WikiWords.separate(name) link = CGI.escape(name) case [:mode] when :export if page then "<a class=\"existingWikiWord\" href=\"#{link}.html\">#{text}</a>" else "<span class=\"newWikiWord\">#{text}</span>" end when :publish if page then "<a class=\"existingWikiWord\" href=\"../show/#{link}\">#{text}</a>" else "<span class=\"newWikiWord\">#{text}</span>" end else if page then "<a class=\"existingWikiWord\" href=\"../show/#{link}\">#{text}</a>" else "<span class=\"newWikiWord\">#{text}<a href=\"../show/#{link}\">?</a></span>" end end end |
#refresh_pages_with_references(page_name) ⇒ Object
Clears the display cache for all the pages with references to
63 64 65 66 67 |
# File 'app/models/web.rb', line 63 def refresh_pages_with_references(page_name) select.pages_that_reference(page_name).each { |page| page.revisions.each { |revision| revision.clear_display_cache } } end |
#refresh_revisions ⇒ Object
69 70 71 |
# File 'app/models/web.rb', line 69 def refresh_revisions select.each { |page| page.revisions.each { |revision| revision.clear_display_cache } } end |
#remove_pages(pages_to_be_removed) ⇒ Object
20 21 22 |
# File 'app/models/web.rb', line 20 def remove_pages(pages_to_be_removed) pages.delete_if { |page_name, page| pages_to_be_removed.include?(page) } end |
#revised_on ⇒ Object
28 29 30 |
# File 'app/models/web.rb', line 28 def revised_on select.most_recent_revision end |