junebug-wiki 0.0.28 → 0.0.29
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/History.txt +6 -0
- data/Rakefile +4 -1
- data/deploy/public/style/base.css +1 -0
- data/lib/junebug.rb +1 -1
- data/lib/junebug/controllers.rb +13 -7
- data/lib/junebug/models.rb +14 -8
- data/lib/junebug/version.rb +1 -1
- data/test/test_wiki.rb +14 -0
- metadata +12 -3
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
= 0.0.29 2007-04-15
|
2
|
+
|
3
|
+
* Support Unicode wikiwords. Thanks Julian Tarkhanov
|
4
|
+
* Disable suprious warnings when running tests. Thanks Julian Tarkhanov
|
5
|
+
* Css tweak to prevent overflow in pre tags. Thanks Leslie Viljoen
|
6
|
+
|
1
7
|
= 0.0.28 2007-01-20
|
2
8
|
|
3
9
|
* Fix uninitialized constant Mongrel::Camping error
|
data/Rakefile
CHANGED
@@ -55,8 +55,11 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
55
55
|
]
|
56
56
|
end
|
57
57
|
|
58
|
-
#
|
58
|
+
# Disable suprious warnings when running tests
|
59
|
+
# submitted by Julian Tarkhanov
|
59
60
|
|
61
|
+
Hoe::RUBY_FLAGS.replace ENV['RUBY_FLAGS'] || "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}" +
|
62
|
+
(Hoe::RUBY_DEBUG ? " #{RUBY_DEBUG}" : '')
|
60
63
|
|
61
64
|
|
62
65
|
|
data/lib/junebug.rb
CHANGED
data/lib/junebug/controllers.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'junebug/ext/diff'
|
2
2
|
|
3
|
+
|
3
4
|
module Junebug::Controllers
|
5
|
+
# DRY and besides otherwise you need to escape every \d
|
6
|
+
def self.slug(after = '')
|
7
|
+
"/(#{Junebug::Models::Page::PAGE_SLUG})" + after
|
8
|
+
end
|
4
9
|
|
5
10
|
class Index < R '/'
|
6
11
|
def get
|
@@ -8,7 +13,7 @@ module Junebug::Controllers
|
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
11
|
-
class Show < R
|
16
|
+
class Show < R slug, slug('/(\d+)')
|
12
17
|
def get page_name, version = nil
|
13
18
|
redirect(Edit, page_name, 1) and return unless @page = Page.find_by_title(page_name.gsub(/_/,' '))
|
14
19
|
@page_title = @page.title
|
@@ -17,7 +22,8 @@ module Junebug::Controllers
|
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
|
-
class Edit < R '/
|
25
|
+
class Edit < R slug('/edit'), slug('/(\d+)/edit')
|
26
|
+
|
21
27
|
def get page_name, version = nil
|
22
28
|
redirect("/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}") and return unless logged_in?
|
23
29
|
page_name_spc = page_name.gsub(/_/,' ')
|
@@ -52,7 +58,7 @@ module Junebug::Controllers
|
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
55
|
-
class Delete < R '/
|
61
|
+
class Delete < R slug('/delete')
|
56
62
|
def get page_name
|
57
63
|
redirect("/login") and return unless logged_in?
|
58
64
|
Page.find_by_title(page_name.gsub(/_/,' ')).destroy() if is_admin?
|
@@ -61,7 +67,7 @@ module Junebug::Controllers
|
|
61
67
|
|
62
68
|
end
|
63
69
|
|
64
|
-
class Revert < R '/(
|
70
|
+
class Revert < R slug('/(\d)/revert')
|
65
71
|
def get page_name, version
|
66
72
|
redirect("/login") and return unless logged_in?
|
67
73
|
Page.find_by_title(page_name.gsub(/_/,' ')).revert_to!(version) if is_admin?
|
@@ -69,7 +75,7 @@ module Junebug::Controllers
|
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
72
|
-
class Versions < R '/
|
78
|
+
class Versions < R slug('/versions')
|
73
79
|
def get page_name
|
74
80
|
page_name_spc = page_name.gsub(/_/,' ')
|
75
81
|
@page = Page.find_by_title(page_name_spc)
|
@@ -96,7 +102,7 @@ module Junebug::Controllers
|
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
99
|
-
class Backlinks < R '/
|
105
|
+
class Backlinks < R slug('/backlinks')
|
100
106
|
def get page_name
|
101
107
|
page_name_spc = page_name.gsub(/_/,' ')
|
102
108
|
@page = Page.find_by_title(page_name_spc)
|
@@ -114,7 +120,7 @@ module Junebug::Controllers
|
|
114
120
|
end
|
115
121
|
end
|
116
122
|
|
117
|
-
class Diff < R '/(
|
123
|
+
class Diff < R slug('/(\d+)/(\d+)/diff')
|
118
124
|
include HTMLDiff
|
119
125
|
def get page_name, v1, v2
|
120
126
|
page_name_spc = page_name.gsub(/_/,' ')
|
data/lib/junebug/models.rb
CHANGED
@@ -25,14 +25,20 @@ module Junebug::Models
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class Page < Base
|
28
|
-
belongs_to :user, :class_name=>"Junebug::Models::User", :foreign_key=>'user_id' # Hack to prevent
|
29
|
-
#
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
belongs_to :user, :class_name=>"Junebug::Models::User", :foreign_key=>'user_id' # Hack to prevent
|
29
|
+
# camping error on initial load
|
30
|
+
|
31
|
+
PAGE_TITLE = '[\w0-9A-Za-z -]+' # We need the \w for other UTF chars
|
32
|
+
PAGE_SLUG = PAGE_TITLE.gsub(/ /, '_')
|
33
|
+
DENY_UNDERSCORES = /^([^_]+)$/
|
34
|
+
PAGE_LINK = /\[\[(#{PAGE_TITLE})[|]?([^\]]*)\]\]/
|
35
|
+
|
35
36
|
validates_presence_of :title
|
37
|
+
validates_uniqueness_of :title
|
38
|
+
validates_format_of :title, :with => /^(#{PAGE_TITLE})$/
|
39
|
+
# Underscores have to be checked separately because they are included in \w
|
40
|
+
validates_format_of :title, :with => /^(#{DENY_UNDERSCORES})$/
|
41
|
+
|
36
42
|
acts_as_versioned
|
37
43
|
non_versioned_fields.push 'title'
|
38
44
|
|
@@ -41,7 +47,7 @@ module Junebug::Models
|
|
41
47
|
end
|
42
48
|
|
43
49
|
def title_url
|
44
|
-
title.gsub('
|
50
|
+
title.gsub(/\s/,'_')
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
data/lib/junebug/version.rb
CHANGED
data/test/test_wiki.rb
CHANGED
@@ -24,6 +24,17 @@ class TestJunebug < Camping::FunctionalTest
|
|
24
24
|
assert_match_body %r!title>Welcome to Junebug</title!
|
25
25
|
end
|
26
26
|
|
27
|
+
def test_unicody_slug
|
28
|
+
unic_page = Page.create({ :title => "ВикиСлово",
|
29
|
+
:body => "Слово сказано",
|
30
|
+
:user_id => 1,
|
31
|
+
})
|
32
|
+
|
33
|
+
get '/ВикиСлово'
|
34
|
+
assert_response :success
|
35
|
+
assert_match_body /Слово сказано/
|
36
|
+
end
|
37
|
+
|
27
38
|
def test_login
|
28
39
|
post '/login', :username => 'admin', :password => 'password'
|
29
40
|
assert_response :redirect
|
@@ -158,6 +169,8 @@ class TestPage < Camping::UnitTest
|
|
158
169
|
page = create(:title => '1')
|
159
170
|
assert page.valid?
|
160
171
|
|
172
|
+
page = create(:title => 'вики слово')
|
173
|
+
assert page.valid?
|
161
174
|
end
|
162
175
|
|
163
176
|
def test_invalid_title
|
@@ -184,6 +197,7 @@ class TestPage < Camping::UnitTest
|
|
184
197
|
page = create(:title => 'test_title')
|
185
198
|
deny page.valid?
|
186
199
|
assert_not_nil page.errors.on(:title)
|
200
|
+
|
187
201
|
end
|
188
202
|
|
189
203
|
def test_unique_title
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: junebug-wiki
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.29
|
7
|
+
date: 2007-04-15 00:00:00 -07:00
|
8
8
|
summary: Junebug is a minimalist ruby wiki running on Camping.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -127,3 +127,12 @@ dependencies:
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: 1.15.1
|
129
129
|
version:
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: hoe
|
132
|
+
version_requirement:
|
133
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 1.2.0
|
138
|
+
version:
|