clwiki 2.0.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/LICENSE +31 -0
- data/Rakefile +53 -0
- data/app/assets/javascripts/cl_wiki/application.js +29 -0
- data/app/assets/stylesheets/cl_wiki/application.css +103 -0
- data/app/controllers/cl_wiki/application_controller.rb +4 -0
- data/app/controllers/cl_wiki/page_controller.rb +106 -0
- data/app/helpers/cl_wiki/application_helper.rb +4 -0
- data/app/views/cl_wiki/page/edit.html.erb +8 -0
- data/app/views/cl_wiki/page/find.html.erb +27 -0
- data/app/views/cl_wiki/page/recent.html.erb +4 -0
- data/app/views/cl_wiki/page/recent.rss.builder +18 -0
- data/app/views/cl_wiki/page/show.html.erb +1 -0
- data/app/views/layouts/cl_wiki/application.html.erb +14 -0
- data/config/clwiki.yml +73 -0
- data/config/initializers/clwiki.rb +9 -0
- data/config/routes.rb +15 -0
- data/lib/cl_wiki.rb +12 -0
- data/lib/cl_wiki/configuration.rb +171 -0
- data/lib/cl_wiki/engine.rb +5 -0
- data/lib/cl_wiki/file.rb +171 -0
- data/lib/cl_wiki/find_in_file.rb +33 -0
- data/lib/cl_wiki/format/format.blockquote.rb +15 -0
- data/lib/cl_wiki/format/format.graphviz.digraph.rb +16 -0
- data/lib/cl_wiki/format/format.opml.rb +105 -0
- data/lib/cl_wiki/format/format.pre.blockquote.rb +15 -0
- data/lib/cl_wiki/format/format.simpletable.rb +25 -0
- data/lib/cl_wiki/index.rb +455 -0
- data/lib/cl_wiki/page.rb +516 -0
- data/lib/cl_wiki/tools/cron.reminders.rb +241 -0
- data/lib/cl_wiki/tools/movepages.rb +27 -0
- data/lib/cl_wiki/tools/pagestomove.txt +56 -0
- data/lib/cl_wiki/tools/rublog/clWiki.rb +62 -0
- data/lib/cl_wiki/tools/rublog/readme.txt +2 -0
- data/lib/cl_wiki/tools/singlepage.rb +58 -0
- data/lib/cl_wiki/tools/test/singlepagetest.rb +9 -0
- data/lib/cl_wiki/tools/thunderbird.rb +23 -0
- data/lib/cl_wiki/version.rb +3 -0
- data/test/dummy/README.rdoc +259 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +37 -0
- data/test/dummy/config/boot.rb +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +34 -0
- data/test/dummy/config/environments/production.rb +81 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/locale.rb +7 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +1963 -0
- data/test/dummy/log/test.log +1340 -0
- data/test/dummy/public/404.html +27 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/17ea26cbf693e610505bdc24be534847 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1883f3d938430da389005555d27c0bad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1b9132b83b822937e80ef987f7da1760 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/259fb44b87b29348087957b4937a1953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/37f8e4f0491b6401433af823dfb471d9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/48d7a2c40083020f9e7d97d4d73f26fa +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4b0bfb6eb9d6983eb9defa58dd96dae4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4da11f1195532cd7b80f2dde7cf843d5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/57347ee373d74c87e1515a059c701085 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/61b40e54192bf61d97ce2aef71e7d694 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/633b01c5a65fcd6457baf30d1cc94148 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ad8bb345cc43acfca78c043b7bfefae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/87a335a43cb68a253dea2b6c0269a4d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8a38b2f4390e68175dae4b4b1c144e2e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8ddc1a668acec35c2707ebc47768f59c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8f5ab7b6f73a1e9f16421b299134e39a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9835aec4bc0277b8f02d0e86c977fdba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ae4f771558859f9c120a0f22328e8521 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/afed0eaa6fcf7a263498a08a5cc02cf0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/be786e5567855cdc6817603725fd1b8d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bf9b02df32690fb2a936818715d611f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c2bf9d91a6a2786263b9912b948f435d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ce4c918439a53cb89d02313ed990d5de +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d9c791f08c547f30854ad746a89b0bb5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ddc3a7b5173ff5c911a53004b56e4305 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dfed1391742203d15f08cb07173bccba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e282b6bdaa0e070754f8558b9de5e417 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f0e957c30443ade693f73ff470f0f894 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f6b3cbb9c04d5af74d780464c9a34ee5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fb41fedee86fd2d10ddd938bf5d68eb7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1883f3d938430da389005555d27c0bad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/48d7a2c40083020f9e7d97d4d73f26fa +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/61b40e54192bf61d97ce2aef71e7d694 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8f5ab7b6f73a1e9f16421b299134e39a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9835aec4bc0277b8f02d0e86c977fdba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ae4f771558859f9c120a0f22328e8521 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/be786e5567855cdc6817603725fd1b8d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c2bf9d91a6a2786263b9912b948f435d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ce4c918439a53cb89d02313ed990d5de +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e282b6bdaa0e070754f8558b9de5e417 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f0e957c30443ade693f73ff470f0f894 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f6b3cbb9c04d5af74d780464c9a34ee5 +0 -0
- data/test/dummy/tmp/testrep/FooBar.txt +1 -0
- data/test/dummy/tmp/testrep/FrontPage.txt +1 -0
- data/test/dummy/tmp/testrep/QuuxBaz.txt +1 -0
- data/test/dummy/wikirep/AboutClWiki.txt +31 -0
- data/test/dummy/wikirep/ChrisMorris.txt +4 -0
- data/test/dummy/wikirep/DotTest.txt +6 -0
- data/test/dummy/wikirep/FooBar.txt +4 -0
- data/test/dummy/wikirep/FooBarQuux.txt +4 -0
- data/test/dummy/wikirep/FrontPage.txt +14 -0
- data/test/dummy/wikirep/HtmlAreaTest.txt +4 -0
- data/test/dummy/wikirep/PreTagsTest.txt +27 -0
- data/test/dummy/wikirep/TheMan.txt +4 -0
- data/test/helpers/wiki_helper_test.rb +4 -0
- data/test/lib/clwiki/clwiki_test_helper.rb +3 -0
- data/test/lib/clwiki/file_test.rb +93 -0
- data/test/lib/clwiki/find_in_file_test.rb +111 -0
- data/test/lib/clwiki/index_test.rb +32 -0
- data/test/lib/clwiki/page_test.rb +239 -0
- data/test/lib/clwiki/test_base.rb +25 -0
- data/test/test_helper.rb +15 -0
- metadata +312 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
<p>If you are the application owner check the logs for more information.</p>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
<p>If you are the application owner check the logs for more information.</p>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
Describe FooBar here.
|
@@ -0,0 +1 @@
|
|
1
|
+
Describe FrontPage here.
|
@@ -0,0 +1 @@
|
|
1
|
+
Describe QuuxBaz here.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
mtime: 2013-01-20
|
2
|
+
|
3
|
+
|
4
|
+
If you're used to a more popular wiki, you'll probably be longing for some features that I've managed to do without myself.
|
5
|
+
|
6
|
+
<b>Markup</b> is basic html. Typical wiki things like asterisked lists, indentation, urls being automagically formatted ain't in here.
|
7
|
+
|
8
|
+
One quirky bit has made it into clWiki, that is the simpletable tag. Look at the source here to see it in action:
|
9
|
+
|
10
|
+
<blockquote>
|
11
|
+
<simpletable>
|
12
|
+
ColA Col B Col C
|
13
|
+
x y z
|
14
|
+
u v w
|
15
|
+
</simpletable>
|
16
|
+
</blockquote>
|
17
|
+
|
18
|
+
A row is a single line of text. A column break is a tab character, two or more spaces or a horizontal bar.
|
19
|
+
|
20
|
+
As of 1.13.5, some new shorthand markup was added.
|
21
|
+
[]
|
22
|
+
[ and ] indicates the start of a blockquote section, and [ and ] with a slash in the middle will indicate the end. (see source of this page)
|
23
|
+
[p]
|
24
|
+
Add in a 'p' and that will indicate a blockquote/pre section with content auto-escaped. (see source of this page)
|
25
|
+
[/p]
|
26
|
+
(Obviously, it'd be nice to have a <raw> tag, or somesuch, to allow me to use [ and ] together.)
|
27
|
+
[/]
|
28
|
+
|
29
|
+
<b>WikiLinks</b> are pretty typical, though there's no special syntax for turning a non-camel-cased word into a link. To stop WikiLinks from being rendered, use a NoWikiLinks tag (closing tag to turn linking back on). <NoWikiLinks>FrontPage</NoWikiLinks> won't render, because the tag is turning it off.
|
30
|
+
|
31
|
+
The legacy CGI version of clWiki supported full hierarchy, but that's no longer supported.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
mtime: 2013-01-10
|
2
|
+
|
3
|
+
|
4
|
+
[p]
|
5
|
+
Version 1.13.1 or .2 introduced a change to ClWikiPage.convert_newline_to_br.
|
6
|
+
Previously, \n was converted to just <br>, but this left the resulting html
|
7
|
+
rather unreadable if you ever viewed the source.
|
8
|
+
|
9
|
+
This was changed to \n -> <br>\n, but this affected <pre> sections. Now every
|
10
|
+
line had <br> and \n and browsers (Mozilla, at least) would render two line
|
11
|
+
feeds instead of one.
|
12
|
+
|
13
|
+
1.13.3 changed this back and this text here is some testing.
|
14
|
+
|
15
|
+
Line One
|
16
|
+
Line Two
|
17
|
+
Line Three
|
18
|
+
|
19
|
+
This section is also testing the custom ClWiki tags for a blockquote/pre section.
|
20
|
+
[/p]
|
21
|
+
|
22
|
+
<pre>
|
23
|
+
This is a pure pre tag section.
|
24
|
+
|
25
|
+
Line One
|
26
|
+
Line Two
|
27
|
+
</pre>
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/clwiki_test_helper'
|
2
|
+
require 'file'
|
3
|
+
require File.dirname(__FILE__) + '/test_base'
|
4
|
+
|
5
|
+
class TestClWikiFile < TestBase
|
6
|
+
# refactor: shouldn't be dealing with page paths at this level, should be at
|
7
|
+
# the ClWikiPage level
|
8
|
+
def do_test_new_page(fullPageName)
|
9
|
+
fullPageName = ClWiki::Util.convertToNativePath(fullPageName)
|
10
|
+
fileName = File.expand_path(File.join(@test_wiki_path, fullPageName)) + '.txt'
|
11
|
+
File.delete(fileName) if FileTest.exists?(fileName)
|
12
|
+
wikiFile = ClWiki::File.new(fullPageName, @test_wiki_path)
|
13
|
+
assert(FileTest.exists?(wikiFile.fullPathAndName))
|
14
|
+
pagePath, pageName = File.split(fullPageName)
|
15
|
+
assert(wikiFile.name == pageName)
|
16
|
+
assert_equal(pagePath, wikiFile.pagePath)
|
17
|
+
assert(wikiFile.wikiRootPath == @test_wiki_path)
|
18
|
+
assert_equal(fileName, wikiFile.fullPathAndName)
|
19
|
+
assert_equal(["Describe " + pageName + " here."], wikiFile.content)
|
20
|
+
newWikiFile = ClWiki::File.new(fullPageName, @test_wiki_path)
|
21
|
+
assert_equal(["Describe " + pageName + " here."], newWikiFile.content)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_new_root_page
|
25
|
+
do_test_new_page('/NewPage')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_new_sub_page_forward_slash
|
29
|
+
do_test_new_page('/NewPage/NewSubPage')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_new_sub_page_back_slash
|
33
|
+
do_test_new_page("\\NewPage\\NewSubPage")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_update_page
|
37
|
+
wikiFile = ClWiki::File.new("/UpdatePage", @test_wiki_path)
|
38
|
+
assert_equal(["Describe UpdatePage here."], wikiFile.content)
|
39
|
+
|
40
|
+
# this test looks ridiculous, but ClWiki::File actually does a write to disk
|
41
|
+
# and re-read from the file behind the scenes here.
|
42
|
+
# refactor rename?
|
43
|
+
wikiFile.content = "This is new content."
|
44
|
+
assert_equal(["This is new content."], wikiFile.content)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_multi_user_edit
|
48
|
+
# this can happen if 2 people load a page, then both edit the page - the last one
|
49
|
+
# to submit would stomp the first edit ... unless:
|
50
|
+
wiki_file_a = ClWiki::File.new("/UpdatePage", @test_wiki_path)
|
51
|
+
wiki_file_b = ClWiki::File.new("/UpdatePage", @test_wiki_path)
|
52
|
+
assert_equal(["Describe UpdatePage here."], wiki_file_a.content)
|
53
|
+
assert_equal(["Describe UpdatePage here."], wiki_file_b.content)
|
54
|
+
|
55
|
+
sleep 2.5 # to ensure mtime changes. (lesser time sometimes doesn't work)
|
56
|
+
wiki_file_a.content = "This is new A content."
|
57
|
+
begin
|
58
|
+
wiki_file_b.content = "This is new B content."
|
59
|
+
assert(false, "Expected exception did not occur.")
|
60
|
+
rescue ClWiki::FileModifiedSinceRead
|
61
|
+
# don do anythain, issa wha shoo 'appen
|
62
|
+
end
|
63
|
+
|
64
|
+
wiki_file_b.readFile
|
65
|
+
assert_equal(["This is new A content."], wiki_file_b.content)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_multi_user_edit_dst
|
69
|
+
# running into a problem where I can't edit a page that was last edited outside
|
70
|
+
# of DST when I'm in DST ... it raises ClWiki::FileModifiedSinceRead
|
71
|
+
wiki_file = ClWiki::File.new("/UpdateDstPage", @test_wiki_path)
|
72
|
+
def wiki_file.ding_mtime
|
73
|
+
@metadata['mtime'] = Time.local(2011, 'jan', 1)
|
74
|
+
end
|
75
|
+
wiki_file.content = 'New content'
|
76
|
+
|
77
|
+
wiki_file_read = ClWiki::File.new("/UpdateDstPage", @test_wiki_path)
|
78
|
+
def wiki_file_read.ding_mtime
|
79
|
+
@metadata['mtime'] = Time.local(2011, 'jun', 1)
|
80
|
+
end
|
81
|
+
wiki_file_read.content = "This is new A content."
|
82
|
+
assert_equal(["This is new A content."], wiki_file_read.content)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_mtime_metadata
|
86
|
+
# the mtime of the file can be optionally stored as meta data at the top of the file
|
87
|
+
wiki_file = ClWiki::File.new("/PageWithMetaData", @test_wiki_path)
|
88
|
+
file_lines = File.readlines(wiki_file.fullPathAndName)
|
89
|
+
assert_match /^mtime: .+$/, file_lines[0]
|
90
|
+
assert_equal "\n", file_lines[1]
|
91
|
+
assert_equal "\n", file_lines[2]
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/clwiki_test_helper'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'clutil'
|
5
|
+
require 'cl/util/test'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
require 'find_in_file'
|
9
|
+
|
10
|
+
class TestFindInFile < TempDirTest
|
11
|
+
def set_temp_dir
|
12
|
+
@temp_dir = '/tmp/clwiki'
|
13
|
+
@test_wiki_path = @temp_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
@find_path = @test_wiki_path
|
19
|
+
@find_in_file = ClWiki::FindInFile.new(@find_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_test_file(filename, content)
|
23
|
+
File.open(filename, 'w') do |f|
|
24
|
+
f.puts(content)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_initialization
|
29
|
+
assert_equal(@find_path, @find_in_file.find_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_simple_find_content
|
33
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
34
|
+
assert_equal(1, @find_in_file.find('only'))
|
35
|
+
assert_equal(1, @find_in_file.files.length)
|
36
|
+
assert_equal('TestA', @find_in_file.files[0])
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_simple_find_filename
|
40
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
41
|
+
assert_equal(1, @find_in_file.find('tA'))
|
42
|
+
assert_equal(1, @find_in_file.files.length)
|
43
|
+
assert_equal('TestA', @find_in_file.files[0])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_simple_find_content_case_insensitive
|
47
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
48
|
+
assert_equal(1, @find_in_file.find('oNly'))
|
49
|
+
assert_equal(1, @find_in_file.files.length)
|
50
|
+
assert_equal('TestA', @find_in_file.files[0])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_simple_find_filename_case_insensitive
|
54
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
55
|
+
assert_equal(1, @find_in_file.find('Ta'))
|
56
|
+
assert_equal(1, @find_in_file.files.length)
|
57
|
+
assert_equal('TestA', @find_in_file.files[0])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_match_in_file_name_and_content
|
61
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
62
|
+
assert_equal(1, @find_in_file.find('test'))
|
63
|
+
assert_equal(1, @find_in_file.files.length)
|
64
|
+
assert_equal('TestA', @find_in_file.files[0])
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_subdir_search
|
68
|
+
FileUtils.makedirs(@test_wiki_path + '/subdir')
|
69
|
+
create_test_file(@test_wiki_path + '/TestA.txt', 'this is only a test')
|
70
|
+
assert_equal(1, @find_in_file.find('test'))
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_title_only_search
|
74
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
75
|
+
create_test_file(@test_wiki_path + '/blah', 'this is only a test')
|
76
|
+
assert_equal(1, @find_in_file.find('test', ClWiki::FindInFile::FILE_NAME_ONLY))
|
77
|
+
assert_equal(1, @find_in_file.files.length)
|
78
|
+
assert_equal('TestA', @find_in_file.files[0])
|
79
|
+
end
|
80
|
+
|
81
|
+
def xtest_mini_load_test
|
82
|
+
create_test_file(@test_wiki_path + '/TestA', 'this is only a test')
|
83
|
+
content = ''
|
84
|
+
1000.times do
|
85
|
+
content << 'this is a sample file'
|
86
|
+
end
|
87
|
+
100.times do |x|
|
88
|
+
create_test_file(@test_wiki_path + '/Test' + x.to_s, content)
|
89
|
+
end
|
90
|
+
start = Time.now
|
91
|
+
assert_equal(1, @find_in_file.find('only'))
|
92
|
+
stop = Time.now
|
93
|
+
puts "find one file in 101"
|
94
|
+
puts stop - start
|
95
|
+
|
96
|
+
start = Time.now
|
97
|
+
assert_equal(100, @find_in_file.find('sample'))
|
98
|
+
stop = Time.now
|
99
|
+
puts "find 100 file in 101"
|
100
|
+
print stop - start
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_recursive
|
104
|
+
subdir = File.join(@test_wiki_path, '/subdir')
|
105
|
+
FileUtils.makedirs(subdir)
|
106
|
+
create_test_file(File.join(subdir, '/TestA.txt'), 'this is only a test')
|
107
|
+
assert_equal(1, @find_in_file.find('Ta'))
|
108
|
+
assert_equal(1, @find_in_file.files.length)
|
109
|
+
assert_equal('subdir/TestA.txt', @find_in_file.files[0])
|
110
|
+
end
|
111
|
+
end
|