instiki 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +165 -0
- data/README +68 -172
- data/app/controllers/admin_controller.rb +94 -0
- data/app/controllers/application.rb +131 -0
- data/app/controllers/file_controller.rb +129 -0
- data/app/controllers/wiki_controller.rb +354 -0
- data/{libraries/view_helper.rb → app/helpers/application_helper.rb} +68 -33
- data/app/models/author.rb +3 -3
- data/app/models/chunks/category.rb +33 -31
- data/app/models/chunks/chunk.rb +86 -20
- data/app/models/chunks/engines.rb +54 -38
- data/app/models/chunks/include.rb +41 -29
- data/app/models/chunks/literal.rb +31 -19
- data/app/models/chunks/nowiki.rb +28 -31
- data/app/models/chunks/test.rb +18 -18
- data/app/models/chunks/uri.rb +182 -97
- data/app/models/chunks/wiki.rb +141 -82
- data/app/models/file_yard.rb +58 -0
- data/app/models/page.rb +112 -86
- data/app/models/page_lock.rb +22 -23
- data/app/models/page_set.rb +89 -64
- data/app/models/revision.rb +123 -90
- data/app/models/web.rb +176 -89
- data/app/models/wiki_content.rb +207 -105
- data/app/models/wiki_service.rb +233 -83
- data/app/models/wiki_words.rb +23 -25
- data/app/views/{wiki/new_system.rhtml → admin/create_system.rhtml} +83 -78
- data/app/views/{wiki/new_web.rhtml → admin/create_web.rhtml} +69 -64
- data/app/views/admin/edit_web.rhtml +136 -0
- data/app/views/file/file.rhtml +19 -0
- data/app/views/file/import.rhtml +23 -0
- data/app/views/layouts/default.rhtml +85 -0
- data/app/views/markdown_help.rhtml +12 -16
- data/app/views/mixed_help.rhtml +7 -0
- data/app/views/navigation.rhtml +30 -19
- data/app/views/rdoc_help.rhtml +12 -16
- data/app/views/textile_help.rhtml +24 -28
- data/app/views/wiki/authors.rhtml +11 -13
- data/app/views/wiki/edit.rhtml +39 -31
- data/app/views/wiki/export.rhtml +12 -14
- data/app/views/wiki/feeds.rhtml +14 -10
- data/app/views/wiki/list.rhtml +64 -57
- data/app/views/wiki/locked.rhtml +23 -14
- data/app/views/wiki/login.rhtml +14 -11
- data/app/views/wiki/new.rhtml +31 -27
- data/app/views/wiki/page.rhtml +115 -81
- data/app/views/wiki/print.rhtml +14 -16
- data/app/views/wiki/published.rhtml +9 -10
- data/app/views/wiki/recently_revised.rhtml +27 -30
- data/app/views/wiki/revision.rhtml +103 -81
- data/app/views/wiki/rollback.rhtml +14 -9
- data/app/views/wiki/rss_feed.rhtml +22 -22
- data/app/views/wiki/search.rhtml +38 -15
- data/app/views/wiki/tex.rhtml +22 -22
- data/app/views/wiki/tex_web.rhtml +34 -34
- data/app/views/wiki/web_list.rhtml +18 -13
- data/app/views/wiki_words_help.rhtml +9 -8
- data/config/environment.rb +82 -0
- data/config/environments/development.rb +5 -0
- data/config/environments/production.rb +4 -0
- data/config/environments/test.rb +17 -0
- data/config/routes.rb +18 -0
- data/instiki +6 -67
- data/instiki.rb +3 -0
- data/lib/active_record_stub.rb +31 -0
- data/{libraries/diff → lib}/diff.rb +444 -475
- data/lib/instiki_errors.rb +15 -0
- data/{libraries → lib}/rdocsupport.rb +151 -155
- data/lib/redcloth_for_tex.rb +736 -0
- data/natives/osx/desktop_launcher/AppDelegate.h +18 -0
- data/natives/osx/desktop_launcher/AppDelegate.mm +109 -0
- data/natives/osx/desktop_launcher/Credits.html +16 -0
- data/natives/osx/desktop_launcher/English.lproj/InfoPlist.strings +0 -0
- data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/classes.nib +13 -0
- data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/info.nib +24 -0
- data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/objects.nib +0 -0
- data/natives/osx/desktop_launcher/Info.plist +13 -0
- data/natives/osx/desktop_launcher/Instiki.xcode/project.pbxproj +592 -0
- data/natives/osx/desktop_launcher/Instiki_Prefix.pch +7 -0
- data/natives/osx/desktop_launcher/MakeDMG.sh +9 -0
- data/natives/osx/desktop_launcher/main.mm +14 -0
- data/natives/osx/desktop_launcher/version.plist +16 -0
- data/public/404.html +6 -0
- data/public/500.html +6 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/edit_web.js +52 -0
- data/public/javascripts/prototype.js +336 -0
- data/{app/views/static_style_sheet.rhtml → public/stylesheets/instiki.css} +221 -198
- data/script/breakpointer +4 -0
- data/script/server +93 -0
- metadata +59 -32
- data/app/controllers/wiki.rb +0 -389
- data/app/models/chunks/match.rb +0 -19
- data/app/views/bottom.rhtml +0 -4
- data/app/views/top.rhtml +0 -49
- data/app/views/wiki/edit_web.rhtml +0 -138
- data/libraries/action_controller_servlet.rb +0 -177
- data/libraries/erb.rb +0 -490
- data/libraries/madeleine_service.rb +0 -68
- data/libraries/redcloth_for_tex.rb +0 -869
- data/libraries/web_controller_server.rb +0 -81
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: instiki
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.10.0
|
7
|
+
date: 2005-04-08
|
8
8
|
summary: Easy to install WikiClone running on WEBrick and Madeleine
|
9
9
|
require_paths:
|
10
|
-
-
|
10
|
+
- lib
|
11
11
|
email: david@loudthinking.com
|
12
12
|
homepage: http://www.instiki.org
|
13
13
|
rubyforge_project: instiki
|
@@ -15,7 +15,7 @@ description: Instiki is a Wiki Clone written in Ruby that ships with an embedded
|
|
15
15
|
autorequire:
|
16
16
|
default_executable: instiki
|
17
17
|
bindir: "."
|
18
|
-
has_rdoc:
|
18
|
+
has_rdoc: false
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
21
|
-
|
@@ -27,10 +27,17 @@ platform: ruby
|
|
27
27
|
authors:
|
28
28
|
- David Heinemeier Hansson
|
29
29
|
files:
|
30
|
+
- CHANGELOG
|
30
31
|
- README
|
31
32
|
- instiki
|
32
|
-
-
|
33
|
+
- instiki.rb
|
34
|
+
- app/controllers/admin_controller.rb
|
35
|
+
- app/controllers/application.rb
|
36
|
+
- app/controllers/file_controller.rb
|
37
|
+
- app/controllers/wiki_controller.rb
|
38
|
+
- app/helpers/application_helper.rb
|
33
39
|
- app/models/author.rb
|
40
|
+
- app/models/file_yard.rb
|
34
41
|
- app/models/page.rb
|
35
42
|
- app/models/page_lock.rb
|
36
43
|
- app/models/page_set.rb
|
@@ -44,30 +51,30 @@ files:
|
|
44
51
|
- app/models/chunks/engines.rb
|
45
52
|
- app/models/chunks/include.rb
|
46
53
|
- app/models/chunks/literal.rb
|
47
|
-
- app/models/chunks/match.rb
|
48
54
|
- app/models/chunks/nowiki.rb
|
49
55
|
- app/models/chunks/test.rb
|
50
56
|
- app/models/chunks/uri.rb
|
51
57
|
- app/models/chunks/wiki.rb
|
52
|
-
- app/views/bottom.rhtml
|
53
58
|
- app/views/markdown_help.rhtml
|
59
|
+
- app/views/mixed_help.rhtml
|
54
60
|
- app/views/navigation.rhtml
|
55
61
|
- app/views/rdoc_help.rhtml
|
56
|
-
- app/views/static_style_sheet.rhtml
|
57
62
|
- app/views/textile_help.rhtml
|
58
|
-
- app/views/top.rhtml
|
59
63
|
- app/views/wiki_words_help.rhtml
|
64
|
+
- app/views/admin/create_system.rhtml
|
65
|
+
- app/views/admin/create_web.rhtml
|
66
|
+
- app/views/admin/edit_web.rhtml
|
67
|
+
- app/views/file/file.rhtml
|
68
|
+
- app/views/file/import.rhtml
|
69
|
+
- app/views/layouts/default.rhtml
|
60
70
|
- app/views/wiki/authors.rhtml
|
61
71
|
- app/views/wiki/edit.rhtml
|
62
|
-
- app/views/wiki/edit_web.rhtml
|
63
72
|
- app/views/wiki/export.rhtml
|
64
73
|
- app/views/wiki/feeds.rhtml
|
65
74
|
- app/views/wiki/list.rhtml
|
66
75
|
- app/views/wiki/locked.rhtml
|
67
76
|
- app/views/wiki/login.rhtml
|
68
77
|
- app/views/wiki/new.rhtml
|
69
|
-
- app/views/wiki/new_system.rhtml
|
70
|
-
- app/views/wiki/new_web.rhtml
|
71
78
|
- app/views/wiki/page.rhtml
|
72
79
|
- app/views/wiki/print.rhtml
|
73
80
|
- app/views/wiki/published.rhtml
|
@@ -79,20 +86,40 @@ files:
|
|
79
86
|
- app/views/wiki/tex.rhtml
|
80
87
|
- app/views/wiki/tex_web.rhtml
|
81
88
|
- app/views/wiki/web_list.rhtml
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
89
|
+
- lib/active_record_stub.rb
|
90
|
+
- lib/diff.rb
|
91
|
+
- lib/instiki_errors.rb
|
92
|
+
- lib/rdocsupport.rb
|
93
|
+
- lib/redcloth_for_tex.rb
|
94
|
+
- public/404.html
|
95
|
+
- public/500.html
|
96
|
+
- public/dispatch.rb
|
97
|
+
- public/favicon.ico
|
98
|
+
- public/javascripts/edit_web.js
|
99
|
+
- public/javascripts/prototype.js
|
100
|
+
- public/stylesheets/instiki.css
|
101
|
+
- natives/osx/desktop_launcher/AppDelegate.h
|
102
|
+
- natives/osx/desktop_launcher/AppDelegate.mm
|
103
|
+
- natives/osx/desktop_launcher/Credits.html
|
104
|
+
- natives/osx/desktop_launcher/Info.plist
|
105
|
+
- natives/osx/desktop_launcher/Instiki_Prefix.pch
|
106
|
+
- natives/osx/desktop_launcher/main.mm
|
107
|
+
- natives/osx/desktop_launcher/MakeDMG.sh
|
108
|
+
- natives/osx/desktop_launcher/version.plist
|
109
|
+
- natives/osx/desktop_launcher/English.lproj/InfoPlist.strings
|
110
|
+
- natives/osx/desktop_launcher/English.lproj/MainMenu.nib/classes.nib
|
111
|
+
- natives/osx/desktop_launcher/English.lproj/MainMenu.nib/info.nib
|
112
|
+
- natives/osx/desktop_launcher/English.lproj/MainMenu.nib/objects.nib
|
113
|
+
- natives/osx/desktop_launcher/Instiki.xcode/project.pbxproj
|
114
|
+
- config/environment.rb
|
115
|
+
- config/routes.rb
|
116
|
+
- config/environments/development.rb
|
117
|
+
- config/environments/production.rb
|
118
|
+
- config/environments/test.rb
|
119
|
+
- script/breakpointer
|
120
|
+
- script/server
|
90
121
|
test_files: []
|
91
|
-
rdoc_options:
|
92
|
-
- "--title"
|
93
|
-
- "Instiki -- The Wiki"
|
94
|
-
- "--line-numbers"
|
95
|
-
- "--inline-source"
|
122
|
+
rdoc_options: []
|
96
123
|
extra_rdoc_files: []
|
97
124
|
executables:
|
98
125
|
- instiki
|
@@ -111,32 +138,32 @@ dependencies:
|
|
111
138
|
version: 0.7.1
|
112
139
|
version:
|
113
140
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
141
|
+
name: RedCloth
|
115
142
|
version_requirement:
|
116
143
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
117
144
|
requirements:
|
118
145
|
-
|
119
146
|
- "="
|
120
147
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
148
|
+
version: 3.0.3
|
122
149
|
version:
|
123
150
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
151
|
+
name: rubyzip
|
125
152
|
version_requirement:
|
126
153
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
127
154
|
requirements:
|
128
155
|
-
|
129
156
|
- "="
|
130
157
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
158
|
+
version: 0.5.5
|
132
159
|
version:
|
133
160
|
- !ruby/object:Gem::Dependency
|
134
|
-
name:
|
161
|
+
name: rails
|
135
162
|
version_requirement:
|
136
163
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
137
164
|
requirements:
|
138
165
|
-
|
139
166
|
- "="
|
140
167
|
- !ruby/object:Gem::Version
|
141
|
-
version: 0.
|
168
|
+
version: 0.11.1
|
142
169
|
version:
|
data/app/controllers/wiki.rb
DELETED
@@ -1,389 +0,0 @@
|
|
1
|
-
require "cgi"
|
2
|
-
require "redcloth_for_tex"
|
3
|
-
|
4
|
-
class WikiController < ActionControllerServlet
|
5
|
-
EXPORT_DIRECTORY = File.dirname(__FILE__) + "/../../storage/" unless const_defined?("EXPORT_DIRECTORY")
|
6
|
-
|
7
|
-
def index
|
8
|
-
if web_address
|
9
|
-
redirect_show "HomePage"
|
10
|
-
elsif !wiki.setup?
|
11
|
-
redirect_path "/new_system/"
|
12
|
-
elsif wiki.webs.length == 1
|
13
|
-
redirect_show "HomePage", wiki.webs.values.first.address
|
14
|
-
else
|
15
|
-
redirect_path "/web_list/"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Administrating the Instiki setup --------------------------------------------
|
20
|
-
|
21
|
-
def new_system
|
22
|
-
wiki.setup? ? redirect_path("/") : render
|
23
|
-
end
|
24
|
-
|
25
|
-
def new_web
|
26
|
-
redirect_path("/") if wiki.system["password"].nil?
|
27
|
-
end
|
28
|
-
|
29
|
-
def create_system
|
30
|
-
wiki.setup(@params["password"], @params["web_name"], @params["web_address"]) unless wiki.setup?
|
31
|
-
redirect_path "/"
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_web
|
35
|
-
redirect_path("/") unless wiki.authenticate(@params["system_password"])
|
36
|
-
wiki.create_web(@params["name"], @params["address"])
|
37
|
-
redirect_show("HomePage", @params["address"])
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
# Outside a single web --------------------------------------------------------
|
42
|
-
|
43
|
-
def web_list
|
44
|
-
@system, @webs = wiki.system, wiki.webs.values
|
45
|
-
render "wiki/web_list"
|
46
|
-
end
|
47
|
-
|
48
|
-
def login
|
49
|
-
render "wiki/login"
|
50
|
-
end
|
51
|
-
|
52
|
-
def authenticate
|
53
|
-
password_check(@params["password"]) ? redirect_show("HomePage") : redirect_action("login")
|
54
|
-
end
|
55
|
-
|
56
|
-
def static_style_sheet() render "static_style_sheet" end
|
57
|
-
|
58
|
-
|
59
|
-
# Within a single web ---------------------------------------------------------
|
60
|
-
|
61
|
-
def parse_category
|
62
|
-
@categories = web.categories
|
63
|
-
@category = @params["category"]
|
64
|
-
@pages_in_category = web.select { |page| page.in_category?(@category) }
|
65
|
-
@set_name = ( @categories.include?(@category) ? "category '#{@category}'" : "the web" )
|
66
|
-
@category_links = @categories.map do |c|
|
67
|
-
(@category == c ? "<span class=\"selected\">#{c}</span>" : "<a href=\"?category=#{c}\">#{c}</a>")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def search
|
72
|
-
@query = @params["query"]
|
73
|
-
@results = web.select { |page| page.content =~ /#{@query}/i }
|
74
|
-
@results.length == 1 ? redirect_show(@results.first.name) : render
|
75
|
-
end
|
76
|
-
|
77
|
-
def authors
|
78
|
-
@authors = web.select.authors
|
79
|
-
end
|
80
|
-
|
81
|
-
def recently_revised
|
82
|
-
parse_category
|
83
|
-
@pages_by_revision = @pages_in_category.by_revision
|
84
|
-
end
|
85
|
-
|
86
|
-
def rss_with_content
|
87
|
-
@pages_by_revision = web.select.by_revision.first(15)
|
88
|
-
@uri = @req.request_uri
|
89
|
-
host = @req.meta_vars["HTTP_X_FORWARDED_HOST"] || "#{@uri.host}:#{@uri.port.to_s}"
|
90
|
-
@web_url = "#{@uri.scheme}://#{host}/#{@web.address}"
|
91
|
-
@res["Content-Type"] = "text/xml"
|
92
|
-
render "wiki/rss_feed"
|
93
|
-
end
|
94
|
-
|
95
|
-
def rss_with_headlines
|
96
|
-
@hide_description = true
|
97
|
-
rss_with_content
|
98
|
-
end
|
99
|
-
|
100
|
-
def list
|
101
|
-
parse_category
|
102
|
-
@pages_by_name = @pages_in_category.by_name
|
103
|
-
@page_names_that_are_wanted = @pages_in_category.wanted_pages
|
104
|
-
@pages_that_are_orphaned = @pages_in_category.orphaned_pages
|
105
|
-
end
|
106
|
-
|
107
|
-
def export_html
|
108
|
-
file_name = "#{web.address}-html-#{web.revised_on.strftime("%Y-%m-%d-%H-%M")}.zip"
|
109
|
-
file_path = EXPORT_DIRECTORY + file_name
|
110
|
-
|
111
|
-
export_pages_to_zip_file(file_path) unless FileTest.exists?(file_path)
|
112
|
-
send_export(file_name, file_path)
|
113
|
-
end
|
114
|
-
|
115
|
-
def export_markup
|
116
|
-
file_name = "#{web.address}-markup-#{web.revised_on.strftime("%Y-%m-%d-%H-%M")}.zip"
|
117
|
-
file_path = EXPORT_DIRECTORY + file_name
|
118
|
-
|
119
|
-
export_markup_to_zip_file(file_path) unless FileTest.exists?(file_path)
|
120
|
-
send_export(file_name, file_path)
|
121
|
-
end
|
122
|
-
|
123
|
-
def export_pdf
|
124
|
-
file_name = "#{web.address}-tex-#{web.revised_on.strftime("%Y-%m-%d-%H-%M")}"
|
125
|
-
file_path = EXPORT_DIRECTORY + file_name
|
126
|
-
|
127
|
-
export_web_to_tex(file_path + ".tex") unless FileTest.exists?(file_path + ".tex")
|
128
|
-
convert_tex_to_pdf(file_path + ".tex")
|
129
|
-
send_export(file_name + ".pdf", file_path + ".pdf")
|
130
|
-
end
|
131
|
-
|
132
|
-
def export_tex
|
133
|
-
file_name = "#{web.address}-tex-#{web.revised_on.strftime("%Y-%m-%d-%H-%M")}.tex"
|
134
|
-
file_path = EXPORT_DIRECTORY + file_name
|
135
|
-
|
136
|
-
export_web_to_tex(file_path) unless FileTest.exists?(file_path)
|
137
|
-
send_export(file_name, file_path)
|
138
|
-
end
|
139
|
-
|
140
|
-
def update_web
|
141
|
-
redirect_show("HomePage") unless wiki.authenticate(@params["system_password"])
|
142
|
-
|
143
|
-
wiki.update_web(
|
144
|
-
web.address, @params["address"], @params["name"],
|
145
|
-
@params["markup"].intern,
|
146
|
-
@params["color"], @params["additional_style"],
|
147
|
-
@params["safe_mode"] ? true : false,
|
148
|
-
@params["password"].empty? ? nil : @params["password"],
|
149
|
-
@params["published"] ? true : false,
|
150
|
-
@params["brackets_only"] ? true : false,
|
151
|
-
@params["count_pages"] ? true : false
|
152
|
-
)
|
153
|
-
|
154
|
-
redirect_show("HomePage", @params["address"])
|
155
|
-
end
|
156
|
-
|
157
|
-
def remove_orphaned_pages
|
158
|
-
if wiki.authenticate(@params["system_password"])
|
159
|
-
wiki.remove_orphaned_pages(web_address)
|
160
|
-
redirect_action "list/"
|
161
|
-
else
|
162
|
-
redirect_show "HomePage"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# Within a single page --------------------------------------------------------
|
167
|
-
|
168
|
-
def show
|
169
|
-
if @page = wiki.read_page(web_address, page_name)
|
170
|
-
begin
|
171
|
-
render_action "page"
|
172
|
-
rescue => e
|
173
|
-
$stderr << e.backtrace.join("\n")
|
174
|
-
redirect_action "edit/#{CGI.escape(page_name)}?msg=#{CGI.escape(e.message)}"
|
175
|
-
end
|
176
|
-
else
|
177
|
-
redirect_action "new/#{CGI.escape(page_name)}"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def published
|
182
|
-
if web.published then @page = wiki.read_page(web_address, page_name || "HomePage") else redirect_show("HomePage") end
|
183
|
-
end
|
184
|
-
|
185
|
-
def print
|
186
|
-
@page = wiki.read_page(web_address, page_name)
|
187
|
-
end
|
188
|
-
|
189
|
-
def tex
|
190
|
-
@page = wiki.read_page(web_address, page_name)
|
191
|
-
@tex_content = RedClothForTex.new(@page.content).to_tex
|
192
|
-
end
|
193
|
-
|
194
|
-
def pdf
|
195
|
-
page = wiki.read_page(web_address, page_name)
|
196
|
-
safe_page_name = page.name.gsub(/\W/, "")
|
197
|
-
file_name = "#{safe_page_name}-#{web.address}-#{page.created_at.strftime("%Y-%m-%d-%H-%M")}"
|
198
|
-
file_path = EXPORT_DIRECTORY + file_name
|
199
|
-
|
200
|
-
export_page_to_tex(file_path + ".tex") unless FileTest.exists?(file_path + ".tex")
|
201
|
-
convert_tex_to_pdf(file_path + ".tex")
|
202
|
-
send_export(file_name + ".pdf", file_path + ".pdf")
|
203
|
-
end
|
204
|
-
|
205
|
-
def new
|
206
|
-
@page_name, @author = page_name, default_author
|
207
|
-
end
|
208
|
-
|
209
|
-
def edit
|
210
|
-
@page = wiki.read_page(web_address, page_name)
|
211
|
-
|
212
|
-
if !@page.locked?(Time.now) || @params["break_lock"]
|
213
|
-
@page.lock(Time.now, default_author)
|
214
|
-
@author = default_author
|
215
|
-
render
|
216
|
-
else
|
217
|
-
render "wiki/locked"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def cancel_edit
|
222
|
-
@page = wiki.read_page(web_address, page_name)
|
223
|
-
@page.unlock
|
224
|
-
redirect_show
|
225
|
-
end
|
226
|
-
|
227
|
-
def save
|
228
|
-
if web.pages[page_name]
|
229
|
-
page = wiki.revise_page(
|
230
|
-
web_address, page_name, @params["content"], Time.now,
|
231
|
-
Author.new(@params["author"], remote_ip)
|
232
|
-
)
|
233
|
-
|
234
|
-
page.unlock
|
235
|
-
else
|
236
|
-
page = wiki.write_page(
|
237
|
-
web_address, page_name, @params["content"], Time.now,
|
238
|
-
Author.new(@params["author"], remote_ip)
|
239
|
-
)
|
240
|
-
end
|
241
|
-
|
242
|
-
write_cookie("author", @params["author"], true)
|
243
|
-
redirect_show(page_name)
|
244
|
-
end
|
245
|
-
|
246
|
-
def revision
|
247
|
-
@page = wiki.read_page(web_address, page_name)
|
248
|
-
@revision = @page.revisions[@params["rev"].to_i]
|
249
|
-
end
|
250
|
-
|
251
|
-
def rollback
|
252
|
-
@page = wiki.read_page(web_address, page_name)
|
253
|
-
@revision = @page.revisions[@params["rev"].to_i]
|
254
|
-
end
|
255
|
-
|
256
|
-
|
257
|
-
protected
|
258
|
-
def before_action
|
259
|
-
if in_a_web? && !authorized?(web_address) && !%w( login authenticate published ).include?(action_name)
|
260
|
-
redirect_action("login")
|
261
|
-
return false
|
262
|
-
elsif in_a_web?
|
263
|
-
@web, @page_name, @action_name = web, page_name, action_name
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
def action_name
|
268
|
-
if in_a_web?
|
269
|
-
request_path[1]
|
270
|
-
elsif action_methods.include?(request_path[0])
|
271
|
-
request_path[0]
|
272
|
-
else
|
273
|
-
"index"
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
def redirect_show(page = @page.name, web = web_address)
|
278
|
-
redirect_path "/#{web}/show/#{CGI.escape(page)}"
|
279
|
-
end
|
280
|
-
|
281
|
-
def redirect_action(action, web = web_address)
|
282
|
-
redirect_path "/#{web}/#{action}"
|
283
|
-
end
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
private
|
288
|
-
def wiki
|
289
|
-
WikiService.instance
|
290
|
-
end
|
291
|
-
|
292
|
-
def web
|
293
|
-
wiki.webs[web_address]
|
294
|
-
end
|
295
|
-
|
296
|
-
def in_a_web?
|
297
|
-
request_path.length > 1
|
298
|
-
end
|
299
|
-
|
300
|
-
def web_address
|
301
|
-
request_path[0]
|
302
|
-
end
|
303
|
-
|
304
|
-
def page_name
|
305
|
-
CGI.unescape(request_path[2]) if request_path[2]
|
306
|
-
end
|
307
|
-
|
308
|
-
def authorized?(web_address)
|
309
|
-
web.nil? ||
|
310
|
-
web.password.nil? ||
|
311
|
-
(read_cookie(web_address) && read_cookie(web_address) == web.password) ||
|
312
|
-
password_check(@params["password"])
|
313
|
-
end
|
314
|
-
|
315
|
-
def default_author
|
316
|
-
read_cookie("author") || "AnonymousCoward"
|
317
|
-
end
|
318
|
-
|
319
|
-
def password_check(password)
|
320
|
-
@params["password"] == web.password && write_cookie(web_address, @params["password"])
|
321
|
-
end
|
322
|
-
|
323
|
-
def export_pages_to_zip_file(zip_file_path)
|
324
|
-
Zip::ZipOutputStream.open(zip_file_path) do |zos|
|
325
|
-
web.select.by_name.each do |@page|
|
326
|
-
zos.put_next_entry(@page.name + ".html")
|
327
|
-
zos.puts(template_engine("print").result(binding))
|
328
|
-
end
|
329
|
-
|
330
|
-
zos.put_next_entry("index.html")
|
331
|
-
zos.puts('<html><head><META HTTP-EQUIV="Refresh" CONTENT="0;URL=HomePage.html"></head></html>')
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
def export_markup_to_zip_file(zip_file_path)
|
336
|
-
Zip::ZipOutputStream.open(zip_file_path) do |zos|
|
337
|
-
web.select.by_name.each do |page|
|
338
|
-
zos.put_next_entry(page.name + ".#{web.markup}")
|
339
|
-
zos.puts(page.content)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
def export_web_to_tex(file_path)
|
345
|
-
@web_name = web.name
|
346
|
-
@tex_content = table_of_contents(web.pages["HomePage"].content.dup, render_tex_web)
|
347
|
-
File.open(file_path, "w") { |f| f.write(template_engine("tex_web").result(binding)) }
|
348
|
-
end
|
349
|
-
|
350
|
-
def render_tex_web
|
351
|
-
web.select.by_name.inject({}) do |tex_web, page|
|
352
|
-
tex_web[page.name] = RedClothForTex.new(page.content).to_tex
|
353
|
-
tex_web
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def export_page_to_tex(file_path)
|
358
|
-
tex
|
359
|
-
File.open(file_path, "w") { |f| f.write(template_engine("tex").result(binding)) }
|
360
|
-
end
|
361
|
-
|
362
|
-
def convert_tex_to_pdf(tex_path)
|
363
|
-
`cd #{File.dirname(tex_path)}; pdflatex --interaction=scrollmode '#{File.basename(tex_path)}'`
|
364
|
-
end
|
365
|
-
|
366
|
-
def truncate(text, length = 30, truncate_string = "...")
|
367
|
-
if text.length > length then text[0..(length - 3)] + truncate_string else text end
|
368
|
-
end
|
369
|
-
|
370
|
-
def render_markup_help
|
371
|
-
web ? sub_template("#{web.markup}_help") : ''
|
372
|
-
end
|
373
|
-
|
374
|
-
def send_export(file_name, file_path, content_type = "application/zip")
|
375
|
-
@res["Content-Type"] = content_type
|
376
|
-
@res["Content-Disposition"] = "attachment; filename=#{file_name}"
|
377
|
-
@res["Content-Length"] = File.size(file_path)
|
378
|
-
File.open(file_path, "rb") { |f| @res.body = f.read }
|
379
|
-
end
|
380
|
-
|
381
|
-
def template_engine(template_name)
|
382
|
-
ERB.new(IO.readlines(action_template_path(template_name)).join)
|
383
|
-
end
|
384
|
-
|
385
|
-
def remote_ip
|
386
|
-
$stderr << "#{@req.meta_vars['HTTP_X_FORWARDED_FOR']} || #{@req.meta_vars['REMOTE_ADDR']}"
|
387
|
-
@req.meta_vars["HTTP_X_FORWARDED_FOR"] || @req.meta_vars["REMOTE_ADDR"]
|
388
|
-
end
|
389
|
-
end
|