junebug-wiki 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- #rake test RUBY_FLAGS=''
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
 
@@ -270,6 +270,7 @@ body {
270
270
  border: 1px solid #ddd;
271
271
  padding: 8px 20px;
272
272
  margin: 15px 0px;
273
+ overflow: auto;
273
274
  }
274
275
 
275
276
  .content pre.clean {
@@ -1,5 +1,5 @@
1
1
  $:.unshift File.dirname(__FILE__) # for running in foreground in dev
2
-
2
+ $KCODE = 'u'
3
3
  require 'rubygems'
4
4
  require_gem 'camping', '>=1.5'
5
5
  require 'camping/session'
@@ -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 '/([0-9A-Za-z_-]+)', '/([0-9A-Za-z_-]+)/(\d+)'
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 '/([0-9A-Za-z_-]+)/edit', '/([0-9A-Za-z_-]+)/(\d+)/edit'
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 '/([0-9A-Za-z_-]+)/delete'
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 '/([0-9A-Za-z_-]+)/(\d+)/revert'
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 '/([0-9A-Za-z_-]+)/versions'
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 '/([0-9A-Za-z_-]+)/backlinks'
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 '/([0-9A-Za-z_-]+)/(\d+)/(\d+)/diff'
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(/_/,' ')
@@ -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 camping error on initial load
29
- #PAGE_LINK = /\[\[([^\]|]*)[|]?([^\]]*)\]\]/
30
- PAGE_LINK = /\[\[([0-9A-Za-z -]+)[|]?([^\]]*)\]\]/
31
- #before_save { |r| r.title = r.title.underscore }
32
- #PAGE_LINK = /([A-Z][a-z]+[A-Z]\w+)/
33
- validates_uniqueness_of :title
34
- validates_format_of :title, :with => /^[0-9A-Za-z -]+$/
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
 
@@ -2,7 +2,7 @@ module Junebug #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 28
5
+ TINY = 29
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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.0
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.28
7
- date: 2007-01-20 00:00:00 -08:00
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: