Soks 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +7 -3
- data/README.txt +16 -21
- data/bin/soks-create-wiki.rb +3 -2
- data/contrib/redcloth-2.0.11.rb +1 -1
- data/lib/soks-helpers.rb +7 -4
- data/lib/soks-model.rb +17 -9
- data/lib/soks-storage.rb +55 -72
- data/lib/soks-view.rb +32 -87
- data/templates/default/attachment/stylesheet.css +7 -0
- data/templates/default/content/All%20News.textile +9 -0
- data/templates/default/content/Author.textile +12 -0
- data/templates/default/content/Automatic%20Summaries.textile +77 -0
- data/templates/default/content/Automatic%20linking%20between%20pages.textile +5 -0
- data/templates/default/content/Bug%3A%20Automatic%20link%20links%20to%20stuff%20inside%20%3Chtml.textile +1 -0
- data/templates/default/content/Bug%3A%20Does%20not%20make%20use%20of%20if%2Dmodified%2Dsince%20r.textile +1 -0
- data/templates/default/content/Bug%3A%20Duplicate%20links%2Dto%20a%20page%20sometimes%20appear.textile +1 -0
- data/templates/default/content/Bug%3A%20External%20links%20incorrectly%20include%20trailing%20pu.textile +1 -0
- data/templates/default/content/Bug%3A%20GEM%20limits%20title%20lengths.textile +1 -0
- data/templates/default/content/Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20link%20is%2.textile +1 -0
- data/templates/default/content/Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%20new%20.textile +1 -0
- data/templates/default/content/Bug%3A%20No%20robots%2Etxt%20or%20favicon%2Eico.textile +1 -0
- data/templates/default/content/Bug%3A%20Page%20titles%20cannot%20have%20html%20tags%20in%20them.textile +1 -0
- data/templates/default/content/Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%28not%20.textile +1 -0
- data/templates/default/content/Bug%3A%20Search%20box%20width%20does%20not%20match%20column%20wid.textile +1 -0
- data/templates/default/content/Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +1 -0
- data/templates/default/content/Bug%3A%20Symbols%20are%20not%20always%20correctly%20rendered%20in.textile +1 -0
- data/templates/default/content/{Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20link%20is%20sometimes%20not%20linked.textile → Fixed%20Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20lin.textile} +3 -0
- data/templates/default/content/Fixed%20Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%.textile +9 -0
- data/templates/default/content/Fixed%20Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%.textile +15 -0
- data/templates/default/content/Fixed%20Bug%3A%20Search%20box%20width%20does%20not%20match%20colu.textile +3 -0
- data/templates/default/content/Fixed%20Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +3 -0
- data/templates/default/content/{Bug%3A%20Symbols%20are%20not%20always%20correctly%20rendered%20in%20html.textile → Fixed%20Bug%3A%20Symbols%20are%20not%20always%20correctly%20rende.textile} +2 -0
- data/templates/default/content/Home%20Page.textile +19 -0
- data/templates/default/content/How%20to%20hack%20soks.textile +1 -1
- data/templates/default/content/How%20to%20install%20Soks.textile +27 -0
- data/templates/default/content/How%20to%20use%20the%20keyboard%20shortcuts.textile +13 -0
- data/templates/default/content/How%20to%20use%20this%20wiki.textile +2 -2
- data/templates/default/content/Instructions%20and%20Howtos.textile +17 -0
- data/templates/default/content/Known%20bugs.textile +16 -0
- data/templates/default/content/Latest%20News.textile +9 -0
- data/templates/default/content/Picture%20of%20Type%20a%20title%20here.textile +1 -0
- data/templates/default/content/README.textile +61 -0
- data/templates/default/content/RSS%20feed.textile +7 -0
- data/templates/default/content/Recent%20Blog%20Entries.textile +5 -0
- data/templates/default/content/Recent%20Changes%20to%20This%20Site.textile +96 -0
- data/templates/default/content/Recent%20News.textile +9 -0
- data/templates/default/content/Ruby.textile +9 -0
- data/templates/default/content/SOKS%20features.textile +12 -0
- data/templates/default/content/Site%20Index.textile +55 -0
- data/templates/default/content/fixed%20bug%3A%20automatic%20link%20links%20to%20stuff%20inside%2.textile +3 -0
- data/templates/default/content/let%20me%20know.textile +1 -0
- data/templates/default/content/sandbox.textile +2 -0
- data/templates/default/content/tamc2.textile +1 -0
- data/templates/default/content/test%20page.textile +1 -0
- data/templates/default/start.rb +10 -4
- data/templates/default/version.txt +1 -1
- data/templates/default/views/Page_rss.rhtml +1 -1
- data/templates/default/views/frame.rhtml +3 -2
- data/templates/instiki/content/All%20News.textile +9 -0
- data/templates/instiki/content/Author.textile +12 -0
- data/templates/instiki/content/Automatic%20Summaries.textile +77 -0
- data/templates/instiki/content/Automatic%20linking%20between%20pages.textile +5 -0
- data/templates/instiki/content/Bug%3A%20Automatic%20link%20links%20to%20stuff%20inside%20%3Chtml.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Does%20not%20make%20use%20of%20if%2Dmodified%2Dsince%20r.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Duplicate%20links%2Dto%20a%20page%20sometimes%20appear.textile +1 -0
- data/templates/instiki/content/Bug%3A%20External%20links%20incorrectly%20include%20trailing%20pu.textile +1 -0
- data/templates/instiki/content/Bug%3A%20GEM%20limits%20title%20lengths.textile +1 -0
- data/templates/instiki/content/Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20link%20is%2.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%20new%20.textile +1 -0
- data/templates/instiki/content/Bug%3A%20No%20robots%2Etxt%20or%20favicon%2Eico.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Page%20titles%20cannot%20have%20html%20tags%20in%20them.textile +1 -0
- data/templates/instiki/content/Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%28not%20.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Search%20box%20width%20does%20not%20match%20column%20wid.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Symbols%20are%20not%20always%20correctly%20rendered%20in.textile +1 -0
- data/templates/instiki/content/Bug%3A%20Uploads%20are%20not%20password%20protected.textile +3 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20lin.textile +13 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%.textile +9 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%.textile +15 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20Search%20box%20width%20does%20not%20match%20colu.textile +3 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +3 -0
- data/templates/instiki/content/Fixed%20Bug%3A%20Symbols%20are%20not%20always%20correctly%20rende.textile +5 -0
- data/templates/instiki/content/Home%20Page.textile +19 -0
- data/templates/instiki/content/How%20to%20hack%20soks.textile +1 -1
- data/templates/instiki/content/How%20to%20install%20Soks.textile +27 -0
- data/templates/instiki/content/How%20to%20use%20the%20keyboard%20shortcuts.textile +13 -0
- data/templates/instiki/content/{Pointers%20on%20how%20to%20use%20this%20wiki.textile → How%20to%20use%20this%20wiki.textile} +2 -2
- data/templates/instiki/content/Instructions%20and%20Howtos.textile +17 -0
- data/templates/instiki/content/Known%20bugs.textile +14 -6
- data/templates/instiki/content/Latest%20News.textile +9 -0
- data/templates/instiki/content/List%20of%20changes.textile +2 -1
- data/templates/instiki/content/Picture%20of%20Type%20a%20title%20here.textile +1 -0
- data/templates/instiki/content/Picture%20of%20a%20pair%20of%20soks.textile +1 -1
- data/templates/instiki/content/README.textile +61 -0
- data/templates/instiki/content/RSS%20feed.textile +7 -0
- data/templates/instiki/content/Recent%20Blog%20Entries.textile +3 -1
- data/templates/instiki/content/Recent%20Changes%20to%20This%20Site.textile +95 -47
- data/templates/instiki/content/Recent%20News.textile +9 -0
- data/templates/instiki/content/Ruby.textile +9 -0
- data/templates/instiki/content/SOKS%20features.textile +12 -0
- data/templates/instiki/content/Site%20Index.textile +54 -15
- data/templates/instiki/content/fixed%20bug%3A%20automatic%20link%20links%20to%20stuff%20inside%2.textile +3 -0
- data/templates/instiki/content/let%20me%20know.textile +1 -0
- data/templates/instiki/content/sandbox.textile +2 -0
- data/templates/instiki/content/tamc2.textile +1 -0
- data/templates/instiki/content/test%20page.textile +1 -0
- data/templates/instiki/start.rb +27 -0
- data/templates/instiki/version.txt +1 -1
- data/templates/rails/content/All%20News.textile +9 -0
- data/templates/rails/content/Author.textile +12 -0
- data/templates/rails/content/Automatic%20Summaries.textile +77 -0
- data/templates/rails/content/Automatic%20linking%20between%20pages.textile +5 -0
- data/templates/rails/content/Bug%3A%20Automatic%20link%20links%20to%20stuff%20inside%20%3Chtml.textile +1 -0
- data/templates/rails/content/Bug%3A%20Does%20not%20make%20use%20of%20if%2Dmodified%2Dsince%20r.textile +1 -0
- data/templates/rails/content/Bug%3A%20Duplicate%20links%2Dto%20a%20page%20sometimes%20appear.textile +1 -0
- data/templates/rails/content/Bug%3A%20External%20links%20incorrectly%20include%20trailing%20pu.textile +1 -0
- data/templates/rails/content/Bug%3A%20GEM%20limits%20title%20lengths.textile +1 -0
- data/templates/rails/content/Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20link%20is%2.textile +1 -0
- data/templates/rails/content/Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%20new%20.textile +1 -0
- data/templates/rails/content/Bug%3A%20No%20robots%2Etxt%20or%20favicon%2Eico.textile +1 -0
- data/templates/rails/content/Bug%3A%20Page%20titles%20cannot%20have%20html%20tags%20in%20them.textile +1 -0
- data/templates/rails/content/Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%28not%20.textile +1 -0
- data/templates/rails/content/Bug%3A%20Search%20box%20width%20does%20not%20match%20column%20wid.textile +1 -0
- data/templates/rails/content/Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +1 -0
- data/templates/rails/content/Bug%3A%20Symbols%20are%20not%20always%20correctly%20rendered%20in.textile +1 -0
- data/templates/rails/content/Bug%3A%20Uploads%20are%20not%20password%20protected.textile +3 -0
- data/templates/rails/content/Fixed%20Bug%3A%20In%20a%20list%20of%20links%2C%20the%20last%20lin.textile +13 -0
- data/templates/rails/content/Fixed%20Bug%3A%20Inserted%20pages%20are%20not%20refreshed%20when%.textile +9 -0
- data/templates/rails/content/Fixed%20Bug%3A%20RSS%20feed%20shows%20oldest%2015%20revisions%20%.textile +15 -0
- data/templates/rails/content/Fixed%20Bug%3A%20Search%20box%20width%20does%20not%20match%20colu.textile +3 -0
- data/templates/rails/content/Fixed%20Bug%3A%20Site%20Index%20updates%20on%20every%20revision.textile +3 -0
- data/templates/rails/content/Fixed%20Bug%3A%20Symbols%20are%20not%20always%20correctly%20rende.textile +5 -0
- data/templates/rails/content/Home%20Page.textile +19 -0
- data/templates/rails/content/How%20to%20hack%20soks.textile +1 -1
- data/templates/rails/content/How%20to%20install%20Soks.textile +27 -0
- data/templates/rails/content/How%20to%20use%20the%20keyboard%20shortcuts.textile +13 -0
- data/templates/rails/content/{Pointers%20on%20how%20to%20use%20this%20wiki.textile → How%20to%20use%20this%20wiki.textile} +2 -2
- data/templates/rails/content/Instructions%20and%20Howtos.textile +17 -0
- data/templates/rails/content/Known%20bugs.textile +14 -6
- data/templates/rails/content/Latest%20News.textile +9 -0
- data/templates/rails/content/List%20of%20changes.textile +2 -1
- data/templates/rails/content/Picture%20of%20Type%20a%20title%20here.textile +1 -0
- data/templates/rails/content/Picture%20of%20a%20pair%20of%20soks.textile +1 -1
- data/templates/rails/content/README.textile +61 -0
- data/templates/rails/content/RSS%20feed.textile +7 -0
- data/templates/rails/content/Recent%20Blog%20Entries.textile +3 -1
- data/templates/rails/content/Recent%20Changes%20to%20This%20Site.textile +95 -47
- data/templates/rails/content/Recent%20News.textile +9 -0
- data/templates/rails/content/Ruby.textile +9 -0
- data/templates/rails/content/SOKS%20features.textile +12 -0
- data/templates/rails/content/Site%20Index.textile +54 -15
- data/templates/rails/content/fixed%20bug%3A%20automatic%20link%20links%20to%20stuff%20inside%2.textile +3 -0
- data/templates/rails/content/let%20me%20know.textile +1 -0
- data/templates/rails/content/sandbox.textile +2 -0
- data/templates/rails/content/tamc2.textile +1 -0
- data/templates/rails/content/test%20page.textile +1 -0
- data/templates/rails/start.rb +28 -0
- data/templates/rails/version.txt +1 -1
- metadata +132 -15
- data/templates/default/content/home%20page.textile +0 -17
- data/templates/instiki/content/AutomaticSummary.textile +0 -24
- data/templates/instiki/content/home%20page.textile +0 -23
- data/templates/rails/content/AutomaticSummary.textile +0 -24
- data/templates/rails/content/home%20page.textile +0 -23
- /data/templates/instiki/content/{Pointers%20on%20adjusting%20the%20settings.textile → How%20to%20administrate%20this%20wiki.textile} +0 -0
- /data/templates/instiki/content/{Improving%20the%20style%20of%20this%20wiki.textile → How%20to%20change%20the%20way%20this%20wiki%20looks.textile} +0 -0
- /data/templates/rails/content/{Pointers%20on%20adjusting%20the%20settings.textile → How%20to%20administrate%20this%20wiki.textile} +0 -0
- /data/templates/rails/content/{Improving%20the%20style%20of%20this%20wiki.textile → How%20to%20change%20the%20way%20this%20wiki%20looks.textile} +0 -0
data/LICENSE.txt
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
h1. Soks is licensed under the The Ruby License
|
2
2
|
|
3
3
|
Note: This licence applies to all that is contained in this distribution EXCEPT files within the contrib folder which may be under different licences.
|
4
4
|
|
5
|
-
Soks is copyrighted (c) 2004, 2005 free software by Thomas Counsell
|
5
|
+
Soks is copyrighted (c) 2004, 2005 free software by Thomas Counsell tamc@rubyforge.org.
|
6
|
+
|
7
|
+
<pre>
|
8
|
+
|
6
9
|
You can redistribute it and/or modify it under either the terms of the
|
7
10
|
GPL (see the file GPL), or the conditions below:
|
8
11
|
|
@@ -46,7 +49,7 @@ GPL (see the file GPL), or the conditions below:
|
|
46
49
|
are not written by the author, so that they are not under these terms.
|
47
50
|
|
48
51
|
For the list of those files and their copying conditions, see the
|
49
|
-
contrib
|
52
|
+
contrib directory.
|
50
53
|
|
51
54
|
5. The scripts and library files supplied as input to or produced as
|
52
55
|
output from the software do not automatically fall under the
|
@@ -58,3 +61,4 @@ GPL (see the file GPL), or the conditions below:
|
|
58
61
|
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
59
62
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
60
63
|
PURPOSE.
|
64
|
+
</pre>
|
data/README.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
SOKS: Another Ruby Wiki
|
2
|
-
|
1
|
+
h1. SOKS: Another Ruby Wiki
|
2
|
+
|
3
3
|
* This application is a Wiki (a system to allow the easy and collaborative editing of web pages).
|
4
4
|
* The project has been kindly hosted at http://rubyforge.org/projects/soks/
|
5
5
|
|
@@ -8,18 +8,17 @@ Quickstart:
|
|
8
8
|
2. soks-create-wiki.rb
|
9
9
|
3. http://localhost:8000
|
10
10
|
|
11
|
-
REQUIRES
|
12
|
-
|
13
|
-
* Ruby 1.8
|
11
|
+
h2. REQUIRES
|
12
|
+
|
13
|
+
* Ruby 1.8.2
|
14
14
|
* A number of additional libraries are contained in contrib.
|
15
15
|
|
16
|
-
AUTHOR
|
17
|
-
|
16
|
+
h2. AUTHOR
|
17
|
+
|
18
18
|
* This software is copyright (c) Thomas Counsell 2004, 2005. tamc@rubyforge.org
|
19
19
|
* It is licensed under the Ruby Licence, a liberal open source licence. See LICENCE for more details.
|
20
20
|
|
21
|
-
INSTALL
|
22
|
-
=======
|
21
|
+
h2. INSTALL
|
23
22
|
|
24
23
|
Preferably:
|
25
24
|
1. Install rubygems from http://rubyforge.org/projects/rubygems/
|
@@ -30,8 +29,7 @@ Alternatively
|
|
30
29
|
2. Unzip or untar it
|
31
30
|
3. Change into the soks directory
|
32
31
|
|
33
|
-
|
34
|
-
=====
|
32
|
+
h2. USE
|
35
33
|
|
36
34
|
execute soks-create-wiki.rb (will be in your path if installed by gems, otherwise ./bin/soks-create-wiki.rb from the soks directory)
|
37
35
|
This will create a folder called soks-wiki in the current directory and launch the wiki. Surfing to http://localhost:8000 to see it (it is initially accessible from localhost only)
|
@@ -40,8 +38,8 @@ To restart the wiki change into the soks-wiki directory and execute ruby start.r
|
|
40
38
|
|
41
39
|
To change the settings (url, port, etc) edit the start.rb file in the soks-wiki directory.
|
42
40
|
|
43
|
-
|
44
|
-
|
41
|
+
h2. FEATURES
|
42
|
+
|
45
43
|
1. Runs on its own webrick server (no independent web server required)
|
46
44
|
2. Uses textile as its text coding (a proto-standard)
|
47
45
|
3, Uses a combination of flat and yaml files for storage (no database, and page content human readable outside of soks)
|
@@ -51,16 +49,13 @@ Features
|
|
51
49
|
6. Pages can be deleted and moved easily (and these can be undone)
|
52
50
|
7. Has a mechanism for external classes to manipulate the wiki to provide, for instance, automatic calendar pages, or automatic summaries or blog like pages.
|
53
51
|
|
54
|
-
|
55
|
-
|
52
|
+
h2. BUGS
|
53
|
+
|
56
54
|
I suspect there are many, as befits its version number. In particular it has:
|
57
55
|
* Not got any way of securing pictures or attachments added to the wiki
|
58
56
|
* Uses RedCloth 2.0.11 which has some formatting bugs (and no doubt some extra ones introduced by my clumsy extentions). RedCloth 3.0.1 is included but not enabled because it tends to hit stack overflows frequently for me.
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
2005 Jan 24 - soks-0.0.3 - Second public release (
|
58
|
+
h2. RELEASES
|
59
|
+
|
60
|
+
2005 Jan 24 - soks-0.0.3 - Second public release (alpha)
|
63
61
|
2005 Jan 11 - soks-0.0.2 - First public release (alpha)
|
64
|
-
|
65
|
-
---------------
|
66
|
-
End of document
|
data/bin/soks-create-wiki.rb
CHANGED
@@ -114,6 +114,7 @@ if upgrade
|
|
114
114
|
puts "Copied #{source} to #{destination}"
|
115
115
|
|
116
116
|
if keep_content
|
117
|
+
FileUtils.rm_rf( File.join( destination, 'content' ) )
|
117
118
|
FileUtils.cp_r( File.join( old_wiki, 'content'), destination )
|
118
119
|
puts "Copied content from #{old_wiki} to #{destination}"
|
119
120
|
if wiki_version == '0.0.2'
|
@@ -158,8 +159,8 @@ if upgrade
|
|
158
159
|
|
159
160
|
fill_out_script_template( destination, 'start.rb', { :root_directory => File.expand_path( destination ), :soks_libraries => soks_library, :url => old_url, :port => old_port } )
|
160
161
|
|
161
|
-
puts "
|
162
|
-
|
162
|
+
puts "\nI'm very sorry, but if you modified the authenticators, or added any AutomaticSummaries or AutomaticCalendars or suchlike, then you will need to copy them across manually from #{old_wiki}/start.rb to #{destination}/start.rb.\n Note that their api may have changed, so please look at the examples in #{destination}/start.rb\n\nOnce you have done that, run ruby #{destination}/start.rb to start."
|
163
|
+
exit
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
data/contrib/redcloth-2.0.11.rb
CHANGED
data/lib/soks-helpers.rb
CHANGED
@@ -16,7 +16,10 @@ class AutomaticUpdateCrossLinks
|
|
16
16
|
@view.rollingmatch[ page.name ] = page
|
17
17
|
titleregex = Regexp.new( page.name, Regexp::IGNORECASE )
|
18
18
|
@wiki.each { |name, linkedpage |
|
19
|
-
|
19
|
+
if linkedpage.textile =~ titleregex
|
20
|
+
@view.refresh_redcloth( linkedpage )
|
21
|
+
linkedpage.inserted_into.each { |insert| @view.refresh_redcloth( insert ) }
|
22
|
+
end
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
@@ -129,11 +132,11 @@ class AutomaticSummary
|
|
129
132
|
end
|
130
133
|
|
131
134
|
def render_page( page )
|
132
|
-
"<div class='subpage'>\n#
|
135
|
+
"<div class='subpage'>\n[[#{page.name}]] #{ @settings[:include_metadata] ? render_meta_data( page ) : "" }<br />\n\n#{page.textile.first_lines( @settings[:lines_to_include] ).close_unmatched_html}\n\np(more). [[(more) => #{page.name}]]\n\n</div>\n"
|
133
136
|
end
|
134
137
|
|
135
138
|
def render_link_to( page )
|
136
|
-
"* #{page.name} #{ @settings[:include_metadata] ? render_meta_data( page ) : "" }\n"
|
139
|
+
"* [[ #{page.name} ]] #{ @settings[:include_metadata] ? render_meta_data( page ) : "" }\n"
|
137
140
|
end
|
138
141
|
|
139
142
|
def render_meta_data( page )
|
@@ -147,7 +150,7 @@ class AutomaticSummary
|
|
147
150
|
end
|
148
151
|
|
149
152
|
def start_watching_wiki( wiki )
|
150
|
-
wiki.watch_for( @settings[:only_new_pages] ? :page_created : :page_revised ) { |event, page, revision| check_whether_to_add_page( page, revision ) }
|
153
|
+
wiki.watch_for( @settings[:only_new_pages] == true ? :page_created : :page_revised ) { |event, page, revision| check_whether_to_add_page( page, revision ) }
|
151
154
|
wiki.watch_for( :page_deleted ) { |event, page, revision| check_whether_to_remove_page( page, revision ) } if @settings[:remove_deleted_pages]
|
152
155
|
end
|
153
156
|
|
data/lib/soks-model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
1
3
|
# Revision stores changes as a diff against the more recent content version
|
2
4
|
class Revision
|
3
5
|
attr_reader :number, :author, :page
|
@@ -33,8 +35,8 @@ class Revision
|
|
33
35
|
end
|
34
36
|
|
35
37
|
class Page
|
36
|
-
attr_accessor :name, :content, :revisions
|
37
|
-
attr_accessor :links_from, :links_to, :inserted_into
|
38
|
+
attr_accessor :content_lock, :name, :content, :revisions
|
39
|
+
attr_accessor :links_lock, :links_from, :links_to, :inserted_into
|
38
40
|
alias :to_s :name
|
39
41
|
|
40
42
|
# Returns an empty version of itself.
|
@@ -49,6 +51,7 @@ class Page
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def initialize( name )
|
54
|
+
@content_lock, @links_lock = Mutex.new, Mutex.new
|
52
55
|
@name, @content, @revisions = name, "", []
|
53
56
|
@links_from, @links_to = [], []
|
54
57
|
@inserted_into = []
|
@@ -56,9 +59,10 @@ class Page
|
|
56
59
|
|
57
60
|
# Revises the content of this page, creating a new revision class that stores the changes
|
58
61
|
def revise( new_content, author )
|
62
|
+
return nil if new_content == @content
|
59
63
|
if the_same_author_recently_revised_this_page( author )
|
60
64
|
changes = changes_between( previous_content, new_content )
|
61
|
-
@revisions[-1] = Revision.new( self, @revisions.length, changes , author )
|
65
|
+
@revisions[-1] = Revision.new( self, @revisions.length - 1, changes , author )
|
62
66
|
else
|
63
67
|
changes = changes_between( @content, new_content )
|
64
68
|
return nil if changes.empty?
|
@@ -76,7 +80,7 @@ class Page
|
|
76
80
|
def revision( number ) @revisions[ number ] end
|
77
81
|
|
78
82
|
def deleted?
|
79
|
-
( content
|
83
|
+
( content =~ /^#{$MESSAGES[:page_deleted]}/i ) ||
|
80
84
|
( content =~ /^#{$MESSAGES[:content_moved_to]} /i )
|
81
85
|
end
|
82
86
|
|
@@ -88,8 +92,8 @@ class Page
|
|
88
92
|
|
89
93
|
def created_on; @revisions.first.created_on end
|
90
94
|
|
91
|
-
def is_inserted_into( page )
|
92
|
-
@inserted_into << page unless @inserted_into.include? page
|
95
|
+
def is_inserted_into( page )
|
96
|
+
@links_lock.synchronize { @inserted_into << page unless @inserted_into.include? page }
|
93
97
|
end
|
94
98
|
|
95
99
|
def textile( content = @content ) content end
|
@@ -170,10 +174,12 @@ class Wiki
|
|
170
174
|
end
|
171
175
|
|
172
176
|
def revise( pagename, content, author )
|
177
|
+
check_disk_for_updated_page pagename
|
173
178
|
mutate( pagename ) { |page| page.revise( content, author ) }
|
174
179
|
end
|
175
180
|
|
176
181
|
def rollback( pagename, number, author )
|
182
|
+
check_disk_for_updated_page pagename
|
177
183
|
mutate( pagename ) { |page| page.rollback( number, author ) }
|
178
184
|
end
|
179
185
|
|
@@ -197,11 +203,13 @@ class Wiki
|
|
197
203
|
|
198
204
|
def mutate( pagename )
|
199
205
|
didexist = exists? pagename
|
200
|
-
check_disk_for_updated_page pagename
|
201
206
|
page = page_named( pagename ) || new_page( pagename )
|
202
|
-
revision =
|
207
|
+
revision = nil
|
208
|
+
page.content_lock.synchronize do
|
209
|
+
revision, dont_save = yield page
|
210
|
+
save page if revision && dont_save != :dont_save
|
211
|
+
end
|
203
212
|
if revision
|
204
|
-
save page
|
205
213
|
notify :page_revised, page, revision
|
206
214
|
if page.deleted?
|
207
215
|
notify :page_deleted, page, revision
|
data/lib/soks-storage.rb
CHANGED
@@ -4,60 +4,48 @@ module WikiFlatFileStore
|
|
4
4
|
REVISIONS_EXTENSION = '.yaml'
|
5
5
|
DEFAULT_AUTHOR = 'AutomaticImport'
|
6
6
|
|
7
|
-
def save( page )
|
8
|
-
add_page_to_index( page )
|
9
|
-
save_content( page )
|
10
|
-
save_revisions( page )
|
11
|
-
end
|
12
|
-
|
13
7
|
def load_all_pages
|
14
8
|
move_files_if_names_are_not_url_encoded
|
15
9
|
pages_on_disk = Dir[ File.join( @folder, "*#{CONTENT_EXTENSION}" ) ].map { |filename| page_name_for( filename )}
|
16
10
|
pages_in_memory = @pages.values.map { |page| page && page.name }
|
17
|
-
( pages_in_memory.compact | pages_on_disk ).each do |pagename|
|
18
|
-
|
19
|
-
|
20
|
-
if page && !File.exists?( filename_for_content( pagename ) )
|
21
|
-
@pages[ page.name.downcase ] = nil
|
22
|
-
notify :page_revised, page, page.revisions.last
|
23
|
-
notify :page_deleted, page, page.revisions.last
|
24
|
-
next
|
11
|
+
( pages_in_memory.compact | pages_on_disk ).each do |pagename|
|
12
|
+
if check_disk_for_updated_page( pagename, true ) == :file_does_not_exist
|
13
|
+
revise( pagename, $MESSAGES[:page_deleted], DEFAULT_AUTHOR )
|
25
14
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_disk_for_updated_page( pagename, force = false )
|
19
|
+
return unless force || $SETTINGS[:check_files_every] # We don't care about file changes
|
20
|
+
filename = filename_for_content( pagename )
|
21
|
+
return :file_does_not_exist unless File.exists?( filename ) # File doesn't exist on disk
|
22
|
+
return load_page( filename ) unless page_named( pagename )# File is new on the disk, but not yet in memory
|
23
|
+
return load_page( filename ) if content_newer_than_revisions?( page_named(pagename) ) # File is newer on disk
|
24
|
+
return nil
|
37
25
|
end
|
38
26
|
|
39
27
|
def load_page( filename )
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
28
|
+
mutate( page_name_for( filename ) ) do |page|
|
29
|
+
disk_content = load_content( page )
|
30
|
+
return nil if disk_content == page.content # No change, disk is the same as memory
|
31
|
+
|
32
|
+
# We now know that the content on disk is different from that in memory
|
33
|
+
|
34
|
+
page.revisions = load_revisions( page ) if page.revisions.empty? # Load revisions from disk if none known
|
35
|
+
# assumes disk revisions are ALWAYS up to date with memory?
|
36
|
+
|
37
|
+
# We now know what the page content and the page revisions should be. But not if the revisions are up to date
|
38
|
+
if content_newer_than_revisions?( page ) # The textile file has been modified, but the array file has not been updated to match
|
39
|
+
page.content = reconstruct_content_from_revisions( page.revisions )
|
40
|
+
page.revise( disk_content, DEFAULT_AUTHOR )
|
41
|
+
save_revisions( page )
|
42
|
+
else # The textile file and the array file are in sync.
|
43
|
+
page.content = disk_content
|
44
|
+
end
|
47
45
|
|
48
|
-
|
49
|
-
page.
|
50
|
-
save_revisions( page )
|
51
|
-
elsif content_newer_than_revisions?( page ) # The textile file has been modified, but the array file has not been updated to match
|
52
|
-
page.content = reconstruct_content_from_revisions( page.revisions )
|
53
|
-
page.revise( content, DEFAULT_AUTHOR )
|
54
|
-
save_revisions( page )
|
55
|
-
else # The textile file and the array file are in sync.
|
56
|
-
page.content = content
|
46
|
+
add_page_to_index( page )
|
47
|
+
[ page.revisions.last, :dont_save ]
|
57
48
|
end
|
58
|
-
|
59
|
-
add_page_to_index( page )
|
60
|
-
page
|
61
49
|
end
|
62
50
|
|
63
51
|
def load_content( page )
|
@@ -68,40 +56,15 @@ module WikiFlatFileStore
|
|
68
56
|
return [] unless File.exists?( filename_for_revisions( page.name ) )
|
69
57
|
revisions = []
|
70
58
|
File.open( filename_for_revisions( page.name ) ) { |file|
|
71
|
-
YAML.each_document( file ) { |array|
|
72
|
-
revisions[ array[0] ] = Revision.new( page, *array )
|
73
|
-
}
|
59
|
+
YAML.each_document( file ) { |array| revisions[ array[0] ] = Revision.new( page, *array ) }
|
74
60
|
}
|
75
61
|
revisions.each_with_index { |r,i| $stderr.puts "#{page.name} missing revision #{i}" unless r }
|
76
62
|
revisions
|
77
63
|
end
|
78
64
|
|
79
|
-
def save_content( page )
|
80
|
-
File.open(filename_for_content( page.name ), 'w' ) { |file| file.puts page.content }
|
81
|
-
end
|
82
|
-
|
83
|
-
# Appends the last revision onto the yaml file
|
84
|
-
def save_revisions( page )
|
85
|
-
$stderr.puts "Saving revisions for #{page.name}"
|
86
|
-
File.open(filename_for_revisions( page.name ), 'a' ) { |file|
|
87
|
-
YAML.dump( page.revisions.last.to_a, file )
|
88
|
-
file.puts
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
def check_disk_for_updated_page( pagename )
|
93
|
-
return unless $SETTINGS[:check_files_every] # We don't care about file changes
|
94
|
-
filename = filename_for_content( pagename )
|
95
|
-
return nil unless File.exists?( filename ) # File doesn't exist on disk
|
96
|
-
return load_page( filename ) unless page_named pagename # File is new on the disk, but not yet in memory
|
97
|
-
return load_page( filename ) if ( page_named(pagename).revised_on < File.ctime( filename ) ) # File is newer on disk
|
98
|
-
return nil
|
99
|
-
end
|
100
|
-
|
101
65
|
def content_newer_than_revisions?( page )
|
102
|
-
|
103
|
-
|
104
|
-
File.ctime(page_file) > File.ctime(revision_file)
|
66
|
+
return true if page.empty?
|
67
|
+
File.ctime(filename_for_content( page.name )) > File.ctime(filename_for_revisions(page.name))
|
105
68
|
end
|
106
69
|
|
107
70
|
def reconstruct_content_from_revisions( revisions )
|
@@ -119,6 +82,26 @@ module WikiFlatFileStore
|
|
119
82
|
end
|
120
83
|
end
|
121
84
|
|
85
|
+
def save( page )
|
86
|
+
add_page_to_index( page )
|
87
|
+
save_content( page )
|
88
|
+
save_revisions( page )
|
89
|
+
end
|
90
|
+
|
91
|
+
def save_content( page )
|
92
|
+
File.open(filename_for_content( page.name ), 'w' ) { |file| file.puts page.content }
|
93
|
+
end
|
94
|
+
|
95
|
+
# Appends the last revision onto the yaml file
|
96
|
+
def save_revisions( page )
|
97
|
+
$stderr.puts "Saving revisions for #{page.name}"
|
98
|
+
File.open(filename_for_revisions( page.name ), 'a' ) do |file|
|
99
|
+
YAML.dump( page.revisions.last.to_a, file )
|
100
|
+
file.puts # Needed to ensure that documents are separated
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
122
105
|
def page_name_for( filename )
|
123
106
|
File.basename( filename, '.*').url_decode
|
124
107
|
end
|
data/lib/soks-view.rb
CHANGED
@@ -6,12 +6,22 @@ class Links
|
|
6
6
|
def links_from( page ) ; return @links[ page ] ; end
|
7
7
|
|
8
8
|
def set_links_from( page, linkarray )
|
9
|
-
|
10
|
-
page.
|
11
|
-
|
9
|
+
|
10
|
+
page.links_lock.synchronize do
|
11
|
+
page.links_from = @links[ page ] = linkarray.uniq
|
12
|
+
set_links_to( page )
|
13
|
+
end
|
14
|
+
|
15
|
+
page.links_from.each { |linked_page|
|
16
|
+
linked_page.links_lock.synchronize do
|
17
|
+
set_links_to( linked_page )
|
18
|
+
end
|
19
|
+
}
|
12
20
|
end
|
13
21
|
|
14
|
-
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_links_to( thispage )
|
15
25
|
linksto = Array.new
|
16
26
|
@links.each do | pagefrom, pagesto |
|
17
27
|
next if pagefrom == thispage
|
@@ -19,7 +29,7 @@ class Links
|
|
19
29
|
next if linksto.include? pagefrom
|
20
30
|
linksto << pagefrom if pagesto.include? thispage
|
21
31
|
end
|
22
|
-
|
32
|
+
thispage.links_to = linksto.sort
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|
@@ -55,7 +65,7 @@ class RollingMatch
|
|
55
65
|
# This returns the longest match that starts with the first word in the text
|
56
66
|
def longest_match( text, *dont_match )
|
57
67
|
lengths_for_first_word_of( text ).reverse_each do |length|
|
58
|
-
|
68
|
+
next if length > text.length
|
59
69
|
if object_for(text.left(length)) && !dont_match.include?( lower_case( text.left(length) ) )
|
60
70
|
return text.left(length)
|
61
71
|
end
|
@@ -68,13 +78,14 @@ class RollingMatch
|
|
68
78
|
text = text.dup
|
69
79
|
skipped_text = ""
|
70
80
|
until text.empty?
|
81
|
+
skipped_text << text.slice!( SPACE_REGEX ) # Skip to the end of the next space
|
71
82
|
matching_title = longest_match( text, *dont_match )
|
72
83
|
if matching_title
|
73
84
|
yield skipped_text, matching_title, object_for( matching_title )
|
74
85
|
text.slice!( 0, matching_title.length ) # Skip to the end of the matched bit
|
75
|
-
skipped_text =
|
86
|
+
skipped_text = ""
|
76
87
|
else
|
77
|
-
skipped_text << text.slice!( WORD_REGEX )
|
88
|
+
skipped_text << text.slice!( WORD_REGEX ) # Skip to the next word
|
78
89
|
end
|
79
90
|
end
|
80
91
|
yield skipped_text, nil, nil
|
@@ -104,8 +115,7 @@ class WikiRedCloth < RedCloth
|
|
104
115
|
@wiki, @page = wiki, page
|
105
116
|
@rules = [ :soks, :textile ]
|
106
117
|
end
|
107
|
-
|
108
|
-
if RedCloth::VERSION == '2.0.11'
|
118
|
+
|
109
119
|
def to_html( lite = nil )
|
110
120
|
|
111
121
|
@lite = lite unless lite.nil?
|
@@ -116,31 +126,26 @@ if RedCloth::VERSION == '2.0.11'
|
|
116
126
|
@urlrefs = {}
|
117
127
|
@shelf = []
|
118
128
|
@internal_links_from_page = [] # NEW
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
pre_list = rip_offtags text # NEW wasteful to duplicate, but reduces overloading
|
129
|
+
|
130
|
+
no_textile text
|
131
|
+
insert_sub_strings text # NEW
|
132
|
+
no_textile text # NEW (again in case any sub pages had it, BODGE doesn't work recursively)
|
133
|
+
clean_white_space text
|
134
|
+
pre_list = rip_offtags text # NEW wasteful to duplicate, but reduces overloading
|
135
|
+
|
136
|
+
hide_tags text # NEW
|
129
137
|
hide_textile_links text # NEW
|
130
138
|
hide_textile_image_tags text # NEW
|
131
139
|
inline_soks_bracketed_link text # NEW
|
132
140
|
inline_soks_external_link text # NEW
|
133
141
|
inline_soks_automatic_link text # NEW
|
142
|
+
|
134
143
|
@wiki.links.set_links_from( @page, @internal_links_from_page ) # NEW
|
135
144
|
unhide_textile text # NEW
|
136
145
|
smooth_offtags text, pre_list # NEW wasteful to duplicate
|
137
146
|
|
138
147
|
incoming_entities text
|
139
|
-
## encode_entities text
|
140
|
-
## fix_entities text
|
141
|
-
|
142
148
|
get_refs text
|
143
|
-
|
144
149
|
inline text
|
145
150
|
|
146
151
|
unless @lite
|
@@ -151,7 +156,7 @@ if RedCloth::VERSION == '2.0.11'
|
|
151
156
|
retrieve text
|
152
157
|
|
153
158
|
text.gsub!( /<\/?notextile>/, '' )
|
154
|
-
text.gsub!( /x%x%/, '&' )
|
159
|
+
text.gsub!( /x%x%/, '&' )
|
155
160
|
text.gsub!( /<br \/>/, "<br />\n" )
|
156
161
|
text.strip!
|
157
162
|
|
@@ -159,71 +164,11 @@ if RedCloth::VERSION == '2.0.11'
|
|
159
164
|
|
160
165
|
text
|
161
166
|
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
if RedCloth::VERSION == '3.0.1'
|
166
|
-
def to_html( *rules )
|
167
|
-
rules = @rules if rules.empty?
|
168
|
-
# make our working copy
|
169
|
-
text = self.dup
|
170
|
-
|
171
|
-
@urlrefs = {}
|
172
|
-
@shelf = []
|
173
|
-
@internal_links_from_page = []
|
174
|
-
|
175
|
-
textile_rules = [:refs_textile, :block_textile_table, :block_textile_lists,
|
176
|
-
:block_textile_prefix, :inline_textile_image, :inline_textile_link,
|
177
|
-
:inline_textile_code, :inline_textile_glyphs, :inline_textile_span]
|
178
|
-
markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule,
|
179
|
-
:block_markdown_bq, :block_markdown_lists,
|
180
|
-
:inline_markdown_reflink, :inline_markdown_link]
|
181
|
-
soks_rules = [ :hide_textile_links, :hide_textile_image_tags, :inline_soks_bracketed_link, :inline_soks_external_link, :inline_soks_automatic_link, :unhide_textile ]
|
182
|
-
@rules = rules.collect do |rule|
|
183
|
-
case rule
|
184
|
-
when :markdown
|
185
|
-
markdown_rules
|
186
|
-
when :textile
|
187
|
-
textile_rules
|
188
|
-
when :soks
|
189
|
-
soks_rules
|
190
|
-
else
|
191
|
-
rule
|
192
|
-
end
|
193
|
-
end.flatten
|
194
|
-
|
195
|
-
# insert sub pages
|
196
|
-
insert_sub_strings text
|
197
|
-
|
198
|
-
# standard clean up
|
199
|
-
incoming_entities text
|
200
|
-
clean_white_space text
|
201
|
-
|
202
|
-
# start processor
|
203
|
-
pre_list = rip_offtags text
|
204
|
-
refs text
|
205
|
-
blocks text
|
206
|
-
inline text
|
207
|
-
smooth_offtags text, pre_list
|
208
|
-
|
209
|
-
retrieve text
|
210
|
-
|
211
|
-
@wiki.links.set_links_from( @page, @internal_links_from_page )
|
212
|
-
|
213
|
-
text.gsub!( /<\/?notextile>/, '' )
|
214
|
-
text.gsub!( /x%x%/, '&' )
|
215
|
-
text.strip!
|
216
|
-
|
217
|
-
clean_html text
|
218
|
-
|
219
|
-
text
|
220
|
-
end
|
221
|
-
end
|
222
167
|
|
223
168
|
private
|
224
169
|
|
225
|
-
def
|
226
|
-
text.gsub!(
|
170
|
+
def hide_tags( text )
|
171
|
+
text.gsub!(/<.*?>/) { |m| hide_textile m }
|
227
172
|
end
|
228
173
|
|
229
174
|
## Dictionary describing allowable HTML
|
@@ -0,0 +1,12 @@
|
|
1
|
+
h1. The Author
|
2
|
+
|
3
|
+
Soks was written by Tom Counsell. He can be reached at tamc@rubyforge.org.
|
4
|
+
|
5
|
+
Further details can be found at http://tom.counsell.org.
|
6
|
+
|
7
|
+
h2. Thanks to
|
8
|
+
|
9
|
+
* Sebastien Clediere for a patch to fix uploads on windows
|
10
|
+
* _why for the RedCloth library
|
11
|
+
* Austin Ziegler for the Diff:LCS library
|
12
|
+
* Matz and ruby-core for the ruby language
|