Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 3752 Bytes
1 | class Wiki |
2 | |
3 | cattr_accessor :storage_path, :logger |
4 | self.storage_path = Rails.root.join('storage') |
5 | |
6 | def authenticate(password) |
7 | password == (system.password || 'instiki') |
8 | end |
9 | |
10 | def create_web(name, address, password = nil) |
11 | @webs = nil |
12 | Web.create(:name => name, :address => address, :password => password) |
13 | end |
14 | |
15 | def delete_web(address) |
16 | web = Web.find_by_address(address) |
17 | unless web.nil? |
18 | web.destroy |
19 | @webs = nil |
20 | end |
21 | end |
22 | |
23 | def edit_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false, |
24 | password = nil, published = false, brackets_only = false, count_pages = false, |
25 | allow_uploads = true, max_upload_size = nil) |
26 | |
27 | if not (web = Web.find_by_address(old_address)) |
28 | raise Instiki::ValidationError.new("Web with address '#{old_address}' does not exist") |
29 | end |
30 | old_files_path = web.files_path |
31 | |
32 | web.update_attributes(:address => new_address, :name => name, :markup => markup, :color => color, |
33 | :additional_style => additional_style, :safe_mode => safe_mode, :password => password, :published => published, |
34 | :brackets_only => brackets_only, :count_pages => count_pages, :allow_uploads => allow_uploads, :max_upload_size => max_upload_size) |
35 | @webs = nil |
36 | raise Instiki::ValidationError.new("There is already a web with address '#{new_address}'") unless web.errors.on(:address).nil? |
37 | web |
38 | move_files(old_files_path, web.files_path) |
39 | end |
40 | |
41 | def move_files(old_path, new_path) |
42 | return if new_path == old_path |
43 | default_path = Rails.root.join("webs", "files") |
44 | FileUtils.rmdir(new_path) if File.exist?(new_path) |
45 | if [old_path, new_path].include? default_path |
46 | File.rename(old_path, new_path) |
47 | FileUtils.rmdir(old_path.parent) unless old_path == default_path |
48 | else |
49 | File.rename(old_path.parent, new_path.parent) |
50 | end |
51 | end |
52 | |
53 | def read_page(web_address, page_name) |
54 | ApplicationController.logger.debug "Reading page '#{page_name}' from web '#{web_address}'" |
55 | web = Web.find_by_address(web_address) |
56 | if web.nil? |
57 | ApplicationController.logger.debug "Web '#{web_address}' not found" |
58 | return nil |
59 | else |
60 | page = web.pages.first(:conditions => ['name = ?', page_name]) |
61 | ApplicationController.logger.debug "Page '#{page_name}' #{page.nil? ? 'not' : ''} found" |
62 | return page |
63 | end |
64 | end |
65 | |
66 | def remove_orphaned_pages(web_address) |
67 | web = Web.find_by_address(web_address) |
68 | web.remove_pages(web.select.orphaned_pages) |
69 | end |
70 | |
71 | def remove_orphaned_pages_in_category(web_address,category) |
72 | web = Web.find_by_address(web_address) |
73 | pages_in_category = PageSet.new(web, web.select.pages_in_category(category)) |
74 | web.remove_pages(pages_in_category.orphaned_pages) |
75 | end |
76 | |
77 | def revise_page(web_address, page_name, new_name, content, revised_at, author, renderer) |
78 | page = read_page(web_address, page_name) |
79 | page.revise(content, new_name, revised_at, author, renderer) |
80 | end |
81 | |
82 | def rollback_page(web_address, page_name, revision_number, time, author_id = nil) |
83 | page = read_page(web_address, page_name) |
84 | page.rollback(revision_number, time, author_id) |
85 | end |
86 | |
87 | def setup(password, web_name, web_address) |
88 | system.update_attribute(:password, password) |
89 | create_web(web_name, web_address) |
90 | end |
91 | |
92 | def system |
93 | @system ||= (System.first() || System.create) |
94 | end |
95 | |
96 | def setup? |
97 | Web.count > 0 |
98 | end |
99 | |
100 | def webs |
101 | @webs ||= Web.all.inject({}) { |webs, web| webs.merge(web.address => web) } |
102 | end |
103 | |
104 | def storage_path |
105 | self.class.storage_path |
106 | end |
107 | |
108 | def write_page(web_address, page_name, content, written_on, author, renderer) |
109 | Web.find_by_address(web_address).add_page(page_name, content, written_on, author, renderer) |
110 | end |
111 | end |