Pimki 1.3.092 → 1.4.092

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README +145 -131
  2. data/README-PIMKI +15 -5
  3. data/app/controllers/wiki.rb +167 -54
  4. data/app/models/author.rb +3 -3
  5. data/app/models/chunks/chunk.rb +3 -3
  6. data/app/models/chunks/engines.rb +18 -21
  7. data/app/models/chunks/include.rb +29 -29
  8. data/app/models/chunks/literal.rb +20 -20
  9. data/app/models/chunks/match.rb +19 -19
  10. data/app/models/chunks/nowiki.rb +31 -31
  11. data/app/models/chunks/nowiki_test.rb +14 -14
  12. data/app/models/chunks/test.rb +18 -18
  13. data/app/models/chunks/todo.rb +44 -23
  14. data/app/models/chunks/uri.rb +97 -97
  15. data/app/models/chunks/uri_test.rb +92 -92
  16. data/app/models/chunks/wiki.rb +4 -4
  17. data/app/models/chunks/wiki_symbols.rb +22 -22
  18. data/app/models/chunks/wiki_test.rb +36 -36
  19. data/app/models/page.rb +39 -7
  20. data/app/models/page_lock.rb +23 -23
  21. data/app/models/page_set.rb +72 -72
  22. data/app/models/page_test.rb +75 -75
  23. data/app/models/revision.rb +1 -1
  24. data/app/models/revision_test.rb +251 -251
  25. data/app/models/web.rb +19 -6
  26. data/app/models/web_test.rb +52 -52
  27. data/app/models/wiki_content.rb +131 -119
  28. data/app/models/wiki_service.rb +31 -16
  29. data/app/models/wiki_service_test.rb +15 -15
  30. data/app/models/wiki_words.rb +1 -1
  31. data/app/models/wiki_words_test.rb +12 -12
  32. data/app/views/bottom.rhtml +3 -3
  33. data/app/views/markdown_help.rhtml +15 -15
  34. data/app/views/menu.rhtml +20 -20
  35. data/app/views/navigation.rhtml +26 -26
  36. data/app/views/rdoc_help.rhtml +15 -15
  37. data/app/views/static_style_sheet.rhtml +237 -237
  38. data/app/views/style.rhtml +178 -178
  39. data/app/views/textile_help.rhtml +27 -27
  40. data/app/views/top.rhtml +7 -2
  41. data/app/views/wiki/authors.rhtml +15 -15
  42. data/app/views/wiki/bliki.rhtml +101 -101
  43. data/app/views/wiki/bliki_edit.rhtml +3 -0
  44. data/app/views/wiki/bliki_new.rhtml +3 -0
  45. data/app/views/wiki/bliki_revision.rhtml +90 -90
  46. data/app/views/wiki/edit.rhtml +12 -3
  47. data/app/views/wiki/edit_menu.rhtml +64 -47
  48. data/app/views/wiki/edit_web.rhtml +65 -18
  49. data/app/views/wiki/export.rhtml +14 -14
  50. data/app/views/wiki/feeds.rhtml +10 -10
  51. data/app/views/wiki/list.rhtml +17 -15
  52. data/app/views/wiki/locked.rhtml +13 -13
  53. data/app/views/wiki/login.rhtml +10 -10
  54. data/app/views/wiki/mind.rhtml +0 -1
  55. data/app/views/wiki/new.rhtml +8 -3
  56. data/app/views/wiki/new_system.rhtml +77 -77
  57. data/app/views/wiki/new_web.rhtml +63 -63
  58. data/app/views/wiki/page.rhtml +88 -82
  59. data/app/views/wiki/print.rhtml +15 -15
  60. data/app/views/wiki/published.rhtml +2 -1
  61. data/app/views/wiki/recently_revised.rhtml +31 -31
  62. data/app/views/wiki/revision.rhtml +1 -7
  63. data/app/views/wiki/rollback.rhtml +31 -0
  64. data/app/views/wiki/rss_feed.rhtml +21 -21
  65. data/app/views/wiki/search.rhtml +48 -48
  66. data/app/views/wiki/tex.rhtml +22 -22
  67. data/app/views/wiki/tex_web.rhtml +34 -34
  68. data/app/views/wiki/todo.rhtml +90 -67
  69. data/app/views/wiki/web_list.rhtml +12 -12
  70. data/app/views/wiki_words_help.rhtml +1 -1
  71. data/favicon.png +0 -0
  72. data/libraries/action_controller_servlet.rb +17 -2
  73. data/libraries/bluecloth.rb +1127 -1127
  74. data/libraries/diff/diff.rb +474 -474
  75. data/libraries/diff/diff_test.rb +79 -79
  76. data/libraries/erb.rb +490 -490
  77. data/libraries/madeleine/automatic.rb +418 -357
  78. data/libraries/madeleine/clock.rb +94 -94
  79. data/libraries/madeleine/files.rb +19 -0
  80. data/libraries/madeleine/zmarshal.rb +60 -0
  81. data/libraries/madeleine_service.rb +14 -15
  82. data/libraries/rdocsupport.rb +155 -155
  83. data/libraries/redcloth_for_tex.rb +869 -869
  84. data/libraries/redcloth_for_tex_test.rb +40 -40
  85. data/libraries/view_helper.rb +32 -32
  86. data/libraries/web_controller_server.rb +96 -94
  87. data/pimki.rb +47 -6
  88. metadata +18 -4
data/README CHANGED
@@ -1,13 +1,13 @@
1
- <pre>
2
- What is Instiki?
3
- ================
1
+ ===What is Instiki?
4
2
 
5
- Admitted, it's Yet Another Wiki Clone[1], but with a strong focus
3
+ Admitted, it's YetAnotherWikiClone[http://c2.com/cgi/wiki?WikiWikiClones], but with a strong focus
6
4
  on simplicity of installation and running:
7
5
 
8
6
  Step 1. Download
9
- Step 2. Run "instiki.rb"
10
- Step 3. *Chuckle*... "There's no step three!" (TM)
7
+
8
+ Step 2. Run "instiki"
9
+
10
+ Step 3. Chuckle... "There's no step three!" (TM)
11
11
 
12
12
  You're now running a perfectly suitable wiki on port 2500
13
13
  that'll present you with one-step setup, followed by a textarea for the home page
@@ -18,7 +18,7 @@ using a wiki. It's so simple to get running that you'll find yourself
18
18
  using it for anything -- taking notes, brainstorming, organizing a
19
19
  gathering.
20
20
 
21
- Features:
21
+ ===Features:
22
22
  * Regular expression search: Find deep stuff really fast
23
23
  * Revisions: Follow the changes on every page from birth. Rollback to an earlier rev
24
24
  * Export to HTML or markup in a zip: Take the entire wiki with you home or for reference
@@ -27,132 +27,146 @@ Features:
27
27
  * Password-protected webs: Keep it private
28
28
  * Authors: Each revision is associated with an author, so you can see who changed what
29
29
  * Reference tracker: Which other pages are pointing to the current?
30
- * Speed: Using Madelein for persistence (all pages are in memory)
31
- * Three markup choices: Textile (default / RedCloth), Markdown (BlueCloth), and RDoc
32
- * Embedded webserver: Through WEBrick
30
+ * Speed: Using Madelein[http://madeleine.sourceforge.net] for persistence (all pages are in memory)
31
+ * Three markup choices: Textile[http://www.textism.com/tools/textile]
32
+ (default / RedCloth[http://www.whytheluckystiff.net/ruby/redcloth]),
33
+ Markdown (BlueCloth[http://bluecloth.rubyforge.org]), and RDoc[http://rdoc.sourceforge.net/doc]
34
+ * Embedded webserver: Through WEBrick[http://www.webrick.org]
33
35
  * Internationalization: Wiki words in any latin, greek, cyrillian, or armenian characters
34
36
  * Color diffs: Track changes through revisions
35
37
 
36
- Missing:
38
+ ===Missing:
37
39
  * File attachments
38
40
 
39
- Command-line options:
40
- Run "ruby instiki.rb --help"
41
-
42
- History:
43
- * 0.9.2: Changed rollback link to be powered by javascript so it's not trigged by search engines
44
- Changed to use inline style on published pages
45
- Fixed "forward in time" on the last revision before current page
46
- * 0.9.1: Added performance improvements for updating existing pages
47
- Fixed IP logging and RSS feeds behind proxies [With help from Guan Yang]
48
- Fixed default storage directory (borked running on Windows) [Spotted by Curt Hibbs]
49
- * 0.9.0: Added aliased links such as [[HomePage|that nice home page]] [Mark Reid]
50
- Added include other page content with [[!include TableOfContents]] [Mark Reid]
51
- Added delete orphan pages from the Edit Web screen [by inspiration from Simon Arnaud]
52
- Added logging of IP address for authors (who's behind the rollback wars)
53
- Added Categories pages through backlinks (use "categories: news, instiki" on start of line) [Mark Reid]
54
- Added option to use bracket-style wiki links only (and hence ban WikiWords)
55
- Added command-line option to specify different storage path
56
- Added print view without navigation
57
- Added character and page (2275 characters including spaces) counter (important for student papers)
58
- Off by default, activate it on the Edit Web screen
59
- Added LaTeX/PDF integration on Textile installations with pdflatex installed on system (EXPERIMENTAL)
60
- Use the home page as a table of contents with a unordered list to control sections
61
- Added limit of 15 to the number of pages included in RSS feed
62
- Moved static parts of stylesheet to separate file [Lau T�rnskov]
63
- Fixed better semantics for revision movement [Ryan Singer]
64
- Fixed color diffs to work much better [Xen/Mertz/Atkins]
65
- Fixed performance problems for All Pages list [Dennis Mertz]
66
- Fixed lots of rendering bugs [Mark Reid]
67
- Upgraded to RedCloth 2.0.11 [integrating the fine work of Dennis Mertz]
68
- * 0.8.9: Added color diffs to see changes between revisions [Bill Atkins]
69
- They're aren't quite perfect yet as new paragraphs split the <ins> tags (hence 0.8.9, not 0.9.0)
70
- Added redirect to edit if content of page generates an error
71
- (so the page doesn't become unusable on bugs in the markup engines)
72
- Fixed update Web with different address bug [Denis Metz]
73
- Fixed a bunch of wiki word rendering issues by doing wiki word detection and replacment at once
74
- Upgraded to BlueCloth 0.0.3b (should fix loads of problems on Markdown wikis)
75
- * 0.8.5: Instiki can now serve as a CMS by running a password-protected web with a published front
76
- Added version check at startup (Instiki needs Ruby 1.8.1)
77
- * 0.8.1: Actually included RedCloth 2.0.7 in the release
78
- * 0.8.0: NOTE: Single-web wikis created in versions prior to 0.8.0 have "instiki" as their system password
79
- Accepts wiki words in bracket style. Ex: [[wiki word]], [[c]], [[We could'nt have done it!]]
80
- Accepts camel-case wiki words in all latin, greek, cyrillian, and armenian unicode characters
81
- Many thanks to Guan Yang for building the higher- and lower-case lookup tables
82
- And thanks to Simon Arnaud for the initial patch that got the work started
83
- Changed charset to UTF-8
84
- Cut down on command-line options and replaced them with an per-web config screen
85
- Added option to extend the stylesheet on a per-web basis to tweak the look in details
86
- Added simple color options for variety
87
- Added option to add/remove password protection on each web
88
- Added the wiki name of the author locking a given page (instead of just "someone")
89
- Removed single/multi-web distinction -- all Instikis are now multi-web
90
- Load libraries from an unshifted load path, so that old installed libraries doesn't clash [Emiel van de Laar]
91
- Keeps the author cookie forever, so you don't have to enter your name again and again
92
- Fixed XHTML so it validates [Bruce D'Arcus]
93
- Authors are no longer listed under orphan pages
94
- Added export to markup (great for backups, potentially for switching wiki engine)
95
- Don't link wiki words that proceeds from either /, = or ?
96
- (http://c2.com/cgi/wiki?WikiWikiClones, /show/HomePage, cgi.pl?show=WikiWord without escaping)
97
- Accessing an unexisting page redirects to a different url (/new/PageName)
98
- Increased snapshot time to just once a day (cuts down on disk storage requirements)
99
- Made RDoc support work better with 1.8.1 [Mauricio Fern�ndez]
100
- Added convinient redirect from /wiki/ to /wiki/show/HomePage
101
- Fixed BlueCloth bug with backticks at start of line
102
- Updated to RedCloth 2.0.7 (and linked to the new Textile reference)
103
- * 0.7.0: Added Markdown (BlueCloth) and RDoc [Mauricio Fern�ndez] as command-line markup choices
104
- Added wanted and orphan page lists to All pages (only show up if there's actually orphan or wanted pages)
105
- Added ISO-8859-1 as XML encoding in RSS feeds (makes FeedReader among others happy for special entities)
106
- Added proper links in the RSS feed (but the body links are still relative, which NNW and others doesn't grok)
107
- Added access keys: E => Edit, H => HomePage, A => All Pages, U => Recently Revised, X => Export
108
- Added password-login through URL (so you can subscribe to feed on a protected web)
109
- Added web passwords to the feed links for protected webs, so they work without manual login
110
- Added the web name in small letters above all pages within a web
111
- Polished authors and recently revised
112
- Updated to RedCloth 2.0.6
113
- Changed content type for RSS feeds to text/xml (makes Mozilla Aggreg8 happy)
114
- Changed searching to be case insensitive
115
- Changed HomePage to display the name of the web instead
116
- Changed exported HTML pages to be valid XHTML (which can be preprocessed by XSLT)
117
- Fixed broken recently revised
118
- * 0.6.0: Fixed Windows compatibility [Florian]
119
- Fixed bug that would prevent Madeleine from taking snapshots in Daemon mode
120
- Added export entire web as HTML in a zip file
121
- Added RSS feeds
122
- Added proper getops support for the growing number of options [Florian]
123
- Added safe mode that forbids style options in RedCloth [Florian]
124
- Updated RedCloth to 2.0.5
125
- * 0.5.0: NOTE: 0.5.0 is NOT compatible with databases from earlier versions
126
- Added revisions
127
- Added multiple webs
128
- Added password protection for webs on multi-web setups
129
- Added the notion of authors (that are saved in a cookie)
130
- Added command-line option for not running as a Daemon on Unix
131
- * 0.3.1: Added option to escape wiki words with \
132
- * 0.3.0: Brought all files into common style (including Textile help on the edit page)
133
- Added page locking (if someone already is editing a page there's a warning)
134
- Added daemon abilities on Unix (keep Instiki running after you close the terminal)
135
- Made port 2500 the default port, so Instiki can be launched by dobbelt-click
136
- Added Textile cache to speed-up rendering of large pages
137
- Made WikiWords look like "Wiki Words"
138
- Updated RedCloth to 2.0.4
139
- * 0.2.5: Upgraded to RedCloth 2.0.2 and Madeleine 0.6.1, which means the
140
- Windows problems are gone. Also fixed a problem with wikiwords
141
- that used part of other wikiwords.
142
- * 0.2.0: First public release
143
-
144
- Download latest from:
145
- <a href="http://rubyforge.org/project/showfiles.php?group_id=186">http://rubyforge.org/project/showfiles.php?group_id=186</a>
146
-
147
- Visit the official Instiki wiki:
148
- http://www.instiki.org/
149
-
150
- License is the same as Ruby's
151
-
152
- [1] <a href="http://c2.com/cgi/wiki?WikiWikiClones">http://c2.com/cgi/wiki?WikiWikiClones</a>
153
- [2] Textile Syntax: <a href="http://www.textism.com/tools/textile/">http://www.textism.com/tools/textile/</a>
154
- --
155
- David Heinemeier Hansson,
156
- david@loudthinking.com
157
- http://www.loudthinking.com/
158
- </pre>
41
+ ===Install from gem:
42
+ * Install rubygems
43
+ * Run "gem install instiki"
44
+ * Change to a directory where you want Instiki to keep its data files (for example, ~/instiki/)
45
+ * Run "instiki" - this will create a "storage" directory (for example, ~/instiki/storage), and start a new Wiki service
46
+
47
+ Make sure that you always launch Instiki from the same working directory, or specify the storage directory in runtime parameters, such as:
48
+ instiki --storage ~/instiki/storage
49
+
50
+ ===Command-line options:
51
+ * Run "instiki --help"
52
+
53
+ ===History:
54
+ * 0.9.2: Rollback takes the user to an edit form. The form has to be submitted for the change to take place.
55
+ Changed to use inline style on published pages
56
+ Fixed "forward in time" on the last revision before current page
57
+ Instiki won't log bogus error messages when creating a new Wiki.
58
+ Fixed deprecation warning for Object.id (introduced in Ruby 1.8.2)
59
+ Madeleine upgraded to 0.7.1
60
+ Madeleine snapshots are compressed
61
+ Packaged as a gem
62
+ * 0.9.1: Added performance improvements for updating existing pages
63
+ Fixed IP logging and RSS feeds behind proxies [With help from Guan Yang]
64
+ Fixed default storage directory (borked running on Windows) [Spotted by Curt Hibbs]
65
+ * 0.9.0: Added aliased links such as [[HomePage|that nice home page]] [Mark Reid]
66
+ Added include other page content with [[!include TableOfContents]] [Mark Reid]
67
+ Added delete orphan pages from the Edit Web screen [by inspiration from Simon Arnaud]
68
+ Added logging of IP address for authors (who's behind the rollback wars)
69
+ Added Categories pages through backlinks (use "categories: news, instiki" on start of line) [Mark Reid]
70
+ Added option to use bracket-style wiki links only (and hence ban WikiWords)
71
+ Added command-line option to specify different storage path
72
+ Added print view without navigation
73
+ Added character and page (2275 characters including spaces) counter (important for student papers)
74
+ Off by default, activate it on the Edit Web screen
75
+ Added LaTeX/PDF integration on Textile installations with pdflatex installed on system (EXPERIMENTAL)
76
+ Use the home page as a table of contents with a unordered list to control sections
77
+ Added limit of 15 to the number of pages included in RSS feed
78
+ Moved static parts of stylesheet to separate file [Lau T�rnskov]
79
+ Fixed better semantics for revision movement [Ryan Singer]
80
+ Fixed color diffs to work much better [Xen/Mertz/Atkins]
81
+ Fixed performance problems for All Pages list [Dennis Mertz]
82
+ Fixed lots of rendering bugs [Mark Reid]
83
+ Upgraded to RedCloth 2.0.11 [integrating the fine work of Dennis Mertz]
84
+ * 0.8.9: Added color diffs to see changes between revisions [Bill Atkins]
85
+ They're aren't quite perfect yet as new paragraphs split the <ins> tags (hence 0.8.9, not 0.9.0)
86
+ Added redirect to edit if content of page generates an error
87
+ (so the page doesn't become unusable on bugs in the markup engines)
88
+ Fixed update Web with different address bug [Denis Metz]
89
+ Fixed a bunch of wiki word rendering issues by doing wiki word detection and replacment at once
90
+ Upgraded to BlueCloth 0.0.3b (should fix loads of problems on Markdown wikis)
91
+ * 0.8.5: Instiki can now serve as a CMS by running a password-protected web with a published front
92
+ Added version check at startup (Instiki needs Ruby 1.8.1)
93
+ * 0.8.1: Actually included RedCloth 2.0.7 in the release
94
+ * 0.8.0: NOTE: Single-web wikis created in versions prior to 0.8.0 have "instiki" as their system password
95
+ Accepts wiki words in bracket style. Ex: [[wiki word]], [[c]], [[We could'nt have done it!]]
96
+ Accepts camel-case wiki words in all latin, greek, cyrillian, and armenian unicode characters
97
+ Many thanks to Guan Yang for building the higher- and lower-case lookup tables
98
+ And thanks to Simon Arnaud for the initial patch that got the work started
99
+ Changed charset to UTF-8
100
+ Cut down on command-line options and replaced them with an per-web config screen
101
+ Added option to extend the stylesheet on a per-web basis to tweak the look in details
102
+ Added simple color options for variety
103
+ Added option to add/remove password protection on each web
104
+ Added the wiki name of the author locking a given page (instead of just "someone")
105
+ Removed single/multi-web distinction -- all Instikis are now multi-web
106
+ Load libraries from an unshifted load path, so that old installed libraries doesn't clash [Emiel van de Laar]
107
+ Keeps the author cookie forever, so you don't have to enter your name again and again
108
+ Fixed XHTML so it validates [Bruce D'Arcus]
109
+ Authors are no longer listed under orphan pages
110
+ Added export to markup (great for backups, potentially for switching wiki engine)
111
+ Don't link wiki words that proceeds from either /, = or ?
112
+ (http://c2.com/cgi/wiki?WikiWikiClones, /show/HomePage, cgi.pl?show=WikiWord without escaping)
113
+ Accessing an unexisting page redirects to a different url (/new/PageName)
114
+ Increased snapshot time to just once a day (cuts down on disk storage requirements)
115
+ Made RDoc support work better with 1.8.1 [Mauricio Fern�ndez]
116
+ Added convinient redirect from /wiki/ to /wiki/show/HomePage
117
+ Fixed BlueCloth bug with backticks at start of line
118
+ Updated to RedCloth 2.0.7 (and linked to the new Textile reference)
119
+ * 0.7.0: Added Markdown (BlueCloth) and RDoc [Mauricio Fern�ndez] as command-line markup choices
120
+ Added wanted and orphan page lists to All pages (only show up if there's actually orphan or wanted pages)
121
+ Added ISO-8859-1 as XML encoding in RSS feeds (makes FeedReader among others happy for special entities)
122
+ Added proper links in the RSS feed (but the body links are still relative, which NNW and others doesn't grok)
123
+ Added access keys: E => Edit, H => HomePage, A => All Pages, U => Recently Revised, X => Export
124
+ Added password-login through URL (so you can subscribe to feed on a protected web)
125
+ Added web passwords to the feed links for protected webs, so they work without manual login
126
+ Added the web name in small letters above all pages within a web
127
+ Polished authors and recently revised
128
+ Updated to RedCloth 2.0.6
129
+ Changed content type for RSS feeds to text/xml (makes Mozilla Aggreg8 happy)
130
+ Changed searching to be case insensitive
131
+ Changed HomePage to display the name of the web instead
132
+ Changed exported HTML pages to be valid XHTML (which can be preprocessed by XSLT)
133
+ Fixed broken recently revised
134
+ * 0.6.0: Fixed Windows compatibility [Florian]
135
+ Fixed bug that would prevent Madeleine from taking snapshots in Daemon mode
136
+ Added export entire web as HTML in a zip file
137
+ Added RSS feeds
138
+ Added proper getops support for the growing number of options [Florian]
139
+ Added safe mode that forbids style options in RedCloth [Florian]
140
+ Updated RedCloth to 2.0.5
141
+ * 0.5.0: NOTE: 0.5.0 is NOT compatible with databases from earlier versions
142
+ Added revisions
143
+ Added multiple webs
144
+ Added password protection for webs on multi-web setups
145
+ Added the notion of authors (that are saved in a cookie)
146
+ Added command-line option for not running as a Daemon on Unix
147
+ * 0.3.1: Added option to escape wiki words with \
148
+ * 0.3.0: Brought all files into common style (including Textile help on the edit page)
149
+ Added page locking (if someone already is editing a page there's a warning)
150
+ Added daemon abilities on Unix (keep Instiki running after you close the terminal)
151
+ Made port 2500 the default port, so Instiki can be launched by dobbelt-click
152
+ Added Textile cache to speed-up rendering of large pages
153
+ Made WikiWords look like "Wiki Words"
154
+ Updated RedCloth to 2.0.4
155
+ * 0.2.5: Upgraded to RedCloth 2.0.2 and Madeleine 0.6.1, which means the
156
+ Windows problems are gone. Also fixed a problem with wikiwords
157
+ that used part of other wikiwords.
158
+ * 0.2.0: First public release
159
+
160
+ ===Download latest from:
161
+ * http://rubyforge.org/project/showfiles.php?group_id=186
162
+
163
+ ===Visit the official Instiki wiki:
164
+ * http://www.instiki.org
165
+
166
+ ===License:
167
+ * same as Ruby's
168
+
169
+ ---
170
+ Author:: David Heinemeier Hansson
171
+ Email:: david@loudthinking.com
172
+ Weblog:: http://www.loudthinking.com
@@ -52,20 +52,30 @@ Pimki added features:
52
52
  Moved to bottom of Home Page.
53
53
  * Minor stylesheet tweaks.
54
54
 
55
- Missing:
55
+ ToDo:
56
56
 
57
- * Expand todo with more task types?
58
- * Expand Search
57
+ * Expand todo with @Context
58
+ * Advanced Search
59
+ * Advanced Search options (not just regexp, case sensitivity etc)
59
60
  * Highlight match on individual page when clicked form search results
60
- * Advanced Search (not just regexp, case sensitivity)?
61
61
  * Editable left-side menu options: by search results? by author?
62
- * Bliki entries revision diff.
63
62
 
64
63
 
65
64
  Command-line options:
66
65
  Run "ruby pimki.rb --help"
67
66
 
68
67
  History:
68
+ 1.4.092 New features release
69
+ - Added a major/minor edit override for the default 'continous edit' when
70
+ revising a page.
71
+ - MarkDown can now be through RedCloth 3.0.0 (experimental) or BlueCloth.
72
+ - Integrated Instiki release 0.9.2 features and bug fixes.
73
+ - Todo@Context
74
+ - Edit page on double click (based on Mark Reid's patch to Instiki)
75
+ - Possibility to require edit password for each edit
76
+ - Persist user changes to free-wiki menu content
77
+ - Numerous bug fixes.
78
+
69
79
  1.3.092 New features and bug fixes release
70
80
  - Updated to RedCloth v3.0.0.
71
81
  - Fixed problem with incorrect handling of some complex link formats and
@@ -1,6 +1,8 @@
1
1
  require "cgi"
2
2
  require "redcloth_for_tex"
3
3
 
4
+ RenderedTodo = Struct.new( :text, :context, :due_date )
5
+
4
6
  class WikiController < ActionControllerServlet
5
7
  EXPORT_DIRECTORY = WikiService.storage_path unless const_defined?("EXPORT_DIRECTORY")
6
8
 
@@ -112,17 +114,22 @@ class WikiController < ActionControllerServlet
112
114
  @pages_by_name = @pages_in_category.by_name
113
115
  @page_names_that_are_wanted = @pages_in_category.wanted_pages
114
116
  @pages_that_are_orphaned = @pages_in_category.orphaned_pages
115
- case @req.query['Action']
116
- when 'Delete' # Handle page deletion
117
- wiki.delete_page(web_address, @req.query['sel_page_name'])
118
- redirect_action "list/"
119
-
120
- when 'Create' # Handle page creation
121
- redirect_show @req.query['newpage']
122
117
 
123
- when 'Rename' # Handle page rename
124
- wiki.rename_page(web_address, @req.query['sel_page_name'], @req.query['newpage'])
125
- redirect_action "list/"
118
+ if @req.query['Action']
119
+ redirect_action 'list/' if web.check_pass_on_edit and not authenticate
120
+
121
+ case @req.query['Action']
122
+ when 'Delete' # Handle page deletion
123
+ wiki.delete_page(web_address, @req.query['sel_page_name'])
124
+ redirect_action "list/"
125
+
126
+ when 'Create' # Handle page creation
127
+ redirect_show @req.query['newpage']
128
+
129
+ when 'Rename' # Handle page rename
130
+ wiki.rename_page(web_address, @req.query['sel_page_name'], @req.query['newpage'])
131
+ redirect_action "list/"
132
+ end
126
133
  end
127
134
 
128
135
  end
@@ -160,9 +167,16 @@ class WikiController < ActionControllerServlet
160
167
  send_export(file_name, file_path)
161
168
  end
162
169
 
170
+ def edit_web #{{{
171
+ parse_category
172
+ set_mm_options
173
+ end #}}}
174
+
163
175
  def update_web
164
176
  redirect_show("HomePage") unless wiki.authenticate(@params["system_password"])
165
177
 
178
+ set_mm_options
179
+
166
180
  wiki.update_web(
167
181
  web.address, @params["address"], @params["name"],
168
182
  @params["markup"].intern,
@@ -174,7 +188,10 @@ class WikiController < ActionControllerServlet
174
188
  @params["count_pages"] ? true : false,
175
189
  @params['mind_map_size'],
176
190
  @params['symbols_map'],
177
- @params['links_map']
191
+ @params['links_map'],
192
+ @params['enable_dclick_edit'],
193
+ @params['check_pass_on_edit'] == 'each_edit',
194
+ @prog, @graph_type, @missing, @show_authors, @show_leaves, @selected_categories
178
195
  )
179
196
 
180
197
  redirect_show("HomePage", @params["address"])
@@ -189,29 +206,85 @@ class WikiController < ActionControllerServlet
189
206
  end
190
207
  end
191
208
 
209
+ FAR_FUTURE = Date.new(4000,1,1).freeze
210
+ TODO_RE = %r{<todo-tag context='(.*?)' due_date='(.*?)'><span class="todo"><strong>TODO(?:.*)?:</strong> (.*?)</span></todo-tag>}
211
+
192
212
  def todo #{{{
193
213
  parse_category
194
214
  set_menu_pages
195
- @pages_by_name = @pages_in_category.by_name
196
- @todo_items = Hash.new { Array.new }
197
- @bliki_todo_items = Hash.new { Array.new }
198
- @pages_by_name.each do |page|
199
- if page.content =~ Todo.pattern
215
+
216
+ @context = @params['context']
217
+ @sort_order = @params['sort_order']
218
+
219
+ clear_render_cache # hack to make sure we don't have old-style rendered todos.
220
+ @todo_items = analyse_rendered_todo_items @pages_in_category.by_name
221
+ @bliki_todo_items = analyse_rendered_todo_items web.bliki.values
222
+
223
+ @context_links = @todo_items.clone.update(@bliki_todo_items).map { |page, items|
224
+ # 'items' contain the full 'todo' info
225
+ items.map { |item| item.context }
226
+ }.flatten.compact.uniq.reject { |c| c.nil? || c.empty? }.map { |context|
227
+ @context == context ?
228
+ "[<span class='selected'>#{context}</span>]" :
229
+ "<a href='?context=#{context}#{"&sort_order=#{@sort_order}" if @sort_order}'>#{context}</a>"
230
+ }
231
+
232
+ @todo_items = sort_and_filter_todo_items @todo_items, @sort_order, @context
233
+ @bliki_todo_items = sort_and_filter_todo_items @bliki_todo_items, @sort_order, @context
234
+
235
+ end #}}}
236
+
237
+ def analyse_rendered_todo_items pages
238
+ items = Hash.new { Array.new }
239
+ pages.each do |page|
240
+ if page.has_todos?
200
241
  # Page has todo items. Get the rendered version (marked-up and with links):
242
+ # I specifically don't use the todo chunkss because I want the fully marked-up
243
+ # text of the item.
201
244
  content = page.revisions.last.display_content
202
- @todo_items[page] = content.scan /<span class="todo"><strong>TODO:<\/strong> (.*?)<\/span>/
245
+ items[page] = content.scan(TODO_RE).map { |match|
246
+ RenderedTodo.new match[2], (match[0].empty? ? [] : match[0].split(',') ), (Date.parse(match[1]) rescue FAR_FUTURE)
247
+ }
203
248
  end
204
249
  end
205
- @todo_items = @todo_items.sort_by { |page, items| page.name }
206
- web.bliki.each do |pname, entry|
207
- if entry.content =~ Todo.pattern
208
- # Entry has todo items. Get the rendered version (marked-up and with links):
209
- content = entry.revisions.last.display_content
210
- @bliki_todo_items[entry] = content.scan /<span class="todo"><strong>TODO:<\/strong> (.*?)<\/span>/
211
- end
250
+ items
251
+ end
252
+
253
+ def sort_and_filter_todo_items items, sort_order, context
254
+ case sort_order
255
+ when 'due_date'
256
+ result = items.map { |page, todos|
257
+ # sort the to items themselves
258
+ [page, todos.sort_by { |i| i.due_date } ]
259
+ }.sort_by { |page, todos|
260
+ # sort the pages by the one with the most urgent todo
261
+ todos.map{ |i| i.due_date }.min
262
+ }
263
+
264
+ else # default = sort by page name
265
+ result = items.sort_by { |page, items| page.name }
266
+
212
267
  end
213
- @bliki_todo_items = @bliki_todo_items.sort_by { |entry, items| entry.name }
214
- end #}}}
268
+
269
+ if context
270
+ # filter the items to those that are in context
271
+ result = result.map { |page, items|
272
+ [ page, items.select { |item| item.context.include? context } ]
273
+ }.select { |page, items| not items.empty? }
274
+ end
275
+ result
276
+ end
277
+
278
+ def get_todo_display_style due_date
279
+ # default is the muted 'darkred', to prevent to many bright red
280
+ # items on one page: (See also chunks/todo.rb)
281
+ (due_date <=> Date.today) > -1 ? "todoFuture" : "todo"
282
+ end
283
+
284
+ def clear_render_cache do_redirect=false
285
+ web.refresh_revisions
286
+ redirect_show 'HomePage' if do_redirect
287
+ end
215
288
 
216
289
  def set_menu_pages #{{{
217
290
  parse_category
@@ -221,7 +294,7 @@ class WikiController < ActionControllerServlet
221
294
  when 'recent' then @all_pages.by_last_visited
222
295
  when 'viewed' then @all_pages.by_most_viewed
223
296
  when 'revised' then @all_pages.by_revision
224
- when 'user' then @menu_content = web.rendered_menu; nil
297
+ when 'user' then @menu_content = web.menu_content.revisions.last.display_content; nil
225
298
  when 'category' then web.select { |page| page.in_category?(web.menu_category) }
226
299
  when 'linkers'
227
300
  web.select { |page|
@@ -250,32 +323,47 @@ class WikiController < ActionControllerServlet
250
323
  @authors = web.authors
251
324
  end #}}}
252
325
 
253
- require 'pp'
254
326
  def mind #{{{
255
327
  parse_category
256
328
  set_menu_pages
257
-
258
- @prog = @req.query['draw_type'] || 'neato'
259
- @graph_type = @req.query['graph_type'] || 'normal'
260
- missing = @pages_in_category.wanted_pages if @req.query['missing']
261
- show_authors = !@req.query.empty? && @req.query['show_authors'] == 'on'
262
- show_leaves = @req.query.empty? || @req.query['show_leaves'] == 'on'
263
-
264
- # TODO: fix handling of multiple-select for whole application
265
- @selected_categories = @req.body.split('&').map { |pair|
266
- pair.split('=') }.select { |k,v|
267
- k == 'selected_categs' }.map { |k,v| v } if @req.body
268
- @selected_categories ||= []
269
- @selected_categories = [] if @selected_categories.include? 'all'
329
+ set_mm_options
270
330
 
271
331
  @pngFile = @mapFile = nil
272
332
  case @graph_type
273
- when 'normal' then @pngFile, @mapFile = web.create_mind_map(@prog, missing,
274
- show_authors, show_leaves, @selected_categories)
275
- when 'author' then @pngFile, @mapFile = web.create_author_graph(@prog,
276
- @selected_categories)
277
- when 'category' then @pngFile, @mapFile = web.create_category_graph(@prog,
278
- show_authors, @selected_categories)
333
+ when 'normal'
334
+ @pngFile, @mapFile = web.create_mind_map(@prog, @missing,
335
+ @show_authors, @show_leaves, @selected_categories)
336
+
337
+ when 'author'
338
+ @pngFile, @mapFile = web.create_author_graph(@prog, @selected_categories)
339
+
340
+ when 'category'
341
+ @pngFile, @mapFile = web.create_category_graph(@prog,
342
+ @show_authors, @selected_categories)
343
+ end
344
+ end #}}}
345
+
346
+ def set_mm_options #{{{
347
+ if @req.query.empty?
348
+ @prog = web.mm_prog
349
+ @graph_type = web.mm_graph_type
350
+ @missing = @pages_in_category.wanted_pages if web.mm_show_missing
351
+ @show_authors = web.mm_show_authors
352
+ @show_leaves = web.mm_show_leaves
353
+ @selected_categories = web.mm_selected_categories
354
+ else
355
+ @prog = @req.query['draw_type'] || 'neato'
356
+ @graph_type = @req.query['graph_type'] || 'normal'
357
+ @missing = @pages_in_category.wanted_pages if @req.query['missing']
358
+ @show_authors = @req.query['show_authors'] == 'on'
359
+ @show_leaves = @req.query.empty? || @req.query['show_leaves'] == 'on'
360
+
361
+ # TODO: fix handling of multiple-select for whole application
362
+ @selected_categories = @req.body.split('&').map { |pair|
363
+ pair.split('=') }.select { |k,v|
364
+ k == 'selected_categs' }.map { |k,v| v } if @req.body
365
+ @selected_categories ||= []
366
+ @selected_categories = [] if @selected_categories.include? 'all'
279
367
  end
280
368
  end #}}}
281
369
 
@@ -293,17 +381,18 @@ require 'pp'
293
381
  type = @req.query['type']
294
382
  content = @req.query['content']
295
383
  category = @req.query['category']
384
+ author = @req.query['author']
296
385
 
297
386
  limit = @req.query['limit'].to_i rescue nil
298
387
  limit = 20 unless limit
299
388
  limit -= 1 if limit >= 0
300
389
 
301
390
  # need to go through the WikiService to persist the command:
302
- wiki.save_menu_pref web_address, type, limit, content, category
391
+ wiki.save_menu_pref(web_address, type, limit, content, category, Author.new(author, remote_ip))
303
392
  end
304
393
 
394
+ # redirect to the most recently viewed page, or the home page.
305
395
  if web_address
306
- # redirect to the most recently viewed page, or the home page.
307
396
  pname = begin
308
397
  web.select{ true }.by_last_visited.first.name
309
398
  rescue
@@ -374,6 +463,7 @@ require 'pp'
374
463
  end
375
464
 
376
465
  def new
466
+ redirect_show("HomePage") if web.check_pass_on_edit and not authenticate
377
467
  @page_name, @author = page_name, default_author
378
468
  end
379
469
 
@@ -396,10 +486,15 @@ require 'pp'
396
486
  end
397
487
 
398
488
  def save
489
+ if web.check_pass_on_edit and not authenticate
490
+ wiki.read_page(web_address, page_name).unlock if web.pages[page_name]
491
+ redirect_show("HomePage")
492
+ end
493
+
399
494
  if web.pages[page_name]
400
495
  page = wiki.revise_page(
401
496
  web_address, page_name, @params["content"], Time.now,
402
- Author.new(@params["author"], remote_ip)
497
+ Author.new(@params["author"], remote_ip), @params['edit_type']
403
498
  )
404
499
 
405
500
  page.unlock
@@ -420,19 +515,24 @@ require 'pp'
420
515
  end
421
516
 
422
517
  def rollback
518
+ redirect_show("HomePage") if web.check_pass_on_edit and not authenticate
519
+
423
520
  @page = wiki.read_page(web_address, page_name)
424
- wiki.rollback_page(web_address, page_name, @params["rev"].to_i, Time.now, remote_ip)
425
- redirect_show
521
+ @revision = @page.revisions[@params["rev"].to_i]
426
522
  end
427
523
 
428
524
  # Bliki ----------------------------------------------------------------------
429
525
 
430
526
  def bliki_delete
527
+ redirect_bliki if web.check_pass_on_edit and not authenticate
528
+
431
529
  wiki.delete_bliki_entry(web_address, page_name)
432
530
  redirect_bliki
433
531
  end
434
532
 
435
533
  def bliki_edit
534
+ redirect_bliki if web.check_pass_on_edit and not authenticate
535
+
436
536
  @page = wiki.read_bliki_entry(web_address, page_name)
437
537
 
438
538
  if !@page.locked?(Time.now) || @params["break_lock"]
@@ -451,6 +551,8 @@ require 'pp'
451
551
  end
452
552
 
453
553
  def bliki_save
554
+ redirect_bliki if web.check_pass_on_edit and not authenticate
555
+
454
556
  pname = page_name || @params["pagename"]
455
557
  if web.bliki[pname]
456
558
  page = wiki.revise_bliki_entry(web_address, pname, @params["content"], Time.now, @params["author"])
@@ -464,11 +566,15 @@ require 'pp'
464
566
  end
465
567
 
466
568
  def bliki_revision
569
+ parse_category
570
+ set_menu_pages
467
571
  @page = wiki.read_bliki_entry(web_address, page_name || @params['pagename'])
468
572
  @revision = @page.revisions[@params["rev"].to_i] || @page.revisions.last
469
573
  end
470
574
 
471
575
  def rollback_bliki
576
+ redirect_bliki if web.check_pass_on_edit and not authenticate
577
+
472
578
  @page = wiki.read_bliki_entry(web_address, page_name)
473
579
  wiki.rollback_bliki_entry(web_address, page_name, @params["rev"].to_i, Time.now)
474
580
  redirect_bliki
@@ -535,7 +641,8 @@ require 'pp'
535
641
  end
536
642
 
537
643
  def authorized?(web_address)
538
- (web && web.password.nil?) ||
644
+ web.nil? ||
645
+ web.password.nil? ||
539
646
  (read_cookie(web_address) && read_cookie(web_address) == web.password) ||
540
647
  password_check(@params["password"])
541
648
  end
@@ -596,7 +703,13 @@ require 'pp'
596
703
  end
597
704
 
598
705
  def render_markup_help
599
- sub_template "#{web.markup}_help"
706
+ if web
707
+ markup = web.markup
708
+ markup = 'markdown' if markup.to_s =~ /markdown/
709
+ sub_template("#{markup}_help")
710
+ else
711
+ ''
712
+ end
600
713
  end
601
714
 
602
715
  def send_export(file_name, file_path, content_type = "application/zip")