WikiService (Class)

In: app/models/wiki_service.rb
Parent: MadeleineService

Attributes

system  [R] 
webs  [R] 

Public Class methods

[Source]

    # File app/models/wiki_service.rb, line 11
11:   def initialize
12:     @webs, @system = {}, {}
13:   end

Public Instance methods

[Source]

    # File app/models/wiki_service.rb, line 19
19:   def authenticate(password)
20:     password == (@system["password"] || "instiki")
21:   end

[Source]

    # File app/models/wiki_service.rb, line 28
28:   def create_web(name, address, password = nil)
29:     @webs[address] = Web.new(name, address, password) unless @webs[address]
30:   end

[Source]

    # File app/models/wiki_service.rb, line 50
50:   def read_page(web_address, page_name)
51:     web = @webs[web_address]
52:     web ? web.pages[page_name] : nil
53:   end

[Source]

    # File app/models/wiki_service.rb, line 73
73:   def remove_orphaned_pages(web_address)
74:     @webs[web_address].remove_pages(@webs[web_address].select.orphaned_pages)
75:   end

[Source]

    # File app/models/wiki_service.rb, line 61
61:   def revise_page(web_address, page_name, content, revised_on, author)
62:     page = read_page(web_address, page_name)
63:     page.revise(content, revised_on, author)
64:     page
65:   end

[Source]

    # File app/models/wiki_service.rb, line 67
67:   def rollback_page(web_address, page_name, revision_number, created_at, author_id = nil)
68:     page = read_page(web_address, page_name)
69:     page.rollback(revision_number, created_at, author_id)
70:     page
71:   end

[Source]

    # File app/models/wiki_service.rb, line 23
23:   def setup(password, web_name, web_address)
24:     @system["password"] = password
25:     create_web(web_name, web_address)
26:   end

[Source]

    # File app/models/wiki_service.rb, line 15
15:   def setup?
16:     !@system.empty?
17:   end

[Source]

    # File app/models/wiki_service.rb, line 32
32:   def update_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false, 
33:       password = nil, published = false, brackets_only = false, count_pages = false)
34:     if old_address != new_address
35:       @webs[new_address] = @webs[old_address]
36:       @webs.delete(old_address)
37:       @webs[new_address].address = new_address
38:     end
39:     
40:     web = @webs[new_address]
41:     web.refresh_revisions if settings_changed?(web, markup, safe_mode, brackets_only)
42:     
43:     web.name, web.markup, web.color, web.additional_style, web.safe_mode = 
44:       name, markup, color, additional_style, safe_mode
45:       
46:     web.password, web.published, web.brackets_only, web.count_pages =
47:       password, published, brackets_only, count_pages
48:   end

[Source]

    # File app/models/wiki_service.rb, line 55
55:   def write_page(web_address, page_name, content, written_on, author)
56:     page = Page.new(@webs[web_address], page_name, content, written_on, author)
57:     @webs[web_address].add_page(page)
58:     page
59:   end

[Validate]