olelo 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. data/.gitignore +10 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +3 -0
  4. data/README.markdown +104 -0
  5. data/Rakefile +92 -0
  6. data/bin/olelo +5 -0
  7. data/config.ru +86 -0
  8. data/config/aspects.rb +256 -0
  9. data/config/config.yml.default +154 -0
  10. data/config/initializers/00-mime_types.rb +29 -0
  11. data/config/initializers/01-slim.rb +2 -0
  12. data/config/interwiki.yml +11 -0
  13. data/doc/AUTHORS +7 -0
  14. data/doc/LICENSE +22 -0
  15. data/lib/olelo.rb +39 -0
  16. data/lib/olelo/application.rb +294 -0
  17. data/lib/olelo/attributes.rb +285 -0
  18. data/lib/olelo/config.rb +88 -0
  19. data/lib/olelo/extensions.rb +252 -0
  20. data/lib/olelo/helper.rb +290 -0
  21. data/lib/olelo/hooks.rb +142 -0
  22. data/lib/olelo/html_safe.rb +29 -0
  23. data/lib/olelo/initializer.rb +76 -0
  24. data/lib/olelo/locale.rb +63 -0
  25. data/lib/olelo/locale.yml +284 -0
  26. data/lib/olelo/menu.rb +101 -0
  27. data/lib/olelo/middleware/blacklist.rb +25 -0
  28. data/lib/olelo/middleware/degrade_mime_type.rb +19 -0
  29. data/lib/olelo/middleware/flash.rb +97 -0
  30. data/lib/olelo/middleware/force_encoding.rb +41 -0
  31. data/lib/olelo/page.rb +266 -0
  32. data/lib/olelo/patch.rb +311 -0
  33. data/lib/olelo/plugin.rb +188 -0
  34. data/lib/olelo/repository.rb +225 -0
  35. data/lib/olelo/routing.rb +223 -0
  36. data/lib/olelo/templates.rb +30 -0
  37. data/lib/olelo/user.rb +132 -0
  38. data/lib/olelo/util.rb +233 -0
  39. data/lib/olelo/version.rb +3 -0
  40. data/lib/olelo/virtualfs.rb +161 -0
  41. data/lib/rack/olelo_patches.rb +33 -0
  42. data/lib/rack/relative_redirect.rb +44 -0
  43. data/lib/rack/static_cache.rb +93 -0
  44. data/lib/yard/addons.rb +1 -0
  45. data/lib/yard/addons/hook_handler.rb +25 -0
  46. data/lib/yard/addons/override_tag.rb +14 -0
  47. data/lib/yard/addons/route_handler.rb +33 -0
  48. data/lib/yard/addons/sanitize_anchor.rb +16 -0
  49. data/olelo.gemspec +31 -0
  50. data/plugins/aspects/changelog.rb +45 -0
  51. data/plugins/aspects/documentbrowser.rb +57 -0
  52. data/plugins/aspects/download.rb +11 -0
  53. data/plugins/aspects/highlight.rb +8 -0
  54. data/plugins/aspects/image.rb +41 -0
  55. data/plugins/aspects/imageinfo.rb +64 -0
  56. data/plugins/aspects/locale.yml +60 -0
  57. data/plugins/aspects/main.rb +199 -0
  58. data/plugins/aspects/pageinfo.rb +37 -0
  59. data/plugins/aspects/source.rb +6 -0
  60. data/plugins/aspects/subpages.rb +44 -0
  61. data/plugins/aspects/text.rb +9 -0
  62. data/plugins/blog/blog.css +1 -0
  63. data/plugins/blog/blog.scss +37 -0
  64. data/plugins/blog/locale.yml +12 -0
  65. data/plugins/blog/main.rb +85 -0
  66. data/plugins/editor/locale.yml +18 -0
  67. data/plugins/editor/markup/main.rb +3 -0
  68. data/plugins/editor/markup/script.js +10 -0
  69. data/plugins/editor/markup/script/00-jquery.textselection.js +267 -0
  70. data/plugins/editor/markup/script/01-olelo.markupeditor.js +116 -0
  71. data/plugins/editor/markup/script/init.js +10 -0
  72. data/plugins/editor/preview.rb +52 -0
  73. data/plugins/editor/recaptcha.rb +56 -0
  74. data/plugins/filters/creole.rb +37 -0
  75. data/plugins/filters/disposition.rb +9 -0
  76. data/plugins/filters/editsection.rb +67 -0
  77. data/plugins/filters/fix_img_tag.rb +16 -0
  78. data/plugins/filters/html_wrapper.rb +12 -0
  79. data/plugins/filters/interwiki.rb +19 -0
  80. data/plugins/filters/link_classifier.rb +26 -0
  81. data/plugins/filters/locale.yml +15 -0
  82. data/plugins/filters/main.rb +202 -0
  83. data/plugins/filters/markdown_nowiki.rb +15 -0
  84. data/plugins/filters/numbering.xsl +93 -0
  85. data/plugins/filters/orgmode.rb +6 -0
  86. data/plugins/filters/rubypants.rb +6 -0
  87. data/plugins/filters/s5/main.rb +32 -0
  88. data/plugins/filters/s5/s5.xsl +118 -0
  89. data/plugins/filters/tilt.rb +17 -0
  90. data/plugins/filters/toc.rb +50 -0
  91. data/plugins/filters/xhtml2latex.xsl +232 -0
  92. data/plugins/filters/xslt.rb +22 -0
  93. data/plugins/gallery/gallery.css +1 -0
  94. data/plugins/gallery/gallery.scss +28 -0
  95. data/plugins/gallery/main.rb +34 -0
  96. data/plugins/misc/fancybox/images/blank.gif +0 -0
  97. data/plugins/misc/fancybox/images/fancy_close.png +0 -0
  98. data/plugins/misc/fancybox/images/fancy_loading.png +0 -0
  99. data/plugins/misc/fancybox/images/fancy_nav_left.png +0 -0
  100. data/plugins/misc/fancybox/images/fancy_nav_right.png +0 -0
  101. data/plugins/misc/fancybox/images/fancy_shadow_e.png +0 -0
  102. data/plugins/misc/fancybox/images/fancy_shadow_n.png +0 -0
  103. data/plugins/misc/fancybox/images/fancy_shadow_ne.png +0 -0
  104. data/plugins/misc/fancybox/images/fancy_shadow_nw.png +0 -0
  105. data/plugins/misc/fancybox/images/fancy_shadow_s.png +0 -0
  106. data/plugins/misc/fancybox/images/fancy_shadow_se.png +0 -0
  107. data/plugins/misc/fancybox/images/fancy_shadow_sw.png +0 -0
  108. data/plugins/misc/fancybox/images/fancy_shadow_w.png +0 -0
  109. data/plugins/misc/fancybox/images/fancy_title_left.png +0 -0
  110. data/plugins/misc/fancybox/images/fancy_title_main.png +0 -0
  111. data/plugins/misc/fancybox/images/fancy_title_over.png +0 -0
  112. data/plugins/misc/fancybox/images/fancy_title_right.png +0 -0
  113. data/plugins/misc/fancybox/images/fancybox-x.png +0 -0
  114. data/plugins/misc/fancybox/images/fancybox-y.png +0 -0
  115. data/plugins/misc/fancybox/images/fancybox.png +0 -0
  116. data/plugins/misc/fancybox/jquery.fancybox.css +1 -0
  117. data/plugins/misc/fancybox/jquery.fancybox.scss +323 -0
  118. data/plugins/misc/fancybox/main.rb +4 -0
  119. data/plugins/misc/fancybox/script.js +37 -0
  120. data/plugins/misc/fancybox/script/00-jquery.mousewheel.js +84 -0
  121. data/plugins/misc/fancybox/script/01-jquery.easing.js +205 -0
  122. data/plugins/misc/fancybox/script/02-jquery.fancybox.js +1156 -0
  123. data/plugins/misc/fancybox/script/init.js +18 -0
  124. data/plugins/misc/system.rb +192 -0
  125. data/plugins/misc/variables.rb +29 -0
  126. data/plugins/misc/webdav.rb +45 -0
  127. data/plugins/repositories/git_grep.rb +69 -0
  128. data/plugins/repositories/gitrb_repository.rb +204 -0
  129. data/plugins/repositories/locale.yml +12 -0
  130. data/plugins/repositories/rugged_repository.rb +454 -0
  131. data/plugins/security/acl.rb +57 -0
  132. data/plugins/security/basic_auth.rb +21 -0
  133. data/plugins/security/locale.yml +21 -0
  134. data/plugins/security/persistent_login.rb +32 -0
  135. data/plugins/security/portal.rb +28 -0
  136. data/plugins/security/private_wiki.rb +24 -0
  137. data/plugins/security/readonly_wiki.rb +25 -0
  138. data/plugins/security/stack.rb +20 -0
  139. data/plugins/security/yamlfile.rb +66 -0
  140. data/plugins/tags/code.rb +6 -0
  141. data/plugins/tags/footnotes.rb +35 -0
  142. data/plugins/tags/gist-embed.css +123 -0
  143. data/plugins/tags/gist.rb +13 -0
  144. data/plugins/tags/html.rb +57 -0
  145. data/plugins/tags/include.rb +20 -0
  146. data/plugins/tags/main.rb +353 -0
  147. data/plugins/tags/math.rb +117 -0
  148. data/plugins/tags/scripting.rb +64 -0
  149. data/plugins/tags/sort.rb +7 -0
  150. data/plugins/tags/tabs.rb +20 -0
  151. data/plugins/treeview/images/collapsed.png +0 -0
  152. data/plugins/treeview/images/expanded.png +0 -0
  153. data/plugins/treeview/images/menu.png +0 -0
  154. data/plugins/treeview/images/tree.png +0 -0
  155. data/plugins/treeview/images/wait.gif +0 -0
  156. data/plugins/treeview/main.rb +16 -0
  157. data/plugins/treeview/script.js +5 -0
  158. data/plugins/treeview/script/00-jquery.treeview.js +164 -0
  159. data/plugins/treeview/script/init.js +25 -0
  160. data/plugins/treeview/treeview.css +1 -0
  161. data/plugins/treeview/treeview.scss +113 -0
  162. data/plugins/utils/assets.rb +74 -0
  163. data/plugins/utils/cache.rb +53 -0
  164. data/plugins/utils/image_magick.rb +34 -0
  165. data/plugins/utils/pygments.css +1 -0
  166. data/plugins/utils/pygments.rb +50 -0
  167. data/plugins/utils/pygments.scss +83 -0
  168. data/plugins/utils/semaphore.rb +50 -0
  169. data/plugins/utils/shell.rb +45 -0
  170. data/plugins/utils/store.rb +315 -0
  171. data/plugins/utils/worker.rb +36 -0
  172. data/plugins/utils/xml.rb +29 -0
  173. data/static/images/favicon.png +0 -0
  174. data/static/script.js +267 -0
  175. data/static/script/00-json2.js +486 -0
  176. data/static/script/01-jstorage.js +217 -0
  177. data/static/script/02-jquery.js +9440 -0
  178. data/static/script/03-jquery.ui.core.js +337 -0
  179. data/static/script/04-jquery.ui.widget.js +502 -0
  180. data/static/script/05-jquery.ui.position.js +517 -0
  181. data/static/script/06-jquery.ui.menu.js +609 -0
  182. data/static/script/07-jquery.ui.autocomplete.js +601 -0
  183. data/static/script/08-olelo.i18n.js +37 -0
  184. data/static/script/09-olelo.unsaved.js +68 -0
  185. data/static/script/10-olelo.historytable.js +40 -0
  186. data/static/script/11-olelo.pagination.js +18 -0
  187. data/static/script/13-olelo.tabwidget.js +57 -0
  188. data/static/script/14-olelo.timeago.js +70 -0
  189. data/static/script/15-olelo.underliner.js +31 -0
  190. data/static/script/16-olelo.ui.combobox.js +32 -0
  191. data/static/script/init.js +48 -0
  192. data/static/themes/atlantis/constants.scss +15 -0
  193. data/static/themes/atlantis/iehacks.scss +38 -0
  194. data/static/themes/atlantis/images/actions/delete.png +0 -0
  195. data/static/themes/atlantis/images/actions/edit.png +0 -0
  196. data/static/themes/atlantis/images/actions/history.png +0 -0
  197. data/static/themes/atlantis/images/actions/home.png +0 -0
  198. data/static/themes/atlantis/images/actions/move.png +0 -0
  199. data/static/themes/atlantis/images/actions/new.png +0 -0
  200. data/static/themes/atlantis/images/actions/page.png +0 -0
  201. data/static/themes/atlantis/images/bg/button.png +0 -0
  202. data/static/themes/atlantis/images/bg/container.png +0 -0
  203. data/static/themes/atlantis/images/bg/content.png +0 -0
  204. data/static/themes/atlantis/images/bg/footer.png +0 -0
  205. data/static/themes/atlantis/images/bg/header.jpg +0 -0
  206. data/static/themes/atlantis/images/bg/header.orig.jpg +0 -0
  207. data/static/themes/atlantis/images/bg/header_gray.jpg +0 -0
  208. data/static/themes/atlantis/images/bug.png +0 -0
  209. data/static/themes/atlantis/images/filetypes/7z.png +0 -0
  210. data/static/themes/atlantis/images/filetypes/_archive.png +0 -0
  211. data/static/themes/atlantis/images/filetypes/_audio.png +0 -0
  212. data/static/themes/atlantis/images/filetypes/_code.png +0 -0
  213. data/static/themes/atlantis/images/filetypes/_linux.png +0 -0
  214. data/static/themes/atlantis/images/filetypes/_picture.png +0 -0
  215. data/static/themes/atlantis/images/filetypes/_video.png +0 -0
  216. data/static/themes/atlantis/images/filetypes/bz2.png +0 -0
  217. data/static/themes/atlantis/images/filetypes/doc.png +0 -0
  218. data/static/themes/atlantis/images/filetypes/flac.png +0 -0
  219. data/static/themes/atlantis/images/filetypes/gz.png +0 -0
  220. data/static/themes/atlantis/images/filetypes/html.png +0 -0
  221. data/static/themes/atlantis/images/filetypes/java.png +0 -0
  222. data/static/themes/atlantis/images/filetypes/jpg.png +0 -0
  223. data/static/themes/atlantis/images/filetypes/midi.png +0 -0
  224. data/static/themes/atlantis/images/filetypes/mp3.png +0 -0
  225. data/static/themes/atlantis/images/filetypes/ogg.png +0 -0
  226. data/static/themes/atlantis/images/filetypes/pdf.png +0 -0
  227. data/static/themes/atlantis/images/filetypes/php.png +0 -0
  228. data/static/themes/atlantis/images/filetypes/png.png +0 -0
  229. data/static/themes/atlantis/images/filetypes/ppt.png +0 -0
  230. data/static/themes/atlantis/images/filetypes/psd.png +0 -0
  231. data/static/themes/atlantis/images/filetypes/rar.png +0 -0
  232. data/static/themes/atlantis/images/filetypes/rb.png +0 -0
  233. data/static/themes/atlantis/images/filetypes/sh.png +0 -0
  234. data/static/themes/atlantis/images/filetypes/tar.png +0 -0
  235. data/static/themes/atlantis/images/filetypes/txt.png +0 -0
  236. data/static/themes/atlantis/images/filetypes/wma.png +0 -0
  237. data/static/themes/atlantis/images/filetypes/xls.png +0 -0
  238. data/static/themes/atlantis/images/filetypes/zip.png +0 -0
  239. data/static/themes/atlantis/images/folder.png +0 -0
  240. data/static/themes/atlantis/images/folder_open.png +0 -0
  241. data/static/themes/atlantis/images/loading.gif +0 -0
  242. data/static/themes/atlantis/images/loading.xcf +0 -0
  243. data/static/themes/atlantis/images/not_found.png +0 -0
  244. data/static/themes/atlantis/images/page.png +0 -0
  245. data/static/themes/atlantis/images/search.png +0 -0
  246. data/static/themes/atlantis/layout.scss +115 -0
  247. data/static/themes/atlantis/menu.scss +99 -0
  248. data/static/themes/atlantis/print.scss +129 -0
  249. data/static/themes/atlantis/screen.scss +495 -0
  250. data/static/themes/atlantis/style.css +3 -0
  251. data/static/themes/lib/autocomplete.scss +39 -0
  252. data/static/themes/lib/headlines.scss +10 -0
  253. data/static/themes/lib/horizontal-list.scss +31 -0
  254. data/static/themes/lib/patch.scss +88 -0
  255. data/static/themes/lib/reset.scss +114 -0
  256. data/static/themes/lib/rounded.scss +46 -0
  257. data/static/themes/lib/shadow.scss +14 -0
  258. data/test/config_test.rb +28 -0
  259. data/test/factory_test.rb +29 -0
  260. data/test/hash_extensions_test.rb +16 -0
  261. data/test/helper.rb +38 -0
  262. data/test/hooks_test.rb +85 -0
  263. data/test/object_extensions_test.rb +20 -0
  264. data/test/page_test.rb +168 -0
  265. data/test/request_test.rb +166 -0
  266. data/test/string_extensions_test.rb +32 -0
  267. data/test/templates_test.rb +39 -0
  268. data/test/util_test.rb +71 -0
  269. data/views/changes.slim +22 -0
  270. data/views/compare.slim +8 -0
  271. data/views/delete.slim +9 -0
  272. data/views/deleted.slim +2 -0
  273. data/views/edit.slim +65 -0
  274. data/views/error.slim +6 -0
  275. data/views/history.slim +20 -0
  276. data/views/layout.slim +38 -0
  277. data/views/login.slim +37 -0
  278. data/views/move.slim +10 -0
  279. data/views/not_found.slim +6 -0
  280. data/views/profile.slim +26 -0
  281. data/views/show.slim +9 -0
  282. metadata +488 -0
@@ -0,0 +1,154 @@
1
+ # config.yml.default
2
+ # Default wiki configuration
3
+ # Copy this file to config.yml if you want to tweak any settings.
4
+ # Do not delete this file!
5
+
6
+ ##################################################
7
+ # Main configuration
8
+
9
+ # Wiki title displayed at the top of the page
10
+ title: 'Ōlelo'
11
+
12
+ # Default locale
13
+ # Examples: en, en_US, de_DE
14
+ locale: 'en_US'
15
+
16
+ # Set this to false to put the wiki to debugging mode.
17
+ # Debugging mode disables caching and enables exception backtraces.
18
+ production: true
19
+
20
+ # Page used for the sidebar. This can be a path.
21
+ sidebar_page: 'Sidebar'
22
+
23
+ # Use a different base directory as root to support installation in user homes
24
+ base_path: '/'
25
+
26
+ # Main cache store. Uncomment this!
27
+ # Available caches: memory, file, memcached, pstore
28
+ #cache_store:
29
+ # type: file
30
+ # file:
31
+ # root: '/home/user/wiki/cache'
32
+ # memcached:
33
+ # prefix: ''
34
+ # server: localhost:11211
35
+ # memory:
36
+ # pstore:
37
+ # file: '/home/user/wiki/cache.pstore'
38
+
39
+ # Default math renderer
40
+ # Available renderers:
41
+ # * mathjax - MathML, recommended, just works, but requires javascript
42
+ # * itex - MathML, needs itex2MML executable on path
43
+ # * ritex - MathML, needs ruby ritex gem
44
+ # * blahteximage - Image, needs blahtex executable on path
45
+ # * blahtexml - MathML, recommended, needs blahtex executable on path
46
+ # * google - Image, only short formulas, uses google charts api
47
+ math_renderer: mathjax
48
+
49
+ # Directory where the blahtex math renderer stores the images.
50
+ # Uncomment this!
51
+ #blahtex_directory: '/home/user/wiki/blahtex'
52
+
53
+ # Selected theme
54
+ theme: atlantis
55
+
56
+ ##################################################
57
+ # Authentication backend configuration
58
+
59
+ authentication:
60
+ # Enable signup
61
+ enable_signup: true
62
+
63
+ # Select a authentication service which is configured below.
64
+ # Currently supported are: yamlfile, portal and stack.
65
+ service: yamlfile
66
+
67
+ # Configure the yamlfile backend.
68
+ # The yaml file backend stores the users in a simple yaml file.
69
+ # Uncomment this!
70
+
71
+ #yamlfile:
72
+ # store: '/home/user/wiki/users.yml'
73
+
74
+ # Configure the portal backend.
75
+ # The portal backend uses a REST-API to access user data.
76
+ # Uncomment this!
77
+
78
+ #portal:
79
+ # url: 'http://portal.test.com/'
80
+
81
+ # Stack backend which accesses multiple backends in the following order.
82
+ stack:
83
+ - yamlfile
84
+ - portal
85
+
86
+ ##################################################
87
+ # Mime detection order
88
+ # Possible values are extension, content/magic and a specific mime type
89
+ # You can configure the wiki default mime type here
90
+ # and select the default wiki text this way.
91
+
92
+ mime:
93
+ - extension
94
+ - content
95
+ # Use creole as last resort.
96
+ # You can configure the wiki default mime type here!
97
+ # Use text/x-creole for Creole Wikitext, text/x-markdown for Markdown,
98
+ # text/x-textile for Textile, text/x-orgmode for Emacs Org Mode
99
+ - text/x-creole
100
+
101
+ mime_suggestions:
102
+ - text/x-creole
103
+ - text/x-mediawiki
104
+ - text/x-markdown
105
+ - text/x-textile
106
+ - text/x-orgmode
107
+
108
+ ##################################################
109
+ # List of disabled plugins by name.
110
+ # You can disable whole plugin directories.
111
+
112
+ disabled_plugins:
113
+ - security/readonly_wiki
114
+ - security/private_wiki
115
+ - editor/recaptcha
116
+
117
+ ##################################################
118
+ # Rack middleware configurations
119
+
120
+ rack:
121
+ # Secret key used to verify session integrity. Use a random string here!
122
+ #session_secret: 'Change the secret! Use random string!'
123
+ # Use the deflater to compress data (Rack::Deflater)
124
+ deflater: true
125
+ # Specify a list of blacklisted ips which cannot post data
126
+ blacklist: []
127
+
128
+ ##################################################
129
+ # Logging configuration
130
+
131
+ log:
132
+ level: INFO
133
+ #file: '/home/user/wiki/log'
134
+
135
+ ##################################################
136
+ # Antispam configuration.
137
+ # Specify recaptcha public/private key
138
+
139
+ recaptcha:
140
+ #public: public key
141
+ #private: private key
142
+
143
+ ##################################################
144
+ # Repository configuration
145
+
146
+ repository:
147
+ # Specify type of repository
148
+ type: git
149
+
150
+ # Configuration git repository type. Uncomment this!
151
+ # Path is to a bare (!) git repository.
152
+ #git:
153
+ # path: '/home/user/wiki/repository'
154
+ # bare: true
@@ -0,0 +1,29 @@
1
+ # Register some mime types
2
+
3
+ MimeMagic.add('application/x-empty', :comment => 'Empty file')
4
+ MimeMagic.add('inode/directory', :comment => 'Directory')
5
+
6
+ MimeMagic.add('text/x-creole',
7
+ :extensions => %w(creole text),
8
+ :parents => 'text/plain',
9
+ :comment => 'Creole Wiki Text File')
10
+
11
+ MimeMagic.add('text/x-mediawiki',
12
+ :extensions => %w(mediawiki mw),
13
+ :parents => 'text/plain',
14
+ :comment => 'MediaWiki Text File')
15
+
16
+ MimeMagic.add('text/x-markdown',
17
+ :extensions => %w(markdown md mdown mkdn mdown),
18
+ :parents => 'text/plain',
19
+ :comment => 'Markdown Text File')
20
+
21
+ MimeMagic.add('text/x-textile',
22
+ :extensions => 'textile',
23
+ :parents => 'text/plain',
24
+ :comment => 'Textile Text File')
25
+
26
+ MimeMagic.add('text/x-orgmode',
27
+ :extensions => 'org',
28
+ :parents => 'text/plain',
29
+ :comment => 'Emacs Orgmode File')
@@ -0,0 +1,2 @@
1
+ Slim::Engine.set_default_options :format => :xhtml,
2
+ :shortcut => {'&' => 'input type', '#' => 'id', '.' => 'class'}
@@ -0,0 +1,11 @@
1
+ w: http://en.wikipedia.org/wiki/
2
+ wikipedia: http://en.wikipedia.org/wiki/
3
+ wikt: http://en.wiktionary.org/wiki/
4
+ wiktionary: http://en.wiktionary.org/wiki/
5
+ n: http://en.wikinews.org/wiki/
6
+ wikinews: http://en.wikinews.org/wiki/
7
+ q: http://en.wikiquote.org/wiki/
8
+ wikiquote: http://en.wikiquote.org/wiki/
9
+ s: http://en.wikisource.org/wiki/
10
+ wikisource: http://en.wikisource.org/wiki/
11
+ wikileaks: http://wikileaks.org/wiki/
data/doc/AUTHORS ADDED
@@ -0,0 +1,7 @@
1
+ Originally by Simon Rozet (http://atonie.org/2008/02/git-wiki)
2
+
3
+ Daniel Mendler - Further development to a complete wiki software
4
+
5
+ Contributors:
6
+ Luca Greco
7
+ Hrvoje
data/doc/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Daniel Mendler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
data/lib/olelo.rb ADDED
@@ -0,0 +1,39 @@
1
+ raise "Your Ruby version is too old (1.9.2 is required)" if RUBY_VERSION < '1.9.2'
2
+
3
+ require 'logger'
4
+ require 'cgi'
5
+ require 'digest/md5'
6
+ require 'digest/sha2'
7
+ require 'open3'
8
+ require 'set'
9
+ require 'yaml'
10
+ require 'mimemagic'
11
+
12
+ begin
13
+ require 'yajl/json_gem'
14
+ rescue LoadError
15
+ require 'json'
16
+ end
17
+
18
+ require 'olelo/html_safe'
19
+ require 'slim'
20
+
21
+ require 'olelo/extensions'
22
+ require 'olelo/util'
23
+ require 'olelo/locale'
24
+ require 'olelo/hooks'
25
+ require 'olelo/config'
26
+ require 'olelo/routing'
27
+ require 'olelo/user'
28
+ require 'olelo/virtualfs'
29
+ require 'olelo/templates'
30
+ require 'olelo/menu'
31
+ require 'olelo/helper'
32
+ require 'olelo/repository'
33
+ require 'olelo/attributes'
34
+ require 'olelo/page'
35
+ require 'olelo/plugin'
36
+ require 'olelo/patch'
37
+ require 'olelo/initializer'
38
+ require 'olelo/application'
39
+ require 'olelo/version'
@@ -0,0 +1,294 @@
1
+ module Olelo
2
+ # Main class of the application
3
+ class Application
4
+ include Util
5
+ include Hooks
6
+ include ErrorHandler
7
+ include Routing
8
+ include ApplicationHelper
9
+
10
+ patterns :path => Page::PATH_PATTERN
11
+ attr_reader :page
12
+ attr_setter :on_error
13
+
14
+ has_around_hooks :request, :routing, :action, :title, :footer, :login_buttons, :edit_buttons
15
+ has_hooks :auto_login, :render, :menu, :head, :script
16
+
17
+ class<< self
18
+ attr_accessor :reserved_paths
19
+ def reserved_path?(path)
20
+ path = '/' + path.cleanpath
21
+ reserved_paths.any? {|pattern| path =~ pattern }
22
+ end
23
+ end
24
+
25
+ def initialize(app = nil)
26
+ @app = app
27
+ end
28
+
29
+ # Executed before each request
30
+ before :routing do
31
+ Olelo.logger.debug env
32
+
33
+ User.current = User.find(session[:olelo_user])
34
+ if !User.current
35
+ invoke_hook(:auto_login)
36
+ User.current ||= User.anonymous(request)
37
+ end
38
+
39
+ response['Content-Type'] = 'application/xhtml+xml;charset=utf-8'
40
+ end
41
+
42
+ # Executed after each request
43
+ after :routing do
44
+ if User.logged_in?
45
+ session[:olelo_user] = User.current.name
46
+ else
47
+ session.delete(:olelo_user)
48
+ end
49
+ User.current = nil
50
+ end
51
+
52
+ hook :menu do |menu|
53
+ if menu.name == :actions && page && !page.new?
54
+ menu.item(:view, :href => build_path(page.path), :accesskey => 'v')
55
+ edit_menu = menu.item(:edit, :href => build_path(page, :action => :edit), :accesskey => 'e')
56
+ edit_menu.item(:new, :href => build_path(page, :action => :new), :accesskey => 'n')
57
+ if !page.root?
58
+ edit_menu.item(:move, :href => build_path(page, :action => :move))
59
+ edit_menu.item(:delete, :href => build_path(page, :action => :delete))
60
+ end
61
+ history_menu = menu.item(:history, :href => build_path(page, :action => :history), :accesskey => 'h')
62
+
63
+ if @menu_versions
64
+ head = !page.head? && (Olelo::Page.find(page.path) rescue nil)
65
+ if page.previous_version || head || page.next_version
66
+ history_menu.item(:older, :href => build_path(page, original_params.merge(:version => page.previous_version)),
67
+ :accesskey => 'o') if page.previous_version
68
+ history_menu.item(:head, :href => build_path(page.path, original_params), :accesskey => 'c') if head
69
+ history_menu.item(:newer, :href => build_path(page, original_params.merge(:version => page.next_version)),
70
+ :accesskey => 'n') if page.next_version
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ # Handle 404s
77
+ error NotFound do |error|
78
+ Olelo.logger.debug(error)
79
+ cache_control :no_cache => true
80
+ halt render(:not_found, :locals => {:error => error})
81
+ end
82
+
83
+ error StandardError do |error|
84
+ if on_error
85
+ Olelo.logger.error error
86
+ (error.try(:messages) || [error.message]).each {|msg| flash.error!(msg) }
87
+ halt render(on_error)
88
+ end
89
+ end
90
+
91
+ # Show wiki error page
92
+ error Exception do |error|
93
+ Olelo.logger.error(error)
94
+ cache_control :no_cache => true
95
+ halt render(:error, :locals => {:error => error})
96
+ end
97
+
98
+ get '/login' do
99
+ render :login
100
+ end
101
+
102
+ post '/login' do
103
+ on_error :login
104
+ User.current = User.authenticate(params[:user], params[:password])
105
+ redirect build_path(session.delete(:olelo_goto))
106
+ end
107
+
108
+ post '/signup' do
109
+ on_error :login
110
+ raise 'Sign-up is disabled' if !Config['authentication.enable_signup']
111
+ User.current = User.create(params[:user], params[:password],
112
+ params[:confirm], params[:email])
113
+ redirect build_path('/')
114
+ end
115
+
116
+ get '/logout' do
117
+ User.current = User.anonymous(request)
118
+ redirect build_path('/')
119
+ end
120
+
121
+ get '/profile' do
122
+ raise 'Anonymous users do not have a profile.' if !User.logged_in?
123
+ render :profile
124
+ end
125
+
126
+ post '/profile' do
127
+ raise 'Anonymous users do not have a profile.' if !User.logged_in?
128
+ on_error :profile
129
+ User.current.modify do |u|
130
+ u.change_password(params[:oldpassword], params[:password], params[:confirm]) if !params[:password].blank?
131
+ u.email = params[:email]
132
+ end
133
+ flash.info! :changes_saved.t
134
+ render :profile
135
+ end
136
+
137
+ get '/changes/:version(/:path)' do
138
+ @page = Page.find!(params[:path])
139
+ @diff = page.diff(nil, params[:version])
140
+ @version = @diff.to
141
+ cache_control :version => @version
142
+ render :changes
143
+ end
144
+
145
+ get '/history(/:path)' do
146
+ per_page = 30
147
+ limit = 90
148
+ @page = Page.find!(params[:path])
149
+ @page_nr = [params[:page].to_i, 1].max
150
+ @history = page.history((@page_nr - 1) * per_page, limit)
151
+ @page_count = @page_nr + @history.length / per_page
152
+ @history = @history[0...per_page]
153
+ cache_control :version => page.version
154
+ render :history
155
+ end
156
+
157
+ get '/move/:path' do
158
+ @page = Page.find!(params[:path])
159
+ render :move
160
+ end
161
+
162
+ get '/delete/:path' do
163
+ @page = Page.find!(params[:path])
164
+ render :delete
165
+ end
166
+
167
+ post '/move/:path' do
168
+ Page.transaction do
169
+ @page = Page.find!(params[:path])
170
+ on_error :move
171
+ destination = params[:destination].cleanpath
172
+ raise :reserved_path.t if self.class.reserved_path?(destination)
173
+ page.move(destination)
174
+ Page.commit(:page_moved.t(:page => page.path, :destination => destination))
175
+ redirect build_path(page.path)
176
+ end
177
+ end
178
+
179
+ get '/compare/:versions(/:path)', :versions => '(?:\w+)\.{2,3}(?:\w+)' do
180
+ @page = Page.find!(params[:path])
181
+ versions = params[:versions].split(/\.{2,3}/)
182
+ @diff = page.diff(versions.first, versions.last)
183
+ render :compare
184
+ end
185
+
186
+ get '/compare(/:path)' do
187
+ versions = params[:versions] || []
188
+ redirect build_path(params[:path], :action => versions.size < 2 ? :history : "compare/#{versions.first}...#{versions.last}")
189
+ end
190
+
191
+ get '/edit(/:path)' do
192
+ @page = Page.find!(params[:path])
193
+ render :edit
194
+ end
195
+
196
+ get '/new(/:path)' do
197
+ @page = Page.new(params[:path])
198
+ flash.error! :reserved_path.t if self.class.reserved_path?(page.path)
199
+ params[:path] = !page.root? && Page.find(page.path) ? page.path + '/' : page.path
200
+ render :edit
201
+ end
202
+
203
+ def post_edit
204
+ raise 'No content' if !params[:content]
205
+ params[:content].gsub!("\r\n", "\n")
206
+ message = :page_edited.t(:page => page.title)
207
+ message << " - #{params[:comment]}" if !params[:comment].blank?
208
+
209
+ page.content = if params[:pos]
210
+ [page.content[0, params[:pos].to_i].to_s,
211
+ params[:content],
212
+ page.content[params[:pos].to_i + params[:len].to_i .. -1]].join
213
+ else
214
+ params[:content]
215
+ end
216
+ redirect build_path(page.path) if @close && !page.modified?
217
+ check do |errors|
218
+ errors << :version_conflict.t if !page.new? && page.version.to_s != params[:version]
219
+ errors << :no_changes.t if !page.modified?
220
+ end
221
+ page.save
222
+
223
+ Page.commit(message)
224
+ params.delete(:comment)
225
+ end
226
+
227
+ def post_upload
228
+ raise 'No file' if !params[:file]
229
+ raise :version_conflict.t if !page.new? && page.version.to_s != params[:version]
230
+ page.content = params[:file][:tempfile]
231
+ page.save
232
+ Page.commit(:page_uploaded.t(:page => page.title))
233
+ end
234
+
235
+ def post_attributes
236
+ page.update_attributes(params)
237
+ redirect build_path(page.path) if @close && !page.modified?
238
+ check do |errors|
239
+ errors << :version_conflict.t if !page.new? && page.version.to_s != params[:version]
240
+ errors << :no_changes.t if !page.modified?
241
+ end
242
+ page.save
243
+ Page.commit(:attributes_edited.t(:page => page.title))
244
+ end
245
+
246
+ def show_page
247
+ @menu_versions = true
248
+ halt render(:show, :locals => {:content => page.try(:content)})
249
+ end
250
+
251
+ get '/version/:version(/:path)|/(:path)', :tail => true do
252
+ begin
253
+ @page = Page.find!(params[:path], params[:version])
254
+ cache_control :version => page.version
255
+ show_page
256
+ rescue NotFound
257
+ redirect build_path(params[:path], :action => :new) if params[:version].blank?
258
+ raise
259
+ end
260
+ end
261
+
262
+ post '/(:path)', :tail => true do
263
+ action, @close = params[:action].to_s.split('-')
264
+ if respond_to? "post_#{action}"
265
+ on_error :edit
266
+ Page.transaction do
267
+ @page = Page.find(params[:path]) || Page.new(params[:path])
268
+ raise :reserved_path.t if self.class.reserved_path?(page.path)
269
+ send("post_#{action}")
270
+ end
271
+ else
272
+ raise 'Invalid action'
273
+ end
274
+
275
+ if @close
276
+ flash.clear
277
+ redirect build_path(page.path)
278
+ else
279
+ flash.info! :changes_saved.t
280
+ render :edit
281
+ end
282
+ end
283
+
284
+ delete '/:path', :tail => true do
285
+ Page.transaction do
286
+ @page = Page.find!(params[:path])
287
+ on_error :delete
288
+ page.delete
289
+ Page.commit(:page_deleted.t(:page => page.path))
290
+ render :deleted
291
+ end
292
+ end
293
+ end
294
+ end