junebug-wiki 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.0.32 2007-08-18
2
+
3
+ * Added preview function. Thanks Bob Showalter
4
+ * Added more tests
5
+
1
6
  = 0.0.31 2007-04-22
2
7
 
3
8
  * User list and user history pages
data/RELEASE_NOTES.txt CHANGED
@@ -1,3 +1,10 @@
1
+ = 0.0.32 2007-08-18
2
+
3
+ This release includes some css changes, so don't forget to rake update:everything
4
+
5
+ Read the updating page at http://www.junebugwiki.com/JunebugUpdating
6
+
7
+
1
8
  = 0.0.28 2007-01-20
2
9
 
3
10
  Existing users be sure to read the updating page at http://www.junebugwiki.com/JunebugUpdating
@@ -306,3 +306,10 @@ body {
306
306
  font-weight: bold;
307
307
  background-color: #d7e0ff;
308
308
  }
309
+
310
+ div.preview {
311
+ border: 2px solid #bbf;
312
+ padding: 10px;
313
+ margin-bottom: 10px;
314
+ background: transparent url(/images/draft.png) repeat scroll 0%;
315
+ }
@@ -15,10 +15,14 @@ module Junebug::Controllers
15
15
 
16
16
  class Show < R slug, slug('/(\d+)')
17
17
  def get page_name, version = nil
18
- redirect(Edit, page_name, 1) and return unless @page = Page.find_by_title(page_name.gsub(/_/,' '))
19
- @page_title = @page.title
20
- @version = (version.nil? or version == @page.version.to_s) ? @page : @page.versions.find_by_version(version)
21
- render :show
18
+ @page = Page.find_by_title(page_name.gsub(/_/,' '))
19
+ if @page.nil?
20
+ logged_in? ? redirect(Edit, page_name, 1) : redirect("/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}")
21
+ else
22
+ @page_title = @page.title
23
+ @version = (version.nil? or version == @page.version.to_s) ? @page : @page.versions.find_by_version(version)
24
+ render :show
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -29,13 +33,11 @@ module Junebug::Controllers
29
33
  page_name_spc = page_name.gsub(/_/,' ')
30
34
  @page = Page.find_by_title(page_name_spc)
31
35
  if @page.nil?
32
- # new page
33
- @page = Page.new(:title=>page_name_spc, :body=>'') unless @page
36
+ @page = Page.new(:title=>page_name_spc, :body=>'')
34
37
  else
35
38
  # check for version request
36
39
  @page = @page.versions.find_by_version(version) unless version.nil? or version == @page.version.to_s
37
40
  end
38
- @page_title = "Editing: #{page_name_spc}"
39
41
  render :edit
40
42
  end
41
43
 
@@ -43,27 +45,37 @@ module Junebug::Controllers
43
45
  def post page_name
44
46
  redirect("/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}") and return unless logged_in?
45
47
  page_name_spc = page_name.gsub(/_/,' ')
46
- if input.submit == 'save'
47
- attrs = { :body => input.post_body, :title => input.post_title, :user_id =>@state.user.id }
48
+ @page = Page.find_by_title(page_name_spc)
49
+ if input.submit == 'cancel'
50
+ @page ? redirect(Show, page_name) : redirect(Junebug.startpage)
51
+ else
52
+ attrs = { :body => input.post_body }
48
53
  attrs[:readonly] = input.post_readonly if is_admin?
49
- @page = Page.find_by_title(page_name_spc)
50
- if @page.nil?
51
- # new page
52
- @page = Page.create(attrs)
54
+ if input.submit == 'minor edit'
55
+ current_version = @page.find_version(@page.version)
56
+ current_version.update_attributes(attrs)
57
+ @page.without_revision { @page.update_attributes(attrs) }
58
+ redirect Show, page_name_spc.gsub(/ /,'_') # don't allow pagename changes as minor edits
53
59
  else
54
- @page.update_attributes(attrs)
60
+ attrs[:title] = input.post_title
61
+ if input.submit == 'preview'
62
+ @show_preview = true
63
+ if @page
64
+ @page.attributes = attrs
65
+ else
66
+ @page = Page.new(attrs)
67
+ end
68
+ render :edit
69
+ elsif input.submit == 'save'
70
+ attrs[:user_id] = @state.user.id # don't set this until save
71
+ if @page
72
+ @page.update_attributes(attrs)
73
+ else
74
+ @page = Page.create(attrs)
75
+ end
76
+ redirect Show, input.post_title.gsub(/ /,'_')
77
+ end
55
78
  end
56
- redirect Show, input.post_title.gsub(/ /,'_')
57
- elsif input.submit == 'minor edit'
58
- attrs = { :body => input.post_body }
59
- attrs[:readonly] = input.post_readonly if is_admin?
60
- page = Page.find_by_title(page_name_spc)
61
- current_version = page.find_version(page.version)
62
- current_version.update_attributes(attrs)
63
- page.without_revision { page.update_attributes(attrs) }
64
- redirect Show, input.post_title.gsub(/ /,'_')
65
- else # cancel
66
- redirect Show, page_name
67
79
  end
68
80
  end
69
81
  end
@@ -2,7 +2,7 @@ module Junebug #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 31
5
+ TINY = 32
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/junebug/views.rb CHANGED
@@ -60,7 +60,12 @@ module Junebug::Views
60
60
  def edit
61
61
  _header :show
62
62
  _body do
63
- h1 @page_title
63
+ if @show_preview
64
+ div.preview {
65
+ h1 "#{@page.title}"
66
+ _markup @page.body
67
+ }
68
+ end
64
69
  div.formbox {
65
70
  form :method => 'post', :action => R(Edit, @page.title_url) do
66
71
  p {
@@ -81,6 +86,7 @@ module Junebug::Views
81
86
  input :type => 'submit', :name=>'submit', :value=>'minor edit', :class=>'button', :style=>'float: right;', :accesskey => 'm'
82
87
  end
83
88
  input :type => 'submit', :name=>'submit', :value=>'save', :class=>'button', :style=>'float: right;', :accesskey => 's'
89
+ input :type => 'submit', :name=>'submit', :value=>'preview', :class=>'button', :style=>'float: right;', :accesskey => 'p'
84
90
  if is_admin?
85
91
  opts = { :type => 'checkbox', :value=>'1', :name => 'post_readonly' }
86
92
  opts[:checked] = 1 if @page.readonly
data/test/test_wiki.rb CHANGED
@@ -35,17 +35,29 @@ class TestJunebug < Camping::FunctionalTest
35
35
  assert_match_body /Слово сказано/
36
36
  end
37
37
 
38
- def test_login
38
+ def test_login_basic
39
+ get '/Welcome_to_Junebug/edit'
40
+ assert_response :redirect
41
+ assert_redirected_to '/login'
42
+
39
43
  post '/login', :username => 'admin', :password => 'password'
40
44
  assert_response :redirect
41
45
  assert_redirected_to '/Welcome_to_Junebug'
46
+
47
+ get '/Welcome_to_Junebug/edit'
48
+ assert_response :success
42
49
 
43
50
  get '/logout'
44
51
  assert_response :redirect
45
52
  assert_redirected_to '/Welcome_to_Junebug'
53
+
54
+ get '/Welcome_to_Junebug/edit'
55
+ assert_response :redirect
56
+ assert_redirected_to '/login'
46
57
  end
47
58
 
48
59
  def test_required_login
60
+ # existing pages
49
61
  get '/Welcome_to_Junebug/edit'
50
62
  assert_response :redirect
51
63
  assert_redirected_to '/login'
@@ -61,10 +73,27 @@ class TestJunebug < Camping::FunctionalTest
61
73
  get '/Welcome_to_Junebug/1/revert'
62
74
  assert_response :redirect
63
75
  assert_redirected_to '/login'
76
+
77
+ # page creation
78
+ get '/NonexistentPage/edit'
79
+ assert_response :redirect
80
+ assert_redirected_to '/login'
81
+
82
+ get '/NonexistentPage/1/edit'
83
+ assert_response :redirect
84
+ assert_redirected_to '/login'
85
+
86
+ get '/NonexistentPage/delete'
87
+ assert_response :redirect
88
+ assert_redirected_to '/login'
89
+
90
+ get '/NonexistentPage/1/revert'
91
+ assert_response :redirect
92
+ assert_redirected_to '/login'
64
93
  end
65
94
 
66
- def test_edit_cycle
67
- get '/Welcome_to_Junebug/edit'
95
+ def test_page_editing
96
+ get '/TestPage1'
68
97
  assert_response :redirect
69
98
  assert_redirected_to '/login'
70
99
 
@@ -72,40 +101,60 @@ class TestJunebug < Camping::FunctionalTest
72
101
  assert_response :redirect
73
102
  assert_redirected_to '/Welcome_to_Junebug'
74
103
 
75
- get '/Welcome_to_Junebug/edit'
104
+ get '/TestPage1/edit'
76
105
  assert_response :success
77
106
 
78
- pagename = "Welcome to Junebug"
79
- page = Junebug::Models::Page.find_by_title(pagename)
107
+ # create page
108
+ post "/TestPage1/edit", :post_title=>"TestPage1", :post_body=>"test body", :post_readonly=>"0", :submit=>'save'
109
+ assert_response :redirect
110
+ assert_redirected_to "/TestPage1"
80
111
 
81
- # submit nochange
82
- post "/#{page.title_url}/edit", :post_title=>page.title, :post_body=>page.body, :post_readonly=>page.readonly, :submit=>'save'
112
+ page = Junebug::Models::Page.find_by_title("TestPage1")
113
+
114
+ assert_equal "TestPage1", page.title
115
+ assert_equal "test body", page.body
116
+ assert_equal 1, page.user_id
117
+ assert_equal false, page.readonly
118
+ assert_equal 1, page.version
119
+
120
+ # edit, nochange
121
+ post "/TestPage1/edit", :post_title=>page.title, :post_body=>page.body, :post_readonly=>page.readonly, :submit=>'save'
83
122
  assert_response :redirect
84
- assert_redirected_to "/#{page.title_url}"
85
- page2 = Junebug::Models::Page.find_by_title(page.title)
86
- assert_equal page.title, page2.title
87
- assert_equal page.body, page2.body
88
- assert_equal page.user_id, page2.user_id
89
- assert_equal page.readonly, page2.readonly
90
- assert_equal page.version+1, page2.version
91
-
92
- pagename = "Welcome to Junebug"
93
- page = Junebug::Models::Page.find_by_title(pagename)
123
+ assert_redirected_to "/TestPage1"
124
+
125
+ page2 = Junebug::Models::Page.find_by_title("TestPage1")
126
+
127
+ assert_equal "TestPage1", page2.title
128
+ assert_equal "test body", page2.body
129
+ assert_equal 1, page2.user_id
130
+ assert_equal false, page2.readonly
131
+ assert_equal 2, page2.version
94
132
 
95
133
  # submit edited title and body
96
- post "/#{page.title_url}/edit", :post_title=>page.title+'2', :post_body=>page.body+'2', :post_readonly=>page.readonly, :submit=>'save'
134
+ post "/TestPage1/edit", :post_title=>'TestPage1xx', :post_body=>'test body xx', :post_readonly=>"0", :submit=>'save'
135
+ assert_response :redirect
136
+ assert_redirected_to "/TestPage1xx"
137
+
138
+ page3 = Junebug::Models::Page.find_by_title('TestPage1xx')
139
+
140
+ assert_equal "TestPage1xx", page3.title
141
+ assert_equal "test body xx", page3.body
142
+ assert_equal 1, page3.user_id
143
+ assert_equal false, page3.readonly
144
+ assert_equal 3, page3.version
145
+
146
+ # submit minor edit
147
+ post "/TestPage1xx/edit", :post_title=>"TestPage1yy", :post_body=>'test body yy', :post_readonly=>"0", :submit=>'minor edit'
97
148
  assert_response :redirect
98
- assert_redirected_to "/#{page.title_url+'2'}"
99
- page2 = Junebug::Models::Page.find_by_title(page.title+'2')
100
- assert_equal page.title+'2', page2.title
101
- assert_equal page.body+'2', page2.body
102
- assert_equal page.user_id, page2.user_id
103
- assert_equal page.readonly, page2.readonly
104
- assert_equal page.version+1, page2.version
149
+ assert_redirected_to "/TestPage1xx" # not allowed to change the title in minor edit
105
150
 
106
- # set it back
107
- post "/#{page2.title_url}/edit", :post_title=>page.title, :post_body=>page.body, :post_readonly=>page.readonly, :submit=>'save'
151
+ page4 = Junebug::Models::Page.find_by_title('TestPage1xx')
108
152
 
153
+ assert_equal "TestPage1xx", page4.title
154
+ assert_equal "test body yy", page4.body
155
+ assert_equal 1, page4.user_id
156
+ assert_equal false, page4.readonly
157
+ assert_equal 3, page4.version # version doesn't change
109
158
  end
110
159
 
111
160
 
@@ -148,19 +197,19 @@ class TestPage < Camping::UnitTest
148
197
  end
149
198
 
150
199
  def test_valid_title
151
- page = create(:title => 'TestPage')
200
+ page = create(:title => 'TestPage3')
152
201
  assert page.valid?
153
202
 
154
- page = create(:title => 'Test Page')
203
+ page = create(:title => 'Test Page3')
155
204
  assert page.valid?
156
205
 
157
- page = create(:title => 'Test-Page')
206
+ page = create(:title => 'Test-Page3')
158
207
  assert page.valid?
159
208
 
160
- page = create(:title => 'test page')
209
+ page = create(:title => 'test page3')
161
210
  assert page.valid?
162
211
 
163
- page = create(:title => 'test')
212
+ page = create(:title => 'test3')
164
213
  assert page.valid?
165
214
 
166
215
  page = create(:title => 't')
@@ -215,25 +264,39 @@ class TestPage < Camping::UnitTest
215
264
  end
216
265
 
217
266
  def test_spaces
218
- page1 = create(:title => 'TestTitle5')
267
+ page1 = create(:title => 'TestTitle51')
219
268
  assert page1.valid?
220
- assert_equal 'TestTitle5', page1.title
269
+ assert_equal 'TestTitle51', page1.title
221
270
 
222
271
  # test strip
223
- page1 = create(:title => ' TestTitle6 ')
272
+ page1 = create(:title => ' TestTitle52 ')
224
273
  assert page1.valid?
225
- assert_equal 'TestTitle6', page1.title
274
+ assert_equal 'TestTitle52', page1.title
226
275
 
227
- page1 = create(:title => ' Test Title 7 ')
276
+ page1 = create(:title => ' Test Title 53 ')
228
277
  assert page1.valid?
229
- assert_equal 'Test Title 7', page1.title
278
+ assert_equal 'Test Title 53', page1.title
230
279
 
231
280
  # test squeeze
232
- page1 = create(:title => ' Test Title 8 ')
281
+ page1 = create(:title => ' Test Title 54 ')
233
282
  assert page1.valid?
234
- assert_equal 'Test Title 8', page1.title
283
+ assert_equal 'Test Title 54', page1.title
235
284
  end
236
285
 
286
+ def test_basic_update
287
+ # create test page
288
+ page = create(:title => "TestUpdate")
289
+ assert page.valid?
290
+ assert_equal 1, page.version
291
+
292
+ # update body
293
+ page.body = "New body"
294
+ page.save
295
+ assert page.valid?
296
+ assert_equal "TestUpdate", page.title
297
+ assert_equal "New body", page.body
298
+ assert_equal 2, page.version
299
+ end
237
300
 
238
301
  private
239
302
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: junebug-wiki
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.31
7
- date: 2007-04-22 00:00:00 -07:00
6
+ version: 0.0.32
7
+ date: 2007-08-18 00:00:00 -07:00
8
8
  summary: Junebug is a minimalist ruby wiki running on Camping.
9
9
  require_paths:
10
10
  - lib
@@ -71,10 +71,14 @@ files:
71
71
  - test/test_wiki.rb
72
72
  test_files: []
73
73
 
74
- rdoc_options: []
75
-
76
- extra_rdoc_files: []
77
-
74
+ rdoc_options:
75
+ - --main
76
+ - README.txt
77
+ extra_rdoc_files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.txt
81
+ - RELEASE_NOTES.txt
78
82
  executables:
79
83
  - junebug
80
84
  extensions: []
@@ -134,5 +138,5 @@ dependencies:
134
138
  requirements:
135
139
  - - ">="
136
140
  - !ruby/object:Gem::Version
137
- version: 1.2.0
141
+ version: 1.3.0
138
142
  version: