olelo 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.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/test/hooks_test.rb
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require 'olelo/extensions'
|
|
2
|
+
require 'olelo/hooks'
|
|
3
|
+
|
|
4
|
+
describe 'Olelo::Hooks' do
|
|
5
|
+
before do
|
|
6
|
+
@hooks_test = Class.new do
|
|
7
|
+
include Olelo::Hooks
|
|
8
|
+
has_hooks :ping
|
|
9
|
+
has_around_hooks :action
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
after do
|
|
14
|
+
@hooks_test = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should check for hook existence' do
|
|
18
|
+
lambda { @hooks_test.hook(:action) {} }.should.raise RuntimeError
|
|
19
|
+
lambda { @hooks_test.before(:ping) {} }.should.raise RuntimeError
|
|
20
|
+
lambda { @hooks_test.after(:ping) {} }.should.raise RuntimeError
|
|
21
|
+
lambda { @hooks_test.new.invoke_hook(:action) {} }.should.raise RuntimeError
|
|
22
|
+
lambda { @hooks_test.new.with_hooks(:ping) {} }.should.raise RuntimeError
|
|
23
|
+
@hooks_test.hook(:ping) {}
|
|
24
|
+
@hooks_test.before(:action) {}
|
|
25
|
+
@hooks_test.after(:action) {}
|
|
26
|
+
@hooks_test.new.invoke_hook(:ping)
|
|
27
|
+
@hooks_test.new.with_hooks(:action) {}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should provide #hook' do
|
|
31
|
+
@hooks_test.should.respond_to :hook
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'should provide #before' do
|
|
35
|
+
@hooks_test.should.respond_to :before
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should provide #after' do
|
|
39
|
+
@hooks_test.should.respond_to :after
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should invoke hooks' do
|
|
43
|
+
hooks_test = @hooks_test
|
|
44
|
+
@hooks_test.hook(:ping) do |a, b|
|
|
45
|
+
self.should.be.instance_of hooks_test
|
|
46
|
+
a.should.equal 1
|
|
47
|
+
b.should.equal 2
|
|
48
|
+
:hook1
|
|
49
|
+
end
|
|
50
|
+
@hooks_test.hook(:ping) do |a, b|
|
|
51
|
+
:hook2
|
|
52
|
+
end
|
|
53
|
+
result = @hooks_test.new.invoke_hook(:ping, 1, 2)
|
|
54
|
+
result.should.be.instance_of Array
|
|
55
|
+
result.should.equal [:hook1, :hook2]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should invoke before and after hooks' do
|
|
59
|
+
hooks_test = @hooks_test
|
|
60
|
+
@hooks_test.before(:action) do |a, b|
|
|
61
|
+
self.should.be.instance_of hooks_test
|
|
62
|
+
a.should.equal 1
|
|
63
|
+
b.should.equal 2
|
|
64
|
+
:action_before1
|
|
65
|
+
end
|
|
66
|
+
@hooks_test.before(:action) do |a, b|
|
|
67
|
+
:action_before2
|
|
68
|
+
end
|
|
69
|
+
@hooks_test.after(:action) do |a, b|
|
|
70
|
+
:action_after
|
|
71
|
+
end
|
|
72
|
+
result = @hooks_test.new.with_hooks(:action, 1, 2) do
|
|
73
|
+
:action
|
|
74
|
+
end
|
|
75
|
+
result.should.be.instance_of Array
|
|
76
|
+
result.should.equal [:action_before1, :action_before2, :action, :action_after]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'should have hook priority' do
|
|
80
|
+
@hooks_test.hook(:ping, 2) { :hook1 }
|
|
81
|
+
@hooks_test.hook(:ping, 1) { :hook2 }
|
|
82
|
+
@hooks_test.hook(:ping, 3) { :hook3 }
|
|
83
|
+
@hooks_test.new.invoke_hook(:ping).should.equal [:hook2, :hook1, :hook3]
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'olelo/extensions'
|
|
2
|
+
require 'olelo/util'
|
|
3
|
+
|
|
4
|
+
describe 'Object extensions' do
|
|
5
|
+
it 'should have #blank?' do
|
|
6
|
+
''.should.be.blank
|
|
7
|
+
{}.should.be.blank
|
|
8
|
+
[].should.be.blank
|
|
9
|
+
nil.should.be.blank
|
|
10
|
+
'foo'.should.not.be.blank
|
|
11
|
+
!{42=>'answer'}.should.not.be.blank
|
|
12
|
+
[42].should.not.be.blank
|
|
13
|
+
42.should.not.be.blank
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should have #try' do
|
|
17
|
+
nil.try(:succ).should.be.nil
|
|
18
|
+
1.try(:succ).should.equal 2
|
|
19
|
+
end
|
|
20
|
+
end
|
data/test/page_test.rb
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe 'Olelo::Page' do
|
|
4
|
+
before { create_repository }
|
|
5
|
+
after { destroy_repository }
|
|
6
|
+
|
|
7
|
+
it 'check for path validity' do
|
|
8
|
+
lambda do
|
|
9
|
+
Olelo::Page.check_path(' spaces ')
|
|
10
|
+
end.should.raise RuntimeError
|
|
11
|
+
Olelo::Page.check_path('spaces in the path')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should have no root before the first page is created' do
|
|
15
|
+
Olelo::Page.find('').should.equal nil
|
|
16
|
+
create_page('Home')
|
|
17
|
+
Olelo::Page.find('').should.be.an.instance_of Olelo::Page
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'find or raise' do
|
|
21
|
+
lambda { Olelo::Page.find!('') }.should.raise Olelo::NotFound
|
|
22
|
+
create_page('Home')
|
|
23
|
+
Olelo::Page.find('').should.be.an.instance_of Olelo::Page
|
|
24
|
+
Olelo::Page.find('Home').should.be.an.instance_of Olelo::Page
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should be new' do
|
|
28
|
+
create_page('Home')
|
|
29
|
+
Olelo::Page.find('Home').should.not.be.new
|
|
30
|
+
Olelo::Page.find('').should.not.be.new
|
|
31
|
+
Olelo::Page.new('new').should.be.new
|
|
32
|
+
Olelo::Page.new('new').should.be.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'has name' do
|
|
36
|
+
Olelo::Page.new('/path/name.ext').name.should.equal 'name.ext'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'has path' do
|
|
40
|
+
Olelo::Page.new('/path/name.ext').path.should.equal 'path/name.ext'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should have correct path' do
|
|
44
|
+
Olelo::Page.new('/path/name.ext').path.should.equal 'path/name.ext'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should have correct extension' do
|
|
48
|
+
Olelo::Page.new('/path/name.tar.gz').extension.should.equal 'tar.gz'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'write content' do
|
|
52
|
+
page = Olelo::Page.new('test')
|
|
53
|
+
page.should.be.new
|
|
54
|
+
page.should.not.be.modified
|
|
55
|
+
page.content.should.equal ''
|
|
56
|
+
Olelo::Page.transaction do
|
|
57
|
+
page.content = 'old content'
|
|
58
|
+
page.save
|
|
59
|
+
Olelo::Page.commit "comment1\ntext"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
page.content.should.equal 'old content'
|
|
63
|
+
page.should.not.be.new
|
|
64
|
+
page.should.not.be.modified
|
|
65
|
+
|
|
66
|
+
page.tree_version.comment.should.equal "comment1\ntext"
|
|
67
|
+
|
|
68
|
+
page.content = 'new content'
|
|
69
|
+
page.should.not.be.new
|
|
70
|
+
page.should.be.modified
|
|
71
|
+
page.content.should.equal 'new content'
|
|
72
|
+
Olelo::Page.transaction do
|
|
73
|
+
page.content = 'new content'
|
|
74
|
+
page.save
|
|
75
|
+
Olelo::Page.commit 'comment2'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
page.tree_version.comment.should.equal 'comment2'
|
|
79
|
+
|
|
80
|
+
page = Olelo::Page.find!('test')
|
|
81
|
+
page.should.not.be.new
|
|
82
|
+
page.content.should.equal 'new content'
|
|
83
|
+
|
|
84
|
+
page.tree_version.comment.should.equal 'comment2'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'fail on duplicates' do
|
|
88
|
+
Olelo::Page.transaction do
|
|
89
|
+
page = Olelo::Page.new('test')
|
|
90
|
+
page.content = 'content'
|
|
91
|
+
page.save
|
|
92
|
+
Olelo::Page.commit 'comment'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
lambda do
|
|
96
|
+
Olelo::Page.transaction do
|
|
97
|
+
page = Olelo::Page.new('test')
|
|
98
|
+
page.content = 'content'
|
|
99
|
+
page.save
|
|
100
|
+
Olelo::Page.commit 'comment'
|
|
101
|
+
end
|
|
102
|
+
end.should.raise RuntimeError
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should have children' do
|
|
106
|
+
create_page('page1')
|
|
107
|
+
create_page('page2')
|
|
108
|
+
create_page('page3')
|
|
109
|
+
|
|
110
|
+
tree = Olelo::Page.find!('/')
|
|
111
|
+
tree.tree_version.should.be.head
|
|
112
|
+
|
|
113
|
+
tree.tree_version.should.equal tree.children[0].tree_version
|
|
114
|
+
tree.tree_version.should.equal tree.children[1].tree_version
|
|
115
|
+
tree.tree_version.should.equal tree.children[2].tree_version
|
|
116
|
+
tree.children[0].tree_version.should.be.head
|
|
117
|
+
tree.children[1].tree_version.should.be.head
|
|
118
|
+
tree.children[2].tree_version.should.be.head
|
|
119
|
+
|
|
120
|
+
old_tree = Olelo::Page.find('/', tree.previous_version)
|
|
121
|
+
old_tree.tree_version.should.not.be.head
|
|
122
|
+
tree.previous_version.should.equal old_tree.tree_version
|
|
123
|
+
old_tree.tree_version.should.equal old_tree.children[0].tree_version
|
|
124
|
+
old_tree.tree_version.should.equal old_tree.children[1].tree_version
|
|
125
|
+
old_tree.tree_version.should.equal old_tree.children[2].tree_version
|
|
126
|
+
old_tree.children[0].tree_version.should.not.be.head
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'has working children' do
|
|
130
|
+
create_page('tree1/subpage1')
|
|
131
|
+
create_page('tree1/subpage2')
|
|
132
|
+
create_page('tree1/subpage3')
|
|
133
|
+
create_page('tree2/subpage1')
|
|
134
|
+
create_page('tree2/subpage2')
|
|
135
|
+
create_page('tree2/subpage3')
|
|
136
|
+
create_page('tree3/subpage1')
|
|
137
|
+
create_page('tree3/subpage2')
|
|
138
|
+
create_page('tree3/subpage3')
|
|
139
|
+
create_page('tree1/subtree1/subsubpage1')
|
|
140
|
+
create_page('tree1/subtree1/subsubpage2')
|
|
141
|
+
create_page('tree1/subtree1/subsubpage3')
|
|
142
|
+
create_page('page1')
|
|
143
|
+
create_page('page2')
|
|
144
|
+
create_page('page3')
|
|
145
|
+
|
|
146
|
+
tree = Olelo::Page.find!('/')
|
|
147
|
+
tree.children.size.should.equal 6
|
|
148
|
+
tree.children[0].path.should.equal 'page1'
|
|
149
|
+
tree.children[1].path.should.equal 'page2'
|
|
150
|
+
tree.children[2].path.should.equal 'page3'
|
|
151
|
+
tree.children[3].path.should.equal 'tree1'
|
|
152
|
+
tree.children[4].path.should.equal 'tree2'
|
|
153
|
+
tree.children[5].path.should.equal 'tree3'
|
|
154
|
+
|
|
155
|
+
tree = Olelo::Page.find!('/tree1')
|
|
156
|
+
tree.children.size.should.equal 4
|
|
157
|
+
tree.children[0].path.should.equal 'tree1/subpage1'
|
|
158
|
+
tree.children[1].path.should.equal 'tree1/subpage2'
|
|
159
|
+
tree.children[2].path.should.equal 'tree1/subpage3'
|
|
160
|
+
tree.children[3].path.should.equal 'tree1/subtree1'
|
|
161
|
+
|
|
162
|
+
tree = Olelo::Page.find!('/tree1/subtree1')
|
|
163
|
+
tree.children.size.should.equal 3
|
|
164
|
+
tree.children[0].path.should.equal 'tree1/subtree1/subsubpage1'
|
|
165
|
+
tree.children[1].path.should.equal 'tree1/subtree1/subsubpage2'
|
|
166
|
+
tree.children[2].path.should.equal 'tree1/subtree1/subsubpage3'
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
require 'olelo/middleware/flash'
|
|
3
|
+
require 'olelo/middleware/force_encoding'
|
|
4
|
+
require 'rack/session/pool'
|
|
5
|
+
|
|
6
|
+
Rack::MockRequest::DEFAULT_ENV['REMOTE_ADDR'] = 'localhorst'
|
|
7
|
+
|
|
8
|
+
class Bacon::Context
|
|
9
|
+
include Rack::Test::Methods
|
|
10
|
+
include Olelo::Util
|
|
11
|
+
|
|
12
|
+
attr_reader :app
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'requests' do
|
|
16
|
+
before do
|
|
17
|
+
@test_path = File.expand_path(File.join(File.dirname(__FILE__), '.test'))
|
|
18
|
+
@app_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
19
|
+
|
|
20
|
+
default_config = {
|
|
21
|
+
:title => 'Olelo',
|
|
22
|
+
:app_path => @app_path,
|
|
23
|
+
:plugins_path => File.join(@app_path, 'plugins'),
|
|
24
|
+
:config_path => File.join(@app_path, 'config'),
|
|
25
|
+
:initializers_path => File.join(@app_path, 'config', 'initializers'),
|
|
26
|
+
:views_path => File.join(@app_path, 'views'),
|
|
27
|
+
:themes_path => File.join(@app_path, 'static', 'themes'),
|
|
28
|
+
:theme => 'atlantis',
|
|
29
|
+
:cache_store => {
|
|
30
|
+
:type => 'file',
|
|
31
|
+
:file => {
|
|
32
|
+
:root => File.join(@test_path, 'cache')
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
:base_path => '/',
|
|
36
|
+
:production => true,
|
|
37
|
+
:locale => 'en_US',
|
|
38
|
+
:sidebar_page => 'Sidebar',
|
|
39
|
+
:authentication => {
|
|
40
|
+
:service => :yamlfile,
|
|
41
|
+
:enable_signup => true,
|
|
42
|
+
:yamlfile => {
|
|
43
|
+
:store => File.join(@test_path, 'users.yml'),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
:mime => [
|
|
47
|
+
'extension',
|
|
48
|
+
'content',
|
|
49
|
+
'text/x-creole',
|
|
50
|
+
],
|
|
51
|
+
:mime_suggestions => [],
|
|
52
|
+
:disabled_plugins => [
|
|
53
|
+
'security/readonly_wiki',
|
|
54
|
+
'security/private_wiki',
|
|
55
|
+
'editor/antispam',
|
|
56
|
+
],
|
|
57
|
+
:repository => {
|
|
58
|
+
:type => 'git',
|
|
59
|
+
:git => {
|
|
60
|
+
:path => File.join(@test_path, 'repository'),
|
|
61
|
+
:bare => true,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Olelo::Config.instance.update(default_config)
|
|
67
|
+
Olelo::Repository.instance = nil
|
|
68
|
+
|
|
69
|
+
logger = Logger.new(File.join(@app_path, 'test.log'))
|
|
70
|
+
|
|
71
|
+
@app = Rack::Builder.new do
|
|
72
|
+
use Olelo::Middleware::ForceEncoding
|
|
73
|
+
use Rack::Session::Pool
|
|
74
|
+
use Olelo::Middleware::Flash, :set_accessors => %w(error warn info)
|
|
75
|
+
Olelo::Initializer.initialize(logger)
|
|
76
|
+
run Olelo::Application.new
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
after do
|
|
81
|
+
FileUtils.rm_rf(@test_path)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'should have empty repository' do
|
|
85
|
+
get '/'
|
|
86
|
+
last_response.should.be.redirect
|
|
87
|
+
last_response.location.should.equal '/new'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'should show login page' do
|
|
91
|
+
get '/login'
|
|
92
|
+
last_response.should.be.ok
|
|
93
|
+
last_response.body.should.include '<form action="/signup" method="post">'
|
|
94
|
+
last_response.body.should.include '<form action="/login" method="post">'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should show to /new' do
|
|
98
|
+
get '/new/not-existing'
|
|
99
|
+
last_response.should.be.ok
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should redirect to /new' do
|
|
103
|
+
get '/not-existing'
|
|
104
|
+
last_response.should.be.redirect
|
|
105
|
+
last_response.location.should.equal '/new/not-existing'
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'should not redirect to /new' do
|
|
109
|
+
get '/edit/not-existing'
|
|
110
|
+
last_response.should.be.not_found
|
|
111
|
+
|
|
112
|
+
get '/history/not-existing'
|
|
113
|
+
last_response.should.be.not_found
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'should create page' do
|
|
117
|
+
data = {
|
|
118
|
+
'action' => 'edit-close',
|
|
119
|
+
'content' => 'Content of the Testpage',
|
|
120
|
+
'comment' => 'My Comment'
|
|
121
|
+
}
|
|
122
|
+
post '/Testfolder/Testpage', data
|
|
123
|
+
|
|
124
|
+
last_response.should.be.redirect
|
|
125
|
+
last_response.location.should.equal '/Testfolder/Testpage'
|
|
126
|
+
|
|
127
|
+
get '/'
|
|
128
|
+
last_response.should.be.ok
|
|
129
|
+
|
|
130
|
+
get '/Testfolder/Testpage'
|
|
131
|
+
last_response.should.be.ok
|
|
132
|
+
last_response.body.should.include '<h1>Testpage</h1>'
|
|
133
|
+
last_response.body.should.include 'Content of the Testpage'
|
|
134
|
+
|
|
135
|
+
get '/history/Testfolder/Testpage'
|
|
136
|
+
last_response.should.be.ok
|
|
137
|
+
last_response.body.should.include 'My Comment'
|
|
138
|
+
|
|
139
|
+
get '/edit/Testfolder/Testpage'
|
|
140
|
+
last_response.should.be.ok
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it 'should create page with special characters' do
|
|
144
|
+
data = {
|
|
145
|
+
'action' => 'edit-close',
|
|
146
|
+
'content' => "\343\201\231\343\201\277\343\201\276\343\201\233\343\202\223\343\202\217\343\201\213\343\202\212\343\201\276\343\201\233\343\202\223",
|
|
147
|
+
'comment' => "\346\265\213\350\257\225",
|
|
148
|
+
}
|
|
149
|
+
post '/%E5%AD%90%E4%BE%9B%E3%82%92%E5%85%AC%E5%9C%92/%E4%B8%AD%E6%96%87', data
|
|
150
|
+
last_response.should.be.redirect
|
|
151
|
+
|
|
152
|
+
loc1, loc2 = '', ''
|
|
153
|
+
last_response.location.each_byte {|c| loc1 << c}
|
|
154
|
+
unescape('/%E5%AD%90%E4%BE%9B%E3%82%92%E5%85%AC%E5%9C%92/%E4%B8%AD%E6%96%87').each_byte {|c| loc2 << c }
|
|
155
|
+
loc1.should.equal loc2
|
|
156
|
+
|
|
157
|
+
get '/%E5%AD%90%E4%BE%9B%E3%82%92%E5%85%AC%E5%9C%92/%E4%B8%AD%E6%96%87'
|
|
158
|
+
last_response.should.be.ok
|
|
159
|
+
|
|
160
|
+
get '/history/%E5%AD%90%E4%BE%9B%E3%82%92%E5%85%AC%E5%9C%92/%E4%B8%AD%E6%96%87'
|
|
161
|
+
last_response.should.be.ok
|
|
162
|
+
|
|
163
|
+
get '/edit/%E5%AD%90%E4%BE%9B%E3%82%92%E5%85%AC%E5%9C%92/%E4%B8%AD%E6%96%87'
|
|
164
|
+
last_response.should.be.ok
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'olelo/extensions'
|
|
2
|
+
|
|
3
|
+
describe 'String extensions' do
|
|
4
|
+
it 'should have unindent' do
|
|
5
|
+
%{a
|
|
6
|
+
b
|
|
7
|
+
c}.unindent.should.equal "a\nb\nc"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should have #starts_with?' do
|
|
11
|
+
'123456789'.starts_with?('12').should.equal true
|
|
12
|
+
'123456789'.starts_with?('23').should.not.equal true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should have #ends_with?' do
|
|
16
|
+
'123456789'.ends_with?('89').should.equal true
|
|
17
|
+
'123456789'.ends_with?('98').should.not.equal true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'should have #cleanpath' do
|
|
21
|
+
'/'.cleanpath.should.equal ''
|
|
22
|
+
'/a/b/c/../'.cleanpath.should.equal 'a/b'
|
|
23
|
+
'/a/./b/../c/../d/./'.cleanpath.should.equal 'a/d'
|
|
24
|
+
'1///2'.cleanpath.should.equal '1/2'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should have #/' do
|
|
28
|
+
(''/'').should.equal ''
|
|
29
|
+
('//a/b///'/'').should.equal 'a/b'
|
|
30
|
+
('a'/'x'/'..'/'b'/'c'/'.').should.equal 'a/b/c'
|
|
31
|
+
end
|
|
32
|
+
end
|