olelo 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.gitmodules +3 -0
- data/Gemfile +3 -0
- data/README.markdown +104 -0
- data/Rakefile +92 -0
- data/bin/olelo +5 -0
- data/config.ru +86 -0
- data/config/aspects.rb +256 -0
- data/config/config.yml.default +154 -0
- data/config/initializers/00-mime_types.rb +29 -0
- data/config/initializers/01-slim.rb +2 -0
- data/config/interwiki.yml +11 -0
- data/doc/AUTHORS +7 -0
- data/doc/LICENSE +22 -0
- data/lib/olelo.rb +39 -0
- data/lib/olelo/application.rb +294 -0
- data/lib/olelo/attributes.rb +285 -0
- data/lib/olelo/config.rb +88 -0
- data/lib/olelo/extensions.rb +252 -0
- data/lib/olelo/helper.rb +290 -0
- data/lib/olelo/hooks.rb +142 -0
- data/lib/olelo/html_safe.rb +29 -0
- data/lib/olelo/initializer.rb +76 -0
- data/lib/olelo/locale.rb +63 -0
- data/lib/olelo/locale.yml +284 -0
- data/lib/olelo/menu.rb +101 -0
- data/lib/olelo/middleware/blacklist.rb +25 -0
- data/lib/olelo/middleware/degrade_mime_type.rb +19 -0
- data/lib/olelo/middleware/flash.rb +97 -0
- data/lib/olelo/middleware/force_encoding.rb +41 -0
- data/lib/olelo/page.rb +266 -0
- data/lib/olelo/patch.rb +311 -0
- data/lib/olelo/plugin.rb +188 -0
- data/lib/olelo/repository.rb +225 -0
- data/lib/olelo/routing.rb +223 -0
- data/lib/olelo/templates.rb +30 -0
- data/lib/olelo/user.rb +132 -0
- data/lib/olelo/util.rb +233 -0
- data/lib/olelo/version.rb +3 -0
- data/lib/olelo/virtualfs.rb +161 -0
- data/lib/rack/olelo_patches.rb +33 -0
- data/lib/rack/relative_redirect.rb +44 -0
- data/lib/rack/static_cache.rb +93 -0
- data/lib/yard/addons.rb +1 -0
- data/lib/yard/addons/hook_handler.rb +25 -0
- data/lib/yard/addons/override_tag.rb +14 -0
- data/lib/yard/addons/route_handler.rb +33 -0
- data/lib/yard/addons/sanitize_anchor.rb +16 -0
- data/olelo.gemspec +31 -0
- data/plugins/aspects/changelog.rb +45 -0
- data/plugins/aspects/documentbrowser.rb +57 -0
- data/plugins/aspects/download.rb +11 -0
- data/plugins/aspects/highlight.rb +8 -0
- data/plugins/aspects/image.rb +41 -0
- data/plugins/aspects/imageinfo.rb +64 -0
- data/plugins/aspects/locale.yml +60 -0
- data/plugins/aspects/main.rb +199 -0
- data/plugins/aspects/pageinfo.rb +37 -0
- data/plugins/aspects/source.rb +6 -0
- data/plugins/aspects/subpages.rb +44 -0
- data/plugins/aspects/text.rb +9 -0
- data/plugins/blog/blog.css +1 -0
- data/plugins/blog/blog.scss +37 -0
- data/plugins/blog/locale.yml +12 -0
- data/plugins/blog/main.rb +85 -0
- data/plugins/editor/locale.yml +18 -0
- data/plugins/editor/markup/main.rb +3 -0
- data/plugins/editor/markup/script.js +10 -0
- data/plugins/editor/markup/script/00-jquery.textselection.js +267 -0
- data/plugins/editor/markup/script/01-olelo.markupeditor.js +116 -0
- data/plugins/editor/markup/script/init.js +10 -0
- data/plugins/editor/preview.rb +52 -0
- data/plugins/editor/recaptcha.rb +56 -0
- data/plugins/filters/creole.rb +37 -0
- data/plugins/filters/disposition.rb +9 -0
- data/plugins/filters/editsection.rb +67 -0
- data/plugins/filters/fix_img_tag.rb +16 -0
- data/plugins/filters/html_wrapper.rb +12 -0
- data/plugins/filters/interwiki.rb +19 -0
- data/plugins/filters/link_classifier.rb +26 -0
- data/plugins/filters/locale.yml +15 -0
- data/plugins/filters/main.rb +202 -0
- data/plugins/filters/markdown_nowiki.rb +15 -0
- data/plugins/filters/numbering.xsl +93 -0
- data/plugins/filters/orgmode.rb +6 -0
- data/plugins/filters/rubypants.rb +6 -0
- data/plugins/filters/s5/main.rb +32 -0
- data/plugins/filters/s5/s5.xsl +118 -0
- data/plugins/filters/tilt.rb +17 -0
- data/plugins/filters/toc.rb +50 -0
- data/plugins/filters/xhtml2latex.xsl +232 -0
- data/plugins/filters/xslt.rb +22 -0
- data/plugins/gallery/gallery.css +1 -0
- data/plugins/gallery/gallery.scss +28 -0
- data/plugins/gallery/main.rb +34 -0
- data/plugins/misc/fancybox/images/blank.gif +0 -0
- data/plugins/misc/fancybox/images/fancy_close.png +0 -0
- data/plugins/misc/fancybox/images/fancy_loading.png +0 -0
- data/plugins/misc/fancybox/images/fancy_nav_left.png +0 -0
- data/plugins/misc/fancybox/images/fancy_nav_right.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_e.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_n.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_ne.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_nw.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_s.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_se.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_sw.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_w.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_left.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_main.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_over.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_right.png +0 -0
- data/plugins/misc/fancybox/images/fancybox-x.png +0 -0
- data/plugins/misc/fancybox/images/fancybox-y.png +0 -0
- data/plugins/misc/fancybox/images/fancybox.png +0 -0
- data/plugins/misc/fancybox/jquery.fancybox.css +1 -0
- data/plugins/misc/fancybox/jquery.fancybox.scss +323 -0
- data/plugins/misc/fancybox/main.rb +4 -0
- data/plugins/misc/fancybox/script.js +37 -0
- data/plugins/misc/fancybox/script/00-jquery.mousewheel.js +84 -0
- data/plugins/misc/fancybox/script/01-jquery.easing.js +205 -0
- data/plugins/misc/fancybox/script/02-jquery.fancybox.js +1156 -0
- data/plugins/misc/fancybox/script/init.js +18 -0
- data/plugins/misc/system.rb +192 -0
- data/plugins/misc/variables.rb +29 -0
- data/plugins/misc/webdav.rb +45 -0
- data/plugins/repositories/git_grep.rb +69 -0
- data/plugins/repositories/gitrb_repository.rb +204 -0
- data/plugins/repositories/locale.yml +12 -0
- data/plugins/repositories/rugged_repository.rb +454 -0
- data/plugins/security/acl.rb +57 -0
- data/plugins/security/basic_auth.rb +21 -0
- data/plugins/security/locale.yml +21 -0
- data/plugins/security/persistent_login.rb +32 -0
- data/plugins/security/portal.rb +28 -0
- data/plugins/security/private_wiki.rb +24 -0
- data/plugins/security/readonly_wiki.rb +25 -0
- data/plugins/security/stack.rb +20 -0
- data/plugins/security/yamlfile.rb +66 -0
- data/plugins/tags/code.rb +6 -0
- data/plugins/tags/footnotes.rb +35 -0
- data/plugins/tags/gist-embed.css +123 -0
- data/plugins/tags/gist.rb +13 -0
- data/plugins/tags/html.rb +57 -0
- data/plugins/tags/include.rb +20 -0
- data/plugins/tags/main.rb +353 -0
- data/plugins/tags/math.rb +117 -0
- data/plugins/tags/scripting.rb +64 -0
- data/plugins/tags/sort.rb +7 -0
- data/plugins/tags/tabs.rb +20 -0
- data/plugins/treeview/images/collapsed.png +0 -0
- data/plugins/treeview/images/expanded.png +0 -0
- data/plugins/treeview/images/menu.png +0 -0
- data/plugins/treeview/images/tree.png +0 -0
- data/plugins/treeview/images/wait.gif +0 -0
- data/plugins/treeview/main.rb +16 -0
- data/plugins/treeview/script.js +5 -0
- data/plugins/treeview/script/00-jquery.treeview.js +164 -0
- data/plugins/treeview/script/init.js +25 -0
- data/plugins/treeview/treeview.css +1 -0
- data/plugins/treeview/treeview.scss +113 -0
- data/plugins/utils/assets.rb +74 -0
- data/plugins/utils/cache.rb +53 -0
- data/plugins/utils/image_magick.rb +34 -0
- data/plugins/utils/pygments.css +1 -0
- data/plugins/utils/pygments.rb +50 -0
- data/plugins/utils/pygments.scss +83 -0
- data/plugins/utils/semaphore.rb +50 -0
- data/plugins/utils/shell.rb +45 -0
- data/plugins/utils/store.rb +315 -0
- data/plugins/utils/worker.rb +36 -0
- data/plugins/utils/xml.rb +29 -0
- data/static/images/favicon.png +0 -0
- data/static/script.js +267 -0
- data/static/script/00-json2.js +486 -0
- data/static/script/01-jstorage.js +217 -0
- data/static/script/02-jquery.js +9440 -0
- data/static/script/03-jquery.ui.core.js +337 -0
- data/static/script/04-jquery.ui.widget.js +502 -0
- data/static/script/05-jquery.ui.position.js +517 -0
- data/static/script/06-jquery.ui.menu.js +609 -0
- data/static/script/07-jquery.ui.autocomplete.js +601 -0
- data/static/script/08-olelo.i18n.js +37 -0
- data/static/script/09-olelo.unsaved.js +68 -0
- data/static/script/10-olelo.historytable.js +40 -0
- data/static/script/11-olelo.pagination.js +18 -0
- data/static/script/13-olelo.tabwidget.js +57 -0
- data/static/script/14-olelo.timeago.js +70 -0
- data/static/script/15-olelo.underliner.js +31 -0
- data/static/script/16-olelo.ui.combobox.js +32 -0
- data/static/script/init.js +48 -0
- data/static/themes/atlantis/constants.scss +15 -0
- data/static/themes/atlantis/iehacks.scss +38 -0
- data/static/themes/atlantis/images/actions/delete.png +0 -0
- data/static/themes/atlantis/images/actions/edit.png +0 -0
- data/static/themes/atlantis/images/actions/history.png +0 -0
- data/static/themes/atlantis/images/actions/home.png +0 -0
- data/static/themes/atlantis/images/actions/move.png +0 -0
- data/static/themes/atlantis/images/actions/new.png +0 -0
- data/static/themes/atlantis/images/actions/page.png +0 -0
- data/static/themes/atlantis/images/bg/button.png +0 -0
- data/static/themes/atlantis/images/bg/container.png +0 -0
- data/static/themes/atlantis/images/bg/content.png +0 -0
- data/static/themes/atlantis/images/bg/footer.png +0 -0
- data/static/themes/atlantis/images/bg/header.jpg +0 -0
- data/static/themes/atlantis/images/bg/header.orig.jpg +0 -0
- data/static/themes/atlantis/images/bg/header_gray.jpg +0 -0
- data/static/themes/atlantis/images/bug.png +0 -0
- data/static/themes/atlantis/images/filetypes/7z.png +0 -0
- data/static/themes/atlantis/images/filetypes/_archive.png +0 -0
- data/static/themes/atlantis/images/filetypes/_audio.png +0 -0
- data/static/themes/atlantis/images/filetypes/_code.png +0 -0
- data/static/themes/atlantis/images/filetypes/_linux.png +0 -0
- data/static/themes/atlantis/images/filetypes/_picture.png +0 -0
- data/static/themes/atlantis/images/filetypes/_video.png +0 -0
- data/static/themes/atlantis/images/filetypes/bz2.png +0 -0
- data/static/themes/atlantis/images/filetypes/doc.png +0 -0
- data/static/themes/atlantis/images/filetypes/flac.png +0 -0
- data/static/themes/atlantis/images/filetypes/gz.png +0 -0
- data/static/themes/atlantis/images/filetypes/html.png +0 -0
- data/static/themes/atlantis/images/filetypes/java.png +0 -0
- data/static/themes/atlantis/images/filetypes/jpg.png +0 -0
- data/static/themes/atlantis/images/filetypes/midi.png +0 -0
- data/static/themes/atlantis/images/filetypes/mp3.png +0 -0
- data/static/themes/atlantis/images/filetypes/ogg.png +0 -0
- data/static/themes/atlantis/images/filetypes/pdf.png +0 -0
- data/static/themes/atlantis/images/filetypes/php.png +0 -0
- data/static/themes/atlantis/images/filetypes/png.png +0 -0
- data/static/themes/atlantis/images/filetypes/ppt.png +0 -0
- data/static/themes/atlantis/images/filetypes/psd.png +0 -0
- data/static/themes/atlantis/images/filetypes/rar.png +0 -0
- data/static/themes/atlantis/images/filetypes/rb.png +0 -0
- data/static/themes/atlantis/images/filetypes/sh.png +0 -0
- data/static/themes/atlantis/images/filetypes/tar.png +0 -0
- data/static/themes/atlantis/images/filetypes/txt.png +0 -0
- data/static/themes/atlantis/images/filetypes/wma.png +0 -0
- data/static/themes/atlantis/images/filetypes/xls.png +0 -0
- data/static/themes/atlantis/images/filetypes/zip.png +0 -0
- data/static/themes/atlantis/images/folder.png +0 -0
- data/static/themes/atlantis/images/folder_open.png +0 -0
- data/static/themes/atlantis/images/loading.gif +0 -0
- data/static/themes/atlantis/images/loading.xcf +0 -0
- data/static/themes/atlantis/images/not_found.png +0 -0
- data/static/themes/atlantis/images/page.png +0 -0
- data/static/themes/atlantis/images/search.png +0 -0
- data/static/themes/atlantis/layout.scss +115 -0
- data/static/themes/atlantis/menu.scss +99 -0
- data/static/themes/atlantis/print.scss +129 -0
- data/static/themes/atlantis/screen.scss +495 -0
- data/static/themes/atlantis/style.css +3 -0
- data/static/themes/lib/autocomplete.scss +39 -0
- data/static/themes/lib/headlines.scss +10 -0
- data/static/themes/lib/horizontal-list.scss +31 -0
- data/static/themes/lib/patch.scss +88 -0
- data/static/themes/lib/reset.scss +114 -0
- data/static/themes/lib/rounded.scss +46 -0
- data/static/themes/lib/shadow.scss +14 -0
- data/test/config_test.rb +28 -0
- data/test/factory_test.rb +29 -0
- data/test/hash_extensions_test.rb +16 -0
- data/test/helper.rb +38 -0
- data/test/hooks_test.rb +85 -0
- data/test/object_extensions_test.rb +20 -0
- data/test/page_test.rb +168 -0
- data/test/request_test.rb +166 -0
- data/test/string_extensions_test.rb +32 -0
- data/test/templates_test.rb +39 -0
- data/test/util_test.rb +71 -0
- data/views/changes.slim +22 -0
- data/views/compare.slim +8 -0
- data/views/delete.slim +9 -0
- data/views/deleted.slim +2 -0
- data/views/edit.slim +65 -0
- data/views/error.slim +6 -0
- data/views/history.slim +20 -0
- data/views/layout.slim +38 -0
- data/views/login.slim +37 -0
- data/views/move.slim +10 -0
- data/views/not_found.slim +6 -0
- data/views/profile.slim +26 -0
- data/views/show.slim +9 -0
- metadata +488 -0
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
README
|
2
|
+
======
|
3
|
+
|
4
|
+
Ōlelo is a wiki that stores pages in a [Git][] repository.
|
5
|
+
See the demo installation at <http://www.gitwiki.org/>.
|
6
|
+
|
7
|
+
Features
|
8
|
+
--------
|
9
|
+
|
10
|
+
A lot of the features are implemented as plugins.
|
11
|
+
|
12
|
+
- Edit, move or delete pages
|
13
|
+
- Support for hierarchical wikis (directory structure)
|
14
|
+
- Upload files
|
15
|
+
- History (also as RSS/Atom changelog)
|
16
|
+
- Access control lists
|
17
|
+
- Support for multiple text engines (Creole, Markdown, Textile, ...)
|
18
|
+
- Section editing for creole markup
|
19
|
+
- Embedded LaTeX/Graphviz graphics
|
20
|
+
- Syntax highlighting (embedded code blocks)
|
21
|
+
- Image resizing, SVG to bitmap conversion
|
22
|
+
- Auto-generated table of contents
|
23
|
+
- Templates via include-tag
|
24
|
+
- XML tag soup can be used to extend Wiki syntax
|
25
|
+
- View pages as S5 presentation
|
26
|
+
|
27
|
+
Installation
|
28
|
+
------------
|
29
|
+
|
30
|
+
The best way to install olelo is via `gem`:
|
31
|
+
|
32
|
+
$ gem install olelo
|
33
|
+
|
34
|
+
If you run olelo from source you can use Bundler to install the dependencies.
|
35
|
+
|
36
|
+
$ bundle install
|
37
|
+
|
38
|
+
Running
|
39
|
+
-------
|
40
|
+
|
41
|
+
If you installed via gem, go to a git repository via command line and execute:
|
42
|
+
|
43
|
+
$ olelo
|
44
|
+
|
45
|
+
If you installed from source you can run the rackup configuration from the olelo application directory:
|
46
|
+
|
47
|
+
$ unicorn
|
48
|
+
|
49
|
+
Point your web browser at <http://localhost:8080>.
|
50
|
+
|
51
|
+
For production purposes, I recommend that you deploy the wiki with Unicorn.
|
52
|
+
I tested other webservers like thin, rainbows, webrick and mongrel.
|
53
|
+
|
54
|
+
Configuration
|
55
|
+
-------------
|
56
|
+
|
57
|
+
You might want to deploy the wiki on a server and want to tweak some settings.
|
58
|
+
Just copy the default configuration config/config.yml.default to config/config.yml.
|
59
|
+
You can specify a different configuration file via the environment variable WIKI_CONFIG.
|
60
|
+
|
61
|
+
export WIKI_CONFIG=/home/user/wiki_config.yml
|
62
|
+
|
63
|
+
Dependencies
|
64
|
+
------------
|
65
|
+
|
66
|
+
- [Nokogiri][]
|
67
|
+
- [Slim][]
|
68
|
+
- [Rugged][]
|
69
|
+
- [Rack][]
|
70
|
+
- [MimeMagic][]
|
71
|
+
|
72
|
+
### Optional Dependencies
|
73
|
+
|
74
|
+
- [Pygments][] for syntax highlighting
|
75
|
+
- [ImageMagick][] for image scaling and svg rendering
|
76
|
+
- [RubyPants][] to fix punctuation
|
77
|
+
|
78
|
+
### Dependencies for page rendering
|
79
|
+
|
80
|
+
At least one of these renderers should be installed:
|
81
|
+
|
82
|
+
- [creole][] for creole wikitext rendering
|
83
|
+
(`creole` Gem from [gemcutter][])
|
84
|
+
- [RedCarpet][] for Markdown rendering
|
85
|
+
- [RedCloth][] for Textile rendering
|
86
|
+
- [org-ruby][] for org-mode rendering
|
87
|
+
|
88
|
+
[creole]:http://github.com/minad/creole
|
89
|
+
[mimemagic]:http://github.com/minad/mimemagic
|
90
|
+
[Gem]:http://rubygems.org
|
91
|
+
[Git]:http://www.git-scm.org
|
92
|
+
[rack]:http://rack.rubyforge.org/
|
93
|
+
[org-ruby]:http://orgmode.org/worg/org-tutorials/org-ruby.php
|
94
|
+
[GraphViz]:http://www.graphviz.org
|
95
|
+
[SLIM]:http://github.com/stonean/slim
|
96
|
+
[nokogiri]:http://nokogiri.org/
|
97
|
+
[LaTeX]:www.latex-project.org
|
98
|
+
[pygments]:http://pygments.org/
|
99
|
+
[RedCarpet]:http://github.com/tanoku/redcarpet
|
100
|
+
[RedCloth]:http://redcloth.org/
|
101
|
+
[ImageMagick]:http://www.imagemagick.org/
|
102
|
+
[gitrb]:http://github.com/minad/gitrb/
|
103
|
+
[gemcutter]:http://gemcutter.org/
|
104
|
+
[RubyPants]:http://chneukirchen.org/blog/static/projects/rubypants.html
|
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
task :default => %w(test:spec)
|
2
|
+
|
3
|
+
def shrink_js(t)
|
4
|
+
#sh "cat #{t.prerequisites.sort.join(' ')} > #{t.name}"
|
5
|
+
sh 'java -jar tools/google-compiler*.jar --dev_mode EVERY_PASS --compilation_level SIMPLE_OPTIMIZATIONS ' +
|
6
|
+
t.prerequisites.sort.map {|x| "--js #{x}" }.join(' ') + " > #{t.name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def sass(file)
|
10
|
+
`sass -C -I #{File.dirname(file)} -I static/themes -t compressed #{file}`
|
11
|
+
end
|
12
|
+
|
13
|
+
def spew(file, content)
|
14
|
+
File.open(file, 'w') {|f| f.write(content) }
|
15
|
+
end
|
16
|
+
|
17
|
+
file 'plugins/utils/pygments.scss' do
|
18
|
+
sh "pygmentize -S default -f html -a .highlight > plugins/utils/pygments.scss"
|
19
|
+
end
|
20
|
+
|
21
|
+
file('static/themes/atlantis/style.css' => Dir.glob('static/themes/atlantis/*.scss') + Dir.glob('static/themes/lib/*.scss')) do |t|
|
22
|
+
puts "Creating #{t.name}..."
|
23
|
+
content = "@media screen{#{sass(t.name.gsub('style.css', 'screen.scss'))}}@media print{#{sass(t.name.gsub('style.css', 'print.scss'))}}"
|
24
|
+
spew(t.name, content)
|
25
|
+
end
|
26
|
+
|
27
|
+
rule '.css' => ['.scss'] do |t|
|
28
|
+
puts "Creating #{t.name}..."
|
29
|
+
spew(t.name, sass(t.source))
|
30
|
+
end
|
31
|
+
|
32
|
+
file('static/script.js' => Dir.glob('static/script/*.js')) { |t| shrink_js(t) }
|
33
|
+
file('plugins/treeview/script.js' => Dir.glob('plugins/treeview/script/*.js')) {|t| shrink_js(t) }
|
34
|
+
file('plugins/misc/fancybox/script.js' => Dir.glob('plugins/misc/fancybox/script/*.js')) {|t| shrink_js(t) }
|
35
|
+
file('plugins/editor/markup/script.js' => Dir.glob('plugins/editor/markup/script/*.js')) {|t| shrink_js(t) }
|
36
|
+
|
37
|
+
namespace :gen do
|
38
|
+
desc('Shrink JS files')
|
39
|
+
task :js => %w(static/script.js plugins/treeview/script.js plugins/misc/fancybox/script.js plugins/editor/markup/script.js)
|
40
|
+
|
41
|
+
desc('Compile CSS files')
|
42
|
+
task :css => %w(static/themes/atlantis/style.css
|
43
|
+
plugins/treeview/treeview.css
|
44
|
+
plugins/utils/pygments.css
|
45
|
+
plugins/gallery/gallery.css
|
46
|
+
plugins/misc/fancybox/jquery.fancybox.css
|
47
|
+
plugins/blog/blog.css)
|
48
|
+
end
|
49
|
+
|
50
|
+
namespace :test do
|
51
|
+
desc 'Run tests with bacon'
|
52
|
+
task :spec => FileList['test/*_test.rb'] do |t|
|
53
|
+
sh "bacon -q -Ilib:test #{t.prerequisites.join(' ')}"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Generate test coverage report'
|
57
|
+
task :rcov => FileList['test/*_test.rb'] do |t|
|
58
|
+
sh "rcov -Ilib:test #{t.prerequisites.join(' ')}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'Cleanup'
|
63
|
+
task :clean do |t|
|
64
|
+
FileUtils.rm_rf 'doc/api'
|
65
|
+
FileUtils.rm_rf 'coverage'
|
66
|
+
FileUtils.rm_rf '.wiki/cache'
|
67
|
+
FileUtils.rm_rf '.wiki/blahtex'
|
68
|
+
FileUtils.rm_rf '.wiki/log'
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Remove wiki folder'
|
72
|
+
task 'clean:all' => :clean do |t|
|
73
|
+
FileUtils.rm_rf '.wiki'
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'Generate documentation'
|
77
|
+
namespace :doc do
|
78
|
+
task :gen do; system("yard doc -o doc/api -e lib/yard/addons.rb --backtrace 'lib/**/*.rb' 'plugins/**/*.rb'"); end
|
79
|
+
task :server do; system('yard server --reload -e lib/yard/addons.rb --backtrace'); end
|
80
|
+
task :check do; system("yardcheck 'lib/**/*.rb' 'plugins/**/*.rb'"); end
|
81
|
+
end
|
82
|
+
|
83
|
+
namespace :notes do
|
84
|
+
task :todo do; system('ack T''ODO'); end
|
85
|
+
task :fixme do; system('ack F''IXME'); end
|
86
|
+
task :hack do; system('ack H''ACK'); end
|
87
|
+
task :warning do; system('ack W''ARNING'); end
|
88
|
+
task :important do; system('ack I''MPORTANT'); end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'Show annotations'
|
92
|
+
task :notes => %w(notes:todo notes:fixme notes:hack notes:warning notes:important)
|
data/bin/olelo
ADDED
data/config.ru
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env rackup
|
2
|
+
|
3
|
+
app_path = ::File.expand_path(::File.dirname(__FILE__))
|
4
|
+
$: << ::File.join(app_path, 'lib')
|
5
|
+
|
6
|
+
# We want to read all text data as UTF-8
|
7
|
+
Encoding.default_external = Encoding::UTF_8
|
8
|
+
|
9
|
+
require 'fileutils'
|
10
|
+
require 'rack/olelo_patches'
|
11
|
+
require 'rack/relative_redirect'
|
12
|
+
require 'rack/static_cache'
|
13
|
+
require 'olelo'
|
14
|
+
require 'olelo/middleware/degrade_mime_type'
|
15
|
+
require 'olelo/middleware/flash'
|
16
|
+
require 'olelo/middleware/force_encoding'
|
17
|
+
require 'securerandom'
|
18
|
+
|
19
|
+
Olelo::Config.instance['app_path'] = app_path
|
20
|
+
Olelo::Config.instance['config_path'] = ::File.join(app_path, 'config')
|
21
|
+
Olelo::Config.instance['initializers_path'] = ::File.join(app_path, 'config', 'initializers')
|
22
|
+
Olelo::Config.instance['plugins_path'] = ::File.join(app_path, 'plugins')
|
23
|
+
Olelo::Config.instance['views_path'] = ::File.join(app_path, 'views')
|
24
|
+
Olelo::Config.instance['themes_path'] = ::File.join(app_path, 'static', 'themes')
|
25
|
+
Olelo::Config.instance['rack.session_secret'] = SecureRandom.hex
|
26
|
+
Olelo::Config.instance.load!(::File.join(app_path, 'config', 'config.yml.default'))
|
27
|
+
|
28
|
+
if Dir.pwd == app_path
|
29
|
+
puts "Serving from Olelo application directory #{app_path}"
|
30
|
+
data_path = File.join(app_path, '.wiki')
|
31
|
+
Olelo::Config.instance['repository.git'] = { :path => ::File.join(data_path, 'repository'), :bare => false }
|
32
|
+
Olelo::Config.instance['cache_store'] = { :type => 'file', 'file.root' => ::File.join(data_path, 'cache') }
|
33
|
+
Olelo::Config.instance['authentication.yamlfile.store'] = ::File.join(data_path, 'users.yml')
|
34
|
+
Olelo::Config.instance['log.file'] = ::File.join(data_path, 'log')
|
35
|
+
elsif File.directory?(::File.join(Dir.pwd, '.git'))
|
36
|
+
puts "Serving out of repository #{Dir.pwd}"
|
37
|
+
data_path = File.join(Dir.pwd, '.wiki')
|
38
|
+
Olelo::Config.instance['repository.git'] = { :path => Dir.pwd, :bare => false }
|
39
|
+
Olelo::Config.instance['cache_store'] = { :type => 'file', 'file.root' => ::File.join(data_path, 'cache') }
|
40
|
+
Olelo::Config.instance['authentication.yamlfile.store'] = ::File.join(data_path, 'users.yml')
|
41
|
+
Olelo::Config.instance['log.file'] = ::File.join(data_path, 'log')
|
42
|
+
else
|
43
|
+
puts 'No default data storage location defined, please create your own configuration!'
|
44
|
+
end
|
45
|
+
|
46
|
+
Olelo::Config.instance.load(ENV['OLELO_CONFIG'] || ENV['WIKI_CONFIG'] || ::File.join(app_path, 'config', 'config.yml'))
|
47
|
+
Olelo::Config.instance.freeze
|
48
|
+
|
49
|
+
FileUtils.mkpath ::File.dirname(Olelo::Config['log.file'])
|
50
|
+
logger = ::Logger.new(Olelo::Config['log.file'], :monthly, 10240000)
|
51
|
+
logger.level = ::Logger.const_get(Olelo::Config['log.level'])
|
52
|
+
|
53
|
+
use_lint if !Olelo::Config['production']
|
54
|
+
|
55
|
+
use Rack::Runtime
|
56
|
+
use Rack::ShowExceptions if !Olelo::Config['production']
|
57
|
+
|
58
|
+
if Olelo::Config['rack.deflater']
|
59
|
+
use Rack::Deflater
|
60
|
+
end
|
61
|
+
|
62
|
+
use Rack::StaticCache, :urls => ['/static'], :root => app_path
|
63
|
+
use Rack::Session::Cookie, :key => 'olelo.session', :secret => Olelo::Config['rack.session_secret']
|
64
|
+
use Olelo::Middleware::DegradeMimeType
|
65
|
+
|
66
|
+
class LoggerOutput
|
67
|
+
def initialize(logger); @logger = logger; end
|
68
|
+
def write(text); @logger << text; end
|
69
|
+
end
|
70
|
+
|
71
|
+
use Rack::MethodOverride
|
72
|
+
use Rack::CommonLogger, LoggerOutput.new(logger)
|
73
|
+
|
74
|
+
if !Olelo::Config['rack.blacklist'].empty?
|
75
|
+
require 'olelo/middleware/blacklist'
|
76
|
+
use Olelo::Middleware::Blacklist, :blacklist => Olelo::Config['rack.blacklist']
|
77
|
+
end
|
78
|
+
|
79
|
+
use Olelo::Middleware::ForceEncoding
|
80
|
+
use Olelo::Middleware::Flash, :set_accessors => %w(error warn info)
|
81
|
+
use Rack::RelativeRedirect
|
82
|
+
|
83
|
+
Olelo::Initializer.initialize(logger)
|
84
|
+
run Olelo::Application.new
|
85
|
+
|
86
|
+
logger.info "Olelo started in #{Olelo::Config['production'] ? 'production' : 'development'} mode"
|
data/config/aspects.rb
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
# Filter aspect configuration aspects.rb
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
#
|
5
|
+
# Register some simple regular expression filters which are used later
|
6
|
+
#
|
7
|
+
# Usage:
|
8
|
+
# regexp :filter_name, /regex1/, 'replacement1', /regex2/, 'replacement2'
|
9
|
+
#
|
10
|
+
################################################################################
|
11
|
+
|
12
|
+
regexp :remove_comments, /<!--.*?-->/m, ''
|
13
|
+
regexp :tag_shortcuts, /\\\((.*?)\\\)/m, '<math display="inline">\1</math>',
|
14
|
+
/\\\[(.*?)\\\]/m, '<math display="block">\1</math>',
|
15
|
+
/<<(.*?)(\|(.*?))?>>/, '<include page="\1" \3/>'
|
16
|
+
regexp :creole_nowiki, /\{\{\{.*?\}\}\}/m, '<notags>\0</notags>'
|
17
|
+
regexp :textile_nowiki, /<pre>.*?<\/pre>/m, '<notags>\0</notags>'
|
18
|
+
regexp :mediawiki_nowiki, /<nowiki>.*?<\/nowiki>/m, '<notags>\0</notags>'
|
19
|
+
|
20
|
+
################################################################################
|
21
|
+
#
|
22
|
+
# Define filter aspects which process pages by sending them
|
23
|
+
# through multiple filters. DSL methods can be chained.
|
24
|
+
# Available filters are listed on the /system page.
|
25
|
+
#
|
26
|
+
# Example DSL usage:
|
27
|
+
#
|
28
|
+
# aspect :aspect_name do # Create aspect with name "aspect_name"
|
29
|
+
# is_cacheable # Aspect supports caching (renders static content)
|
30
|
+
# needs_layout # Aspect needs a html layout around the generated content
|
31
|
+
# has_priority 1 # Aspect has priority 1, lower priorities are preferred
|
32
|
+
# accepts 'text/x-creole' # Accepted mime types. This is a regular expression
|
33
|
+
# mime 'text/html' # Generated mime type. Only interesting for aspects which don't need a layout.
|
34
|
+
# filter do # Define filter chain
|
35
|
+
# remove_comments # First filter removes html comments <!--...-->. This filter is defined above.
|
36
|
+
# tag_shortcuts # Replace tag shortcuts with tags (e.g $$...$$ -> <math>...</math>, <<page>> -> <include page="page"/>)
|
37
|
+
# creole_nowiki # Replace creole nowiki tags with <notags> to disable tag interpretation (next filter)
|
38
|
+
# tag do # Interpret wiki tags. Wiki tags are an extension to default wiki text
|
39
|
+
# creole! # Transform creole to html
|
40
|
+
# rubypants # Execute rubypants (e.g. replace ... with …)
|
41
|
+
# end
|
42
|
+
# toc # Auto-generate table of contents
|
43
|
+
# link_classifier # Classify links: Insert classes present for present pages, absent for absent pages, internal, external
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# tag filter options:
|
48
|
+
# tag(:enable => 'html:*') Enable only html tags
|
49
|
+
# tag(:disable => %w(html:* scripting:include)) Disable html tags and scripting:include
|
50
|
+
# tag(:disable => 'html:*') Disable only html tags
|
51
|
+
#
|
52
|
+
################################################################################
|
53
|
+
|
54
|
+
interwiki_map = YAML.load_file(File.join(Config['config_path'], 'interwiki.yml'))
|
55
|
+
|
56
|
+
################################################################################
|
57
|
+
# Creole aspects configuration
|
58
|
+
################################################################################
|
59
|
+
|
60
|
+
aspect :page do
|
61
|
+
is_cacheable.needs_layout.has_priority(1)
|
62
|
+
accepts 'text/x-creole'
|
63
|
+
filter do
|
64
|
+
editsection do
|
65
|
+
remove_comments.tag_shortcuts
|
66
|
+
creole_nowiki.tag { creole!.rubypants }
|
67
|
+
end
|
68
|
+
toc.interwiki(:map => interwiki_map).link_classifier
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
aspect :s5 do
|
73
|
+
is_cacheable
|
74
|
+
accepts 'text/x-creole'
|
75
|
+
mime 'application/xhtml+xml; charset=utf-8'
|
76
|
+
filter do
|
77
|
+
remove_comments.tag_shortcuts
|
78
|
+
creole_nowiki.tag { creole!.rubypants }
|
79
|
+
toc.interwiki(:map => interwiki_map).link_classifier
|
80
|
+
html_wrapper!.s5!
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
aspect :latex do
|
85
|
+
is_cacheable
|
86
|
+
accepts 'text/x-creole'
|
87
|
+
mime 'text/plain; charset=utf-8'
|
88
|
+
filter do
|
89
|
+
remove_comments.tag_shortcuts.creole_nowiki
|
90
|
+
tag(:static => true) { creole!.rubypants }
|
91
|
+
toc.interwiki(:map => interwiki_map)
|
92
|
+
html_wrapper!.xslt!(:stylesheet => 'xhtml2latex.xsl')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
################################################################################
|
97
|
+
# Mediawiki aspects configuration
|
98
|
+
################################################################################
|
99
|
+
|
100
|
+
aspect :page do
|
101
|
+
is_cacheable.needs_layout.has_priority(1)
|
102
|
+
accepts 'text/x-mediawiki'
|
103
|
+
filter do
|
104
|
+
editsection do
|
105
|
+
remove_comments.tag_shortcuts
|
106
|
+
mediawiki_nowiki.tag { mediawiki!.rubypants }
|
107
|
+
end
|
108
|
+
toc.interwiki(:map => interwiki_map).link_classifier
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
aspect :s5 do
|
113
|
+
is_cacheable
|
114
|
+
accepts 'text/x-mediawiki'
|
115
|
+
mime 'application/xhtml+xml; charset=utf-8'
|
116
|
+
filter do
|
117
|
+
remove_comments.tag_shortcuts
|
118
|
+
mediawiki_nowiki.tag { mediawiki!.rubypants }
|
119
|
+
toc.interwiki(:map => interwiki_map).link_classifier
|
120
|
+
html_wrapper!.s5!
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
aspect :latex do
|
125
|
+
is_cacheable
|
126
|
+
accepts 'text/x-mediawiki'
|
127
|
+
mime 'text/plain; charset=utf-8'
|
128
|
+
filter do
|
129
|
+
remove_comments.tag_shortcuts.mediawiki_nowiki
|
130
|
+
tag(:static => true) { mediawiki!.rubypants }
|
131
|
+
toc.interwiki(:map => interwiki_map)
|
132
|
+
html_wrapper!.xslt!(:stylesheet => 'xhtml2latex.xsl')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
################################################################################
|
137
|
+
# Textile aspects configuration
|
138
|
+
################################################################################
|
139
|
+
|
140
|
+
aspect :page do
|
141
|
+
is_cacheable.needs_layout.has_priority(1)
|
142
|
+
accepts 'text/x-textile'
|
143
|
+
filter do
|
144
|
+
remove_comments.tag_shortcuts.textile_nowiki
|
145
|
+
tag(:disable => 'html:*') { textile!.rubypants }
|
146
|
+
fix_img_tag.toc
|
147
|
+
interwiki(:map => interwiki_map).link_classifier
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
aspect :s5 do
|
152
|
+
is_cacheable
|
153
|
+
accepts 'text/x-textile'
|
154
|
+
mime 'application/xhtml+xml; charset=utf-8'
|
155
|
+
filter do
|
156
|
+
remove_comments.tag_shortcuts.textile_nowiki
|
157
|
+
tag(:disable => 'html:*') { textile!.rubypants }
|
158
|
+
fix_img_tag.toc
|
159
|
+
interwiki(:map => interwiki_map).link_classifier
|
160
|
+
html_wrapper!.s5!
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
aspect :latex do
|
165
|
+
is_cacheable
|
166
|
+
accepts 'text/x-textile'
|
167
|
+
mime 'text/plain; charset=utf-8'
|
168
|
+
filter do
|
169
|
+
remove_comments.tag_shortcuts.textile_nowiki
|
170
|
+
tag(:static => true, :disable => 'html:*') { textile!.rubypants }
|
171
|
+
toc.interwiki(:map => interwiki_map)
|
172
|
+
html_wrapper!.xslt!(:stylesheet => 'xhtml2latex.xsl')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
################################################################################
|
177
|
+
# Markdown aspects configuration
|
178
|
+
################################################################################
|
179
|
+
|
180
|
+
aspect :page do
|
181
|
+
is_cacheable.needs_layout.has_priority(1)
|
182
|
+
accepts 'text/x-markdown'
|
183
|
+
filter do
|
184
|
+
editsection do
|
185
|
+
remove_comments.tag_shortcuts.markdown_nowiki
|
186
|
+
tag(:disable => 'html:*') { markdown! }
|
187
|
+
end
|
188
|
+
fix_img_tag.toc
|
189
|
+
interwiki(:map => interwiki_map).link_classifier
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
aspect :s5 do
|
194
|
+
is_cacheable
|
195
|
+
accepts 'text/x-markdown'
|
196
|
+
mime 'application/xhtml+xml; charset=utf-8'
|
197
|
+
filter do
|
198
|
+
remove_comments.tag_shortcuts.markdown_nowiki
|
199
|
+
tag(:disable => 'html:*') { markdown! }
|
200
|
+
fix_img_tag.toc
|
201
|
+
interwiki(:map => interwiki_map).link_classifier
|
202
|
+
html_wrapper!.s5!
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
aspect :latex do
|
207
|
+
is_cacheable
|
208
|
+
accepts 'text/x-markdown'
|
209
|
+
mime 'text/plain; charset=utf-8'
|
210
|
+
filter do
|
211
|
+
remove_comments.tag_shortcuts.markdown_nowiki
|
212
|
+
tag(:static => true, :disable => 'html:*') { markdown! }
|
213
|
+
toc.interwiki(:map => interwiki_map)
|
214
|
+
html_wrapper!.xslt!(:stylesheet => 'xhtml2latex.xsl')
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
################################################################################
|
219
|
+
# Orgmode aspects configuration
|
220
|
+
################################################################################
|
221
|
+
|
222
|
+
aspect :page do
|
223
|
+
is_cacheable.needs_layout.has_priority(1)
|
224
|
+
accepts 'text/x-orgmode'
|
225
|
+
filter do
|
226
|
+
remove_comments.tag_shortcuts
|
227
|
+
tag { orgmode!.rubypants }
|
228
|
+
fix_img_tag.toc
|
229
|
+
interwiki(:map => interwiki_map).link_classifier
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
aspect :s5 do
|
234
|
+
is_cacheable
|
235
|
+
accepts 'text/x-orgmode'
|
236
|
+
mime 'application/xhtml+xml; charset=utf-8'
|
237
|
+
filter do
|
238
|
+
remove_comments.tag_shortcuts
|
239
|
+
tag { orgmode!.rubypants }
|
240
|
+
fix_img_tag.toc
|
241
|
+
interwiki(:map => interwiki_map).link_classifier
|
242
|
+
html_wrapper!.s5!
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
aspect :latex do
|
247
|
+
is_cacheable
|
248
|
+
accepts 'text/x-orgmode'
|
249
|
+
mime 'text/plain; charset=utf-8'
|
250
|
+
filter do
|
251
|
+
remove_comments.tag_shortcuts
|
252
|
+
tag(:static => true) { orgmode!.rubypants }
|
253
|
+
toc.interwiki(:map => interwiki_map)
|
254
|
+
html_wrapper!.xslt!(:stylesheet => 'xhtml2latex.xsl')
|
255
|
+
end
|
256
|
+
end
|