instiki 0.10.0 → 0.10.1

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.
Files changed (88) hide show
  1. data/CHANGELOG +174 -165
  2. data/README +68 -68
  3. data/app/controllers/admin_controller.rb +94 -94
  4. data/app/controllers/application.rb +135 -131
  5. data/app/controllers/file_controller.rb +129 -129
  6. data/app/controllers/wiki_controller.rb +354 -354
  7. data/app/helpers/application_helper.rb +68 -68
  8. data/app/models/author.rb +3 -3
  9. data/app/models/chunks/category.rb +33 -33
  10. data/app/models/chunks/chunk.rb +86 -86
  11. data/app/models/chunks/engines.rb +61 -54
  12. data/app/models/chunks/include.rb +41 -41
  13. data/app/models/chunks/literal.rb +31 -31
  14. data/app/models/chunks/nowiki.rb +28 -28
  15. data/app/models/chunks/test.rb +18 -18
  16. data/app/models/chunks/uri.rb +182 -182
  17. data/app/models/chunks/wiki.rb +141 -141
  18. data/app/models/file_yard.rb +58 -58
  19. data/app/models/page.rb +112 -112
  20. data/app/models/page_lock.rb +22 -22
  21. data/app/models/page_set.rb +89 -89
  22. data/app/models/revision.rb +123 -123
  23. data/app/models/web.rb +182 -176
  24. data/app/models/wiki_content.rb +207 -207
  25. data/app/models/wiki_service.rb +233 -233
  26. data/app/models/wiki_words.rb +23 -23
  27. data/app/views/admin/create_system.rhtml +83 -83
  28. data/app/views/admin/create_web.rhtml +69 -69
  29. data/app/views/admin/edit_web.rhtml +137 -136
  30. data/app/views/file/file.rhtml +18 -18
  31. data/app/views/file/import.rhtml +22 -22
  32. data/app/views/layouts/default.rhtml +86 -85
  33. data/app/views/markdown_help.rhtml +12 -12
  34. data/app/views/mixed_help.rhtml +6 -6
  35. data/app/views/navigation.rhtml +30 -30
  36. data/app/views/rdoc_help.rhtml +12 -12
  37. data/app/views/textile_help.rhtml +24 -24
  38. data/app/views/wiki/authors.rhtml +11 -11
  39. data/app/views/wiki/edit.rhtml +39 -39
  40. data/app/views/wiki/export.rhtml +12 -12
  41. data/app/views/wiki/feeds.rhtml +14 -14
  42. data/app/views/wiki/list.rhtml +64 -64
  43. data/app/views/wiki/locked.rhtml +23 -23
  44. data/app/views/wiki/login.rhtml +14 -14
  45. data/app/views/wiki/new.rhtml +31 -31
  46. data/app/views/wiki/page.rhtml +115 -115
  47. data/app/views/wiki/print.rhtml +14 -14
  48. data/app/views/wiki/published.rhtml +9 -9
  49. data/app/views/wiki/recently_revised.rhtml +26 -26
  50. data/app/views/wiki/revision.rhtml +103 -103
  51. data/app/views/wiki/rollback.rhtml +36 -36
  52. data/app/views/wiki/rss_feed.rhtml +22 -22
  53. data/app/views/wiki/search.rhtml +38 -38
  54. data/app/views/wiki/tex.rhtml +22 -22
  55. data/app/views/wiki/tex_web.rhtml +34 -34
  56. data/app/views/wiki/web_list.rhtml +18 -18
  57. data/app/views/wiki_words_help.rhtml +9 -9
  58. data/config/environment.rb +82 -82
  59. data/config/environments/development.rb +5 -5
  60. data/config/environments/production.rb +4 -4
  61. data/config/environments/test.rb +17 -17
  62. data/config/routes.rb +18 -18
  63. data/lib/active_record_stub.rb +31 -31
  64. data/lib/bluecloth_tweaked.rb +1127 -0
  65. data/lib/diff.rb +444 -444
  66. data/lib/instiki_errors.rb +14 -14
  67. data/lib/rdocsupport.rb +151 -151
  68. data/lib/redcloth_for_tex.rb +736 -736
  69. data/natives/osx/desktop_launcher/AppDelegate.h +18 -18
  70. data/natives/osx/desktop_launcher/AppDelegate.mm +109 -109
  71. data/natives/osx/desktop_launcher/Credits.html +15 -15
  72. data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/classes.nib +12 -12
  73. data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/info.nib +24 -24
  74. data/natives/osx/desktop_launcher/Info.plist +12 -12
  75. data/natives/osx/desktop_launcher/Instiki.xcode/project.pbxproj +592 -592
  76. data/natives/osx/desktop_launcher/Instiki_Prefix.pch +7 -7
  77. data/natives/osx/desktop_launcher/MakeDMG.sh +9 -9
  78. data/natives/osx/desktop_launcher/main.mm +14 -14
  79. data/natives/osx/desktop_launcher/version.plist +16 -16
  80. data/public/404.html +5 -5
  81. data/public/500.html +5 -5
  82. data/public/dispatch.rb +9 -9
  83. data/public/javascripts/edit_web.js +52 -52
  84. data/public/javascripts/prototype.js +336 -336
  85. data/public/stylesheets/instiki.css +222 -222
  86. data/script/breakpointer +4 -4
  87. data/script/server +93 -93
  88. metadata +4 -3
@@ -1,94 +1,94 @@
1
- require 'application'
2
-
3
- class AdminController < ApplicationController
4
-
5
- layout 'default'
6
-
7
- def create_system
8
- if @wiki.setup?
9
- flash[:error] = <<-EOL
10
- Wiki has already been created in '#{@wiki.storage_path}'. Shut down Instiki and delete
11
- this directory if you want to recreate it from scratch.<br/><br/>
12
- (WARNING: this will destroy content of your current wiki).
13
- EOL
14
- redirect_show('HomePage', @wiki.webs.keys.first)
15
- elsif @params['web_name']
16
- # form submitted -> create a wiki
17
- @wiki.setup(@params['password'], @params['web_name'], @params['web_address'])
18
- flash[:info] = <<-EOL
19
- Your new wiki '#{@params['web_name']}' is created!<br/>
20
- Please edit its home page and press Submit when finished.
21
- EOL
22
- redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new',
23
- :id => 'HomePage'
24
- else
25
- # no form submitted -> go to template
26
- end
27
- end
28
-
29
- def create_web
30
- if @params['address']
31
- # form submitted
32
- if @wiki.authenticate(@params['system_password'])
33
- begin
34
- @wiki.create_web(@params['name'], @params['address'])
35
- flash[:info] = "New web '#{@params['name']}' successfully created."
36
- redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new',
37
- :id => 'HomePage'
38
- rescue Instiki::ValidationError => e
39
- flash[:error] = e.message
40
- # and re-render the form again
41
- end
42
- else
43
- redirect_to :controller => 'wiki', :action => 'index'
44
- end
45
- else
46
- # no form submitted -> render template
47
- end
48
- end
49
-
50
- def edit_web
51
- system_password = @params['system_password']
52
- if system_password
53
- # form submitted
54
- if wiki.authenticate(system_password)
55
- begin
56
- wiki.edit_web(
57
- @web.address, @params['address'], @params['name'],
58
- @params['markup'].intern,
59
- @params['color'], @params['additional_style'],
60
- @params['safe_mode'] ? true : false,
61
- @params['password'].empty? ? nil : @params['password'],
62
- @params['published'] ? true : false,
63
- @params['brackets_only'] ? true : false,
64
- @params['count_pages'] ? true : false,
65
- @params['allow_uploads'] ? true : false,
66
- @params['max_upload_size']
67
- )
68
- flash[:info] = "Web '#{@params['address']}' was successfully updated"
69
- redirect_show('HomePage', @params['address'])
70
- rescue Instiki::ValidationError => e
71
- flash[:error] = e.message
72
- # and re-render the same template again
73
- end
74
- else
75
- flash[:error] = password_error(system_password)
76
- # and re-render the same template again
77
- end
78
- else
79
- # no form submitted - go to template
80
- end
81
- end
82
-
83
- def remove_orphaned_pages
84
- if wiki.authenticate(@params['system_password_orphaned'])
85
- wiki.remove_orphaned_pages(@web_name)
86
- flash[:info] = 'Orphaned pages removed'
87
- redirect_to :controller => 'wiki', :web => @web_name, :action => 'list'
88
- else
89
- flash[:error] = password_error(@params['system_password'])
90
- return_to_last_remembered
91
- end
92
- end
93
-
94
- end
1
+ require 'application'
2
+
3
+ class AdminController < ApplicationController
4
+
5
+ layout 'default'
6
+
7
+ def create_system
8
+ if @wiki.setup?
9
+ flash[:error] = <<-EOL
10
+ Wiki has already been created in '#{@wiki.storage_path}'. Shut down Instiki and delete
11
+ this directory if you want to recreate it from scratch.<br/><br/>
12
+ (WARNING: this will destroy content of your current wiki).
13
+ EOL
14
+ redirect_home(@wiki.webs.keys.first)
15
+ elsif @params['web_name']
16
+ # form submitted -> create a wiki
17
+ @wiki.setup(@params['password'], @params['web_name'], @params['web_address'])
18
+ flash[:info] = <<-EOL
19
+ Your new wiki '#{@params['web_name']}' is created!<br/>
20
+ Please edit its home page and press Submit when finished.
21
+ EOL
22
+ redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new',
23
+ :id => 'HomePage'
24
+ else
25
+ # no form submitted -> go to template
26
+ end
27
+ end
28
+
29
+ def create_web
30
+ if @params['address']
31
+ # form submitted
32
+ if @wiki.authenticate(@params['system_password'])
33
+ begin
34
+ @wiki.create_web(@params['name'], @params['address'])
35
+ flash[:info] = "New web '#{@params['name']}' successfully created."
36
+ redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new',
37
+ :id => 'HomePage'
38
+ rescue Instiki::ValidationError => e
39
+ flash[:error] = e.message
40
+ # and re-render the form again
41
+ end
42
+ else
43
+ redirect_to :controller => 'wiki', :action => 'index'
44
+ end
45
+ else
46
+ # no form submitted -> render template
47
+ end
48
+ end
49
+
50
+ def edit_web
51
+ system_password = @params['system_password']
52
+ if system_password
53
+ # form submitted
54
+ if wiki.authenticate(system_password)
55
+ begin
56
+ wiki.edit_web(
57
+ @web.address, @params['address'], @params['name'],
58
+ @params['markup'].intern,
59
+ @params['color'], @params['additional_style'],
60
+ @params['safe_mode'] ? true : false,
61
+ @params['password'].empty? ? nil : @params['password'],
62
+ @params['published'] ? true : false,
63
+ @params['brackets_only'] ? true : false,
64
+ @params['count_pages'] ? true : false,
65
+ @params['allow_uploads'] ? true : false,
66
+ @params['max_upload_size']
67
+ )
68
+ flash[:info] = "Web '#{@params['address']}' was successfully updated"
69
+ redirect_home(@params['address'])
70
+ rescue Instiki::ValidationError => e
71
+ flash[:error] = e.message
72
+ # and re-render the same template again
73
+ end
74
+ else
75
+ flash[:error] = password_error(system_password)
76
+ # and re-render the same template again
77
+ end
78
+ else
79
+ # no form submitted - go to template
80
+ end
81
+ end
82
+
83
+ def remove_orphaned_pages
84
+ if wiki.authenticate(@params['system_password_orphaned'])
85
+ wiki.remove_orphaned_pages(@web_name)
86
+ flash[:info] = 'Orphaned pages removed'
87
+ redirect_to :controller => 'wiki', :web => @web_name, :action => 'list'
88
+ else
89
+ flash[:error] = password_error(@params['system_password'])
90
+ return_to_last_remembered
91
+ end
92
+ end
93
+
94
+ end
@@ -1,131 +1,135 @@
1
- # The filters added to this controller will be run for all controllers in the application.
2
- # Likewise will all the methods added be available for all controllers.
3
- class ApplicationController < ActionController::Base
4
-
5
- before_filter :set_utf8_http_header, :connect_to_model
6
- after_filter :remember_location
7
-
8
- # For injecting a different wiki model implementation. Intended for use in tests
9
- def self.wiki=(the_wiki)
10
- # a global variable is used here because Rails reloads controller and model classes in the
11
- # development environment; therefore, storing it as a class variable does not work
12
- # class variable is, anyway, not much different from a global variable
13
- $instiki_wiki_service = the_wiki
14
- logger.debug("Wiki service: #{the_wiki.to_s}")
15
- end
16
-
17
- def self.wiki
18
- $instiki_wiki_service
19
- end
20
-
21
- protected
22
-
23
- def authorized?
24
- @web.nil? ||
25
- @web.password.nil? ||
26
- cookies['web_address'] == @web.password ||
27
- password_check(@params['password'])
28
- end
29
-
30
- def check_authorization
31
- if in_a_web? and needs_authorization?(@action_name) and not authorized? and
32
- redirect_to :controller => 'wiki', :action => 'login', :web => @web_name
33
- return false
34
- end
35
- end
36
-
37
- def connect_to_model
38
- @action_name = @params['action'] || 'index'
39
- @web_name = @params['web']
40
- @wiki = wiki
41
- if @web_name
42
- @web = @wiki.webs[@web_name]
43
- if @web.nil?
44
- render_text "Unknown web '#{@web_name}'", '404 Not Found'
45
- return false
46
- end
47
- end
48
- @page_name = @file_name = @params['id']
49
- @page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
50
- @author = cookies['author'] || 'AnonymousCoward'
51
- check_authorization
52
- end
53
-
54
- FILE_TYPES = {
55
- '.exe' => 'application/octet-stream',
56
- '.gif' => 'image/gif',
57
- '.jpg' => 'image/jpeg',
58
- '.pdf' => 'application/pdf',
59
- '.png' => 'image/png',
60
- '.txt' => 'text/plain',
61
- '.zip' => 'application/zip'
62
- } unless defined? FILE_TYPES
63
-
64
- def send_file(file, options = {})
65
- options[:type] ||= (FILE_TYPES[File.extname(file)] || 'application/octet-stream')
66
- super(file, options)
67
- end
68
-
69
- def in_a_web?
70
- not @web_name.nil?
71
- end
72
-
73
- def password_check(password)
74
- if password == @web.password
75
- cookies['web_address'] = password
76
- true
77
- else
78
- false
79
- end
80
- end
81
-
82
- def password_error(password)
83
- if password.nil? or password.empty?
84
- 'Please enter the password.'
85
- else
86
- 'You entered a wrong password. Please enter the right one.'
87
- end
88
- end
89
-
90
- def redirect_show(page_name = @page_name, web = @web_name)
91
- redirect_to :web => web, :controller => 'wiki', :action => 'show',
92
- :id => (page_name || 'HomePage')
93
- end
94
-
95
- @@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import']
96
- def remember_location
97
- if @response.headers['Status'] == '200 OK'
98
- unless @@REMEMBER_NOT.include? action_name or @request.method != :get
99
- @session[:return_to] = @request.request_uri
100
- logger.debug("Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'")
101
- end
102
- end
103
- end
104
-
105
- def return_to_last_remembered
106
- # Forget the redirect location
107
- redirect_target, @session[:return_to] = @session[:return_to], nil
108
- # then try to redirect to it
109
- if redirect_target.nil?
110
- logger.debug("Session ##{session.object_id}: no remembered redirect location, trying /")
111
- redirect_to_url '/'
112
- else
113
- logger.debug("Session ##{session.object_id}: " +
114
- "redirect to the last remembered URL #{redirect_target}")
115
- redirect_to_url(redirect_target)
116
- end
117
- end
118
-
119
- def set_utf8_http_header
120
- @response.headers['Content-Type'] = 'text/html; charset=UTF-8'
121
- end
122
-
123
- def wiki
124
- $instiki_wiki_service
125
- end
126
-
127
- def needs_authorization?(action)
128
- not %w( login authenticate published rss_with_content rss_with_headlines ).include?(action)
129
- end
130
-
131
- end
1
+ # The filters added to this controller will be run for all controllers in the application.
2
+ # Likewise will all the methods added be available for all controllers.
3
+ class ApplicationController < ActionController::Base
4
+
5
+ before_filter :set_utf8_http_header, :connect_to_model
6
+ after_filter :remember_location
7
+
8
+ # For injecting a different wiki model implementation. Intended for use in tests
9
+ def self.wiki=(the_wiki)
10
+ # a global variable is used here because Rails reloads controller and model classes in the
11
+ # development environment; therefore, storing it as a class variable does not work
12
+ # class variable is, anyway, not much different from a global variable
13
+ $instiki_wiki_service = the_wiki
14
+ logger.debug("Wiki service: #{the_wiki.to_s}")
15
+ end
16
+
17
+ def self.wiki
18
+ $instiki_wiki_service
19
+ end
20
+
21
+ protected
22
+
23
+ def authorized?
24
+ @web.nil? ||
25
+ @web.password.nil? ||
26
+ cookies['web_address'] == @web.password ||
27
+ password_check(@params['password'])
28
+ end
29
+
30
+ def check_authorization
31
+ if in_a_web? and needs_authorization?(@action_name) and not authorized? and
32
+ redirect_to :controller => 'wiki', :action => 'login', :web => @web_name
33
+ return false
34
+ end
35
+ end
36
+
37
+ def connect_to_model
38
+ @action_name = @params['action'] || 'index'
39
+ @web_name = @params['web']
40
+ @wiki = wiki
41
+ if @web_name
42
+ @web = @wiki.webs[@web_name]
43
+ if @web.nil?
44
+ render_text "Unknown web '#{@web_name}'", '404 Not Found'
45
+ return false
46
+ end
47
+ end
48
+ @page_name = @file_name = @params['id']
49
+ @page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
50
+ @author = cookies['author'] || 'AnonymousCoward'
51
+ check_authorization
52
+ end
53
+
54
+ FILE_TYPES = {
55
+ '.exe' => 'application/octet-stream',
56
+ '.gif' => 'image/gif',
57
+ '.jpg' => 'image/jpeg',
58
+ '.pdf' => 'application/pdf',
59
+ '.png' => 'image/png',
60
+ '.txt' => 'text/plain',
61
+ '.zip' => 'application/zip'
62
+ } unless defined? FILE_TYPES
63
+
64
+ def send_file(file, options = {})
65
+ options[:type] ||= (FILE_TYPES[File.extname(file)] || 'application/octet-stream')
66
+ super(file, options)
67
+ end
68
+
69
+ def in_a_web?
70
+ not @web_name.nil?
71
+ end
72
+
73
+ def password_check(password)
74
+ if password == @web.password
75
+ cookies['web_address'] = password
76
+ true
77
+ else
78
+ false
79
+ end
80
+ end
81
+
82
+ def password_error(password)
83
+ if password.nil? or password.empty?
84
+ 'Please enter the password.'
85
+ else
86
+ 'You entered a wrong password. Please enter the right one.'
87
+ end
88
+ end
89
+
90
+ def redirect_home(web = @web_name)
91
+ redirect_to_page('HomePage', web)
92
+ end
93
+
94
+ def redirect_to_page(page_name = @page_name, web = @web_name)
95
+ redirect_to :web => web, :controller => 'wiki', :action => 'show',
96
+ :id => (page_name || 'HomePage')
97
+ end
98
+
99
+ @@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import']
100
+ def remember_location
101
+ if @response.headers['Status'] == '200 OK'
102
+ unless @@REMEMBER_NOT.include? action_name or @request.method != :get
103
+ @session[:return_to] = @request.request_uri
104
+ logger.debug("Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'")
105
+ end
106
+ end
107
+ end
108
+
109
+ def return_to_last_remembered
110
+ # Forget the redirect location
111
+ redirect_target, @session[:return_to] = @session[:return_to], nil
112
+ # then try to redirect to it
113
+ if redirect_target.nil?
114
+ logger.debug("Session ##{session.object_id}: no remembered redirect location, trying /")
115
+ redirect_to_url '/'
116
+ else
117
+ logger.debug("Session ##{session.object_id}: " +
118
+ "redirect to the last remembered URL #{redirect_target}")
119
+ redirect_to_url(redirect_target)
120
+ end
121
+ end
122
+
123
+ def set_utf8_http_header
124
+ @response.headers['Content-Type'] = 'text/html; charset=UTF-8'
125
+ end
126
+
127
+ def wiki
128
+ $instiki_wiki_service
129
+ end
130
+
131
+ def needs_authorization?(action)
132
+ not %w( login authenticate published rss_with_content rss_with_headlines ).include?(action)
133
+ end
134
+
135
+ end