junebug-wiki 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ = 0.0.23 2006-11-28
2
+
3
+ * *EXISTING USERS PLEASE READ THE RELEASE NOTES*
4
+ * Cleaned up redirect handling
5
+ * Renamed 'url' config parameter to 'feedurl'
6
+ * Make edit button always visible
7
+ * Fix for camping error on initial load
8
+ * Allow dashes in wikiwords
9
+ * More tests
10
+
1
11
  = 0.0.22 2006-11-28
2
12
 
3
13
  * *EXISTING USERS PLEASE READ THE RELEASE NOTES*
data/RELEASE_NOTES.txt CHANGED
@@ -1,3 +1,10 @@
1
+ = 0.0.23 2006-11-28
2
+
3
+ Robert Gogolok rightly pointed out that the 'url' parameter in config.yml was confusing, so I renamed it 'feedurl'. You will need to make this change to any existing junebug wikis.
4
+
5
+ Also, as part of this change, I cleaned up the redirect handling code. This might affect users operating a proxied Junebug wiki. I will add some notes to http://www.junebugwiki.com for setting up an apache proxy for Junebug.
6
+
7
+
1
8
  = 0.0.22 2006-11-28
2
9
 
3
10
  The wikiword syntax has changed slightly. Starting in this version, wikiwords can not contain underscores. Furthermore, in page urls, spaces will now be replaced by underscores. Example:
data/deploy/config.yml CHANGED
@@ -30,7 +30,8 @@ dbconnection:
30
30
  # host: localhost
31
31
 
32
32
  # configuring rss
33
- feedtitle: 'Wiki Updates'
34
- url: http://localhost:3301
33
+ # you should only need to change this is you have an external feed manager like feedburner
34
+ feedtitle: Wiki Updates
35
+ feedurl: http://localhost:3301
35
36
  feed: http://localhost:3301/all/feed
36
37
 
@@ -102,6 +102,7 @@ body {
102
102
  color: #333;
103
103
  font-size: 100%;
104
104
  padding: 8px;
105
+ margin-top: 10px;
105
106
  margin-bottom: 10px;
106
107
  line-height: 150%;
107
108
  }
data/lib/junebug.rb CHANGED
@@ -35,7 +35,7 @@ module Junebug
35
35
  end
36
36
 
37
37
  def self.startpage
38
- "#{Junebug.config['url']}/#{Junebug.config['startpage']}"
38
+ "/#{Junebug.config['startpage']}"
39
39
  end
40
40
  end
41
41
 
@@ -2,26 +2,24 @@ require 'junebug/ext/diff'
2
2
 
3
3
  module Junebug::Controllers
4
4
 
5
-
6
5
  class Index < R '/'
7
6
  def get
8
7
  redirect Junebug.startpage
9
8
  end
10
9
  end
11
10
 
12
- class Show < R '/([0-9A-Za-z_]+)', '/([0-9A-Za-z_]+)/(\d+)'
11
+ class Show < R '/([0-9A-Za-z_-]+)', '/([0-9A-Za-z_-]+)/(\d+)'
13
12
  def get page_name, version = nil
14
- #redirect(Edit, page_name, 1) and return unless @page = Page.find_by_title(page_name)
15
- redirect("#{Junebug.config['url']}/#{page_name.gsub(/ /,'+')}/1/edit") and return unless @page = Page.find_by_title(page_name.gsub(/_/,' '))
13
+ redirect(Edit, page_name, 1) and return unless @page = Page.find_by_title(page_name.gsub(/_/,' '))
16
14
  @page_title = @page.title
17
15
  @version = (version.nil? or version == @page.version.to_s) ? @page : @page.versions.find_by_version(version)
18
16
  render :show
19
17
  end
20
18
  end
21
19
 
22
- class Edit < R '/([0-9A-Za-z_]+)/edit', '/([0-9A-Za-z_]+)/(\d+)/edit'
20
+ class Edit < R '/([0-9A-Za-z_-]+)/edit', '/([0-9A-Za-z_-]+)/(\d+)/edit'
23
21
  def get page_name, version = nil
24
- redirect("#{Junebug.config['url']}/login") and return unless logged_in?
22
+ redirect("/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}") and return unless logged_in?
25
23
  page_name_spc = page_name.gsub(/_/,' ')
26
24
  @page = Page.find(:first, :conditions=>['title = ?', page_name_spc])
27
25
  @page = Page.create(:title => page_name_spc, :user_id=>@state.user.id) unless @page
@@ -32,7 +30,7 @@ module Junebug::Controllers
32
30
 
33
31
  # FIXME: no error checking, also no verify quicksave/readonly rights
34
32
  def post page_name
35
- redirect("#{Junebug.config['url']}/login") and return unless logged_in?
33
+ redirect("/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}") and return unless logged_in?
36
34
  page_name_spc = page_name.gsub(/_/,' ')
37
35
  if input.submit == 'save'
38
36
  if ! input.quicksave
@@ -47,32 +45,31 @@ module Junebug::Controllers
47
45
  current_version.update_attributes(attrs)
48
46
  page.without_revision { page.update_attributes(attrs) }
49
47
  end
50
- # redirect Show, input.post_title
51
- redirect "#{Junebug.config['url']}/#{input.post_title.gsub(/ /,'_')}"
48
+ redirect Show, input.post_title.gsub(/ /,'_')
52
49
  else # cancel
53
- redirect "#{Junebug.config['url']}/#{page_name}"
50
+ redirect Show, page_name
54
51
  end
55
52
  end
56
53
  end
57
54
 
58
- class Delete < R '/([0-9A-Za-z_]+)/delete'
55
+ class Delete < R '/([0-9A-Za-z_-]+)/delete'
59
56
  def get page_name
60
- redirect("#{Junebug.config['url']}/login") and return unless logged_in?
57
+ redirect("/login") and return unless logged_in?
61
58
  Page.find_by_title(page_name.gsub(/_/,' ')).destroy() if is_admin?
62
59
  redirect Junebug.startpage
63
60
  end
64
61
 
65
62
  end
66
63
 
67
- class Revert < R '/([0-9A-Za-z_]+)/(\d+)/revert'
64
+ class Revert < R '/([0-9A-Za-z_-]+)/(\d+)/revert'
68
65
  def get page_name, version
69
- redirect("#{Junebug.config['url']}/login") and return unless logged_in?
66
+ redirect("/login") and return unless logged_in?
70
67
  Page.find_by_title(page_name.gsub(/_/,' ')).revert_to!(version) if is_admin?
71
- redirect "#{Junebug.config['url']}/#{page_name}"
68
+ redirect Show, page_name
72
69
  end
73
70
  end
74
71
 
75
- class Versions < R '/([0-9A-Za-z_]+)/versions'
72
+ class Versions < R '/([0-9A-Za-z_-]+)/versions'
76
73
  def get page_name
77
74
  page_name_spc = page_name.gsub(/_/,' ')
78
75
  @page = Page.find_by_title(page_name_spc)
@@ -90,7 +87,7 @@ module Junebug::Controllers
90
87
  end
91
88
  end
92
89
 
93
- class Backlinks < R '/([0-9A-Za-z_]+)/backlinks'
90
+ class Backlinks < R '/([0-9A-Za-z_-]+)/backlinks'
94
91
  def get page_name
95
92
  page_name_spc = page_name.gsub(/_/,' ')
96
93
  @page = Page.find_by_title(page_name_spc)
@@ -108,7 +105,7 @@ module Junebug::Controllers
108
105
  end
109
106
  end
110
107
 
111
- class Diff < R '/([0-9A-Za-z_]+)/(\d+)/(\d+)/diff'
108
+ class Diff < R '/([0-9A-Za-z_-]+)/(\d+)/(\d+)/diff'
112
109
  include HTMLDiff
113
110
  def get page_name, v1, v2
114
111
  page_name_spc = page_name.gsub(/_/,' ')
@@ -164,7 +161,7 @@ module Junebug::Controllers
164
161
  if @user
165
162
  if @user.password == input.password
166
163
  @state.user = @user
167
- input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
164
+ input.return_to.blank? ? redirect(Junebug.startpage) : redirect(input.return_to)
168
165
  return
169
166
  else
170
167
  @notice = 'Authentication failed'
@@ -173,7 +170,7 @@ module Junebug::Controllers
173
170
  @user = User.create :username=>input.username, :password=>input.password
174
171
  if @user.errors.empty?
175
172
  @state.user = @user
176
- input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
173
+ input.return_to.blank? ? redirect(Junebug.startpage) : redirect(input.return_to)
177
174
  return
178
175
  else
179
176
  @notice = @user.errors.full_messages[0]
@@ -186,7 +183,7 @@ module Junebug::Controllers
186
183
  class Logout
187
184
  def get
188
185
  @state.user = nil
189
- input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
186
+ input.return_to.blank? ? redirect(Junebug.startpage) : redirect(input.return_to)
190
187
  end
191
188
  end
192
189
  end
@@ -25,13 +25,13 @@ module Junebug::Models
25
25
  end
26
26
 
27
27
  class Page < Base
28
- belongs_to :user
28
+ belongs_to :user, :class_name=>"Junebug::Models::User" # Hack to prevent camping error on initial load
29
29
  #PAGE_LINK = /\[\[([^\]|]*)[|]?([^\]]*)\]\]/
30
- PAGE_LINK = /\[\[([0-9A-Za-z ]+)[|]?([^\]]*)\]\]/
30
+ PAGE_LINK = /\[\[([0-9A-Za-z -]+)[|]?([^\]]*)\]\]/
31
31
  #before_save { |r| r.title = r.title.underscore }
32
32
  #PAGE_LINK = /([A-Z][a-z]+[A-Z]\w+)/
33
33
  validates_uniqueness_of :title
34
- validates_format_of :title, :with => /^[0-9A-Za-z ]+$/
34
+ validates_format_of :title, :with => /^[0-9A-Za-z -]+$/
35
35
  validates_presence_of :title
36
36
  acts_as_versioned
37
37
  non_versioned_fields.push 'title'
@@ -46,7 +46,7 @@ module Junebug::Models
46
46
  end
47
47
 
48
48
  class Page::Version < Base
49
- belongs_to :user
49
+ belongs_to :user, :class_name=>"Junebug::Models::User" # Hack to prevent camping error on initial load
50
50
  end
51
51
 
52
52
  class CreateJunebug < V 1.0
@@ -2,7 +2,7 @@ module Junebug #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 22
5
+ TINY = 23
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/junebug/views.rb CHANGED
@@ -23,10 +23,10 @@ module Junebug::Views
23
23
  def show
24
24
  _header (@version.version == @page.version ? :backlinks : :show)
25
25
  _body do
26
- _button 'edit', R(Edit, @page.title_url, @version.version), {:style=>'float: right; margin: 0 0 5px 5px;'} if logged_in? && (@version.version == @page.version && (! @page.readonly || is_admin?))
26
+ _button 'edit', R(Edit, @page.title_url, @version.version), {:style=>'float: right; margin: 0 0 5px 5px;'} if (@version.version == @page.version && (! @page.readonly || is_admin?))
27
27
  h1 @page.title
28
28
  _markup @version.body
29
- _button 'edit', R(Edit, @page.title_url, @version.version), {:style=>'float: right; margin: 5px 0 0 5px;'} if logged_in? && (@version.version == @page.version && (! @page.readonly || is_admin?)) && (@version.body && @version.body.size > 200)
29
+ _button 'edit', R(Edit, @page.title_url, @version.version), {:style=>'float: right; margin: 5px 0 0 5px;'} if (@version.version == @page.version && (! @page.readonly || is_admin?)) && (@version.body && @version.body.size > 200)
30
30
  br :clear=>'all'
31
31
  end
32
32
  _footer {
@@ -64,7 +64,7 @@ module Junebug::Views
64
64
  br
65
65
  input :value => @page.title, :name => 'post_title', :size => 30,
66
66
  :type => 'text'
67
- small " word characters [0-9A-Za-z] and spaces only"
67
+ small " word characters (0-9A-Za-z), dashes, and spaces only"
68
68
  }
69
69
  p {
70
70
  label 'Page Content'
@@ -288,14 +288,14 @@ module Junebug::Views
288
288
  xml.feed "xmlns"=>"http://www.w3.org/2005/Atom" do
289
289
 
290
290
  xml.title Junebug.config['feedtitle'] || "Wiki Updates"
291
- xml.id Junebug.config['url'] + '/'
291
+ xml.id Junebug.config['feedurl'] + '/'
292
292
  xml.link "rel" => "self", "href" => Junebug.config['feed']
293
293
 
294
294
  pages = Junebug::Models::Page.find(:all, :order => 'updated_at DESC', :limit => 20)
295
295
  xml.updated pages.first.updated_at.xmlschema
296
296
 
297
297
  pages.each do |page|
298
- url = Junebug.config['url'] + '/' + page.title
298
+ url = Junebug.config['feedurl'] + '/' + page.title
299
299
  xml.entry do
300
300
  xml.id url
301
301
  xml.title page.title
data/test/wiki_test.rb CHANGED
@@ -6,7 +6,7 @@ include Junebug::Models
6
6
 
7
7
  class JunebugTest < Camping::FunctionalTest
8
8
 
9
- fixtures :junebug_users
9
+ #fixtures :junebug_users
10
10
 
11
11
  def setup
12
12
  super
@@ -43,10 +43,6 @@ class JunebugTest < Camping::FunctionalTest
43
43
  assert_response :redirect
44
44
  assert_redirected_to '/login'
45
45
 
46
- post '/Welcome_to_Junebug/edit'
47
- assert_response :redirect
48
- assert_redirected_to '/login'
49
-
50
46
  get '/Welcome_to_Junebug/delete'
51
47
  assert_response :redirect
52
48
  assert_redirected_to '/login'
@@ -55,6 +51,47 @@ class JunebugTest < Camping::FunctionalTest
55
51
  assert_response :redirect
56
52
  assert_redirected_to '/login'
57
53
  end
54
+
55
+ def test_edit_cycle
56
+ get '/Welcome_to_Junebug/edit'
57
+ assert_response :redirect
58
+ assert_redirected_to '/login'
59
+
60
+ post '/login', :username => 'admin', :password => 'password'
61
+ assert_response :redirect
62
+ assert_redirected_to '/Welcome_to_Junebug'
63
+
64
+ get '/Welcome_to_Junebug/edit'
65
+ assert_response :success
66
+
67
+ pagename = "Welcome to Junebug"
68
+ page = Junebug::Models::Page.find_by_title(pagename)
69
+
70
+ # submit nochange
71
+ post "/#{page.title_url}/edit", :post_title=>page.title, :post_body=>page.body, :post_readonly=>page.readonly, :submit=>'save'
72
+ assert_response :redirect
73
+ assert_redirected_to "/#{page.title_url}"
74
+ page2 = Junebug::Models::Page.find_by_title(page.title)
75
+ assert_equal page.title, page2.title
76
+ assert_equal page.body, page2.body
77
+ assert_equal page.user_id, page2.user_id
78
+ assert_equal page.readonly, page2.readonly
79
+ assert_equal page.version+1, page2.version
80
+
81
+ pagename = "Welcome to Junebug"
82
+ page = Junebug::Models::Page.find_by_title(pagename)
83
+
84
+ # submit edited title and body
85
+ post "/#{page.title_url}/edit", :post_title=>page.title+'2', :post_body=>page.body+'2', :post_readonly=>page.readonly, :submit=>'save'
86
+ assert_response :redirect
87
+ assert_redirected_to "/#{page.title_url+'2'}"
88
+ page2 = Junebug::Models::Page.find_by_title(page.title+'2')
89
+ assert_equal page.title+'2', page2.title
90
+ assert_equal page.body+'2', page2.body
91
+ assert_equal page.user_id, page2.user_id
92
+ assert_equal page.readonly, page2.readonly
93
+ assert_equal page.version+1, page2.version
94
+ end
58
95
 
59
96
 
60
97
  #
@@ -98,6 +135,9 @@ class PageTest < Camping::UnitTest
98
135
  page = create(:title => 'Test Page')
99
136
  assert page.valid?
100
137
 
138
+ page = create(:title => 'Test-Page')
139
+ assert page.valid?
140
+
101
141
  page = create(:title => 'test page')
102
142
  assert page.valid?
103
143
 
@@ -128,10 +168,6 @@ class PageTest < Camping::UnitTest
128
168
  page = create(:title => '*')
129
169
  deny page.valid?
130
170
  assert_not_nil page.errors.on(:title)
131
-
132
- page = create(:title => 'page-1')
133
- deny page.valid?
134
- assert_not_nil page.errors.on(:title)
135
171
 
136
172
  page = create(:title => 'page\'s')
137
173
  deny page.valid?
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: junebug-wiki
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.22
6
+ version: 0.0.23
7
7
  date: 2006-11-28 00:00:00 -08:00
8
8
  summary: Junebug is a minimalist ruby wiki running on Camping.
9
9
  require_paths: