junebug-wiki 0.0.27 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ = 0.0.28 2007-01-20
2
+
3
+ * Fix uninitialized constant Mongrel::Camping error
4
+ * Fix rails 2 deprecation warnings on startup
5
+ * Added search based on Barry Arthur's work. Thanks Barry!
6
+
1
7
  = 0.0.27 2006-12-18
2
8
 
3
9
  * Quick bugfix release
data/Manifest.txt CHANGED
@@ -18,7 +18,6 @@ lib/junebug/config.rb
18
18
  lib/junebug/controllers.rb
19
19
  lib/junebug/ext/acts_as_versioned.rb
20
20
  lib/junebug/ext/diff.rb
21
- lib/junebug/ext/mosquito.rb
22
21
  lib/junebug/ext/redcloth.rb
23
22
  lib/junebug/ext/redcloth/all_formats.rb
24
23
  lib/junebug/ext/redcloth/base.rb
@@ -38,4 +37,4 @@ test/fixtures/junebug_page_versions.yml
38
37
  test/fixtures/junebug_pages.yml
39
38
  test/fixtures/junebug_users.yml
40
39
  test/test_helper.rb
41
- test/wiki_test.rb
40
+ test/test_wiki.rb
data/RELEASE_NOTES.txt CHANGED
@@ -1,3 +1,12 @@
1
+ = 0.0.28 2007-01-20
2
+
3
+ Existing users be sure to read the updating page at http://www.junebugwiki.com/JunebugUpdating
4
+
5
+ In particular, don't forget to rake update:everything
6
+
7
+ Also, I upped the required versions of the mongrel, daemons, and activerecord gems. I've been getting lots of bug reports about deprecation warnings and niggling errors that users experienced when they were running newer gems. Particularly with the switch to Rails 1.2. I don't have time to test all combinations, so I'm setting the dependencies to what I'm using.
8
+
9
+
1
10
  = 0.0.26 2006-12-18
2
11
 
3
12
  A couple of changes to the config.yml parameters were made as part of the feed cleanup. If you have an existing Junebug wiki, you may need to make the following changes:
data/Rakefile CHANGED
@@ -47,11 +47,11 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
47
47
  #p.changes - A description of the release's latest changes.
48
48
  #p.spec_extras - A hash of extra values to set in the gemspec.
49
49
  p.extra_deps = [
50
- ['mongrel', '>=0.3.13.3'],
50
+ ['mongrel', '>=1.0'],
51
51
  ['camping', '>=1.5'],
52
- ['daemons', '>=1.0.3'],
52
+ ['daemons', '>=1.0.4'],
53
53
  ['sqlite3-ruby', '>=1.1.0.1'],
54
- ['activerecord', '>=1.14.4']
54
+ ['activerecord', '>=1.15.1']
55
55
  ]
56
56
  end
57
57
 
@@ -20,7 +20,7 @@ input.button {
20
20
  }
21
21
 
22
22
  input, textarea {
23
- padding: 2px;
23
+ padding: 4px 2px 1px 2px;
24
24
  margin-bottom: 5px;
25
25
  /* font-family:"Bitstream Vera Sans Mono", "Monaco", "Courier", monospace;*/
26
26
  }
@@ -63,7 +63,7 @@ body {
63
63
  #hd {
64
64
  /* border-top: 6px solid #809fff;*/
65
65
  background-color: #6677aa;
66
- padding: 8px 25px;
66
+ padding: 8px 25px 10px;
67
67
  color: #ffffff;
68
68
  margin-bottom: 10px;
69
69
  }
@@ -72,6 +72,15 @@ body {
72
72
  float: right;
73
73
  }
74
74
 
75
+ #hd #search {
76
+ float: right;
77
+ margin-top: 5px;
78
+ }
79
+
80
+ #hd #search input {
81
+ margin-bottom: 0px;
82
+ }
83
+
75
84
  #hd a {
76
85
  color: #ffffff;
77
86
  }
@@ -157,7 +166,7 @@ body {
157
166
  /* WIKI CONTENT STYLES */
158
167
  .content {
159
168
  font-size: 107%;
160
- padding: 25px;
169
+ padding: 20px 25px;
161
170
  min-height: 300px;
162
171
  }
163
172
 
data/lib/junebug.rb CHANGED
@@ -14,6 +14,7 @@ require 'junebug/controllers'
14
14
 
15
15
  require 'yaml'
16
16
  require 'mongrel'
17
+ require 'mongrel/camping'
17
18
  require 'fileutils'
18
19
 
19
20
  module Junebug
@@ -87,6 +87,15 @@ module Junebug::Controllers
87
87
  end
88
88
  end
89
89
 
90
+ class Search
91
+ def post
92
+ @search_term = input.q
93
+ @page_title = "Search Results for: #{@search_term}"
94
+ @pages = Page.find(:all, :conditions => ["body LIKE ? OR title LIKE ?", "%#{@search_term}%", "%#{@search_term}%" ])
95
+ render :search
96
+ end
97
+ end
98
+
90
99
  class Backlinks < R '/([0-9A-Za-z_-]+)/backlinks'
91
100
  def get page_name
92
101
  page_name_spc = page_name.gsub(/_/,' ')
@@ -137,11 +146,11 @@ module Junebug::Controllers
137
146
  class Static < R '(/images/.+)', '(/style/.+)'
138
147
  MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript', '.jpg' => 'image/jpeg'}
139
148
  #PATH = __FILE__[/(.*)\//, 1]
140
- PATH = ENV['JUNEBUG_ROOT'] || '.'
149
+ PATH = ENV['JUNEBUG_ROOT'] || File.expand_path('.')
141
150
 
142
151
  def get(path)
143
152
  @headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
144
- unless path =~ /\.\./ # sample test to prevent directory traversal attacks
153
+ unless path.include? '..' # sample test to prevent directory traversal attacks
145
154
  @headers['X-Sendfile'] = "#{PATH}/public#{path}"
146
155
  else
147
156
  "404 - Invalid path"
@@ -25,7 +25,7 @@ module Junebug::Models
25
25
  end
26
26
 
27
27
  class Page < Base
28
- belongs_to :user, :class_name=>"Junebug::Models::User" # Hack to prevent camping error on initial load
28
+ belongs_to :user, :class_name=>"Junebug::Models::User", :foreign_key=>'user_id' # Hack to prevent camping error on initial load
29
29
  #PAGE_LINK = /\[\[([^\]|]*)[|]?([^\]]*)\]\]/
30
30
  PAGE_LINK = /\[\[([0-9A-Za-z -]+)[|]?([^\]]*)\]\]/
31
31
  #before_save { |r| r.title = r.title.underscore }
@@ -46,7 +46,7 @@ module Junebug::Models
46
46
  end
47
47
 
48
48
  class Page::Version < Base
49
- belongs_to :user, :class_name=>"Junebug::Models::User" # Hack to prevent camping error on initial load
49
+ belongs_to :user, :class_name=>"Junebug::Models::User", :foreign_key=>'user_id' # Hack to prevent camping error on initial load
50
50
  end
51
51
 
52
52
  class CreateJunebug < V 1.0
@@ -90,7 +90,12 @@ module Junebug::Models
90
90
 
91
91
  # Install some default pages
92
92
  pages_file = File.dirname(__FILE__) + "/../../dump/junebug_pages.yml"
93
- YAML.load_file(pages_file).each {|page_data|Page.create(page_data) } if File.exist?(pages_file)
93
+ if File.exist?(pages_file)
94
+ puts "Loading fixtures"
95
+ YAML.load_file(pages_file).each {|page_data|Page.create(page_data) }
96
+ else
97
+ puts "Could not find fixtures: #{pages_file}"
98
+ end
94
99
  end
95
100
  def self.down
96
101
  drop_table :junebug_pages
@@ -1,4 +1,5 @@
1
1
  require 'junebug'
2
+ require 'junebug/config'
2
3
 
3
4
  namespace :update do
4
5
 
@@ -2,7 +2,7 @@ module Junebug #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 27
5
+ TINY = 28
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/junebug/views.rb CHANGED
@@ -120,6 +120,25 @@ module Junebug::Views
120
120
  end
121
121
 
122
122
 
123
+ def search
124
+ _header :show
125
+ _body do
126
+ h1 "Search results"
127
+
128
+ form :action => R(Search), :method => 'post' do
129
+ input :name => 'q', :type => 'text', :value=>@search_term, :accesskey => 's'
130
+ input :type => 'submit', :name => 'search', :value => 'Search',
131
+ :style=>'margin: 0 0 5px 5px;'
132
+ end
133
+
134
+ ul {
135
+ @pages.each { |p| li{ a p.title, :href => R(Show, p.title_url) } }
136
+ }
137
+ end
138
+ _footer { '' }
139
+ end
140
+
141
+
123
142
  def backlinks
124
143
  _header :show
125
144
  _body do
@@ -246,13 +265,24 @@ module Junebug::Views
246
265
  span :id=>'navlinks' do
247
266
  a 'Home', :href => R(Show, Junebug.config['startpage'])
248
267
  text ' | '
249
- a 'RecentChanges', :href => R(Recent)
268
+ a 'Recent Changes', :href => R(Recent)
250
269
  text ' | '
251
270
  a 'All Pages', :href => R(List)
252
271
  text ' | '
253
272
  a 'Help', :href => R(Show, "Junebug_help")
254
273
  end
255
-
274
+
275
+ span :id=>'search' do
276
+ text 'Search: '
277
+ form :action => R(Search), :method => 'post' do
278
+ input :name => 'q', :type => 'text', :value=>(''), :accesskey => 's'
279
+ #input :type => 'submit', :name => 'search', :value => 'Search',
280
+ # :style=>'margin: 0 0 5px 5px;'
281
+ end
282
+ end
283
+
284
+ br :clear => 'all'
285
+
256
286
  # if type == :static
257
287
  # h1 page_title
258
288
  # elsif type == :backlinks
@@ -1,19 +1,19 @@
1
- require File.dirname(__FILE__) + "/../lib/junebug/ext/mosquito"
1
+ require 'rubygems'
2
+ require 'mosquito'
2
3
  require File.dirname(__FILE__) + "/../lib/junebug"
3
4
 
4
5
  Junebug.create
5
6
  include Junebug::Models
6
7
 
7
- class JunebugTest < Camping::FunctionalTest
8
+ class TestJunebug < Camping::FunctionalTest
8
9
 
9
10
  #fixtures :junebug_users
10
-
11
11
  def setup
12
12
  super
13
13
  end
14
14
 
15
15
  def test_index
16
- get
16
+ get '/'
17
17
  assert_response :redirect
18
18
  assert_redirected_to '/Welcome_to_Junebug'
19
19
  end
@@ -91,6 +91,10 @@ class JunebugTest < Camping::FunctionalTest
91
91
  assert_equal page.user_id, page2.user_id
92
92
  assert_equal page.readonly, page2.readonly
93
93
  assert_equal page.version+1, page2.version
94
+
95
+ # set it back
96
+ post "/#{page2.title_url}/edit", :post_title=>page.title, :post_body=>page.body, :post_readonly=>page.readonly, :submit=>'save'
97
+
94
98
  end
95
99
 
96
100
 
@@ -107,10 +111,14 @@ class JunebugTest < Camping::FunctionalTest
107
111
  #
108
112
  end
109
113
 
110
- class PageTest < Camping::UnitTest
114
+ class TestPage < Camping::UnitTest
111
115
 
112
116
  fixtures :junebug_users, :junebug_pages, :junebug_page_versions
113
-
117
+
118
+ def setup
119
+ super
120
+ end
121
+
114
122
  def test_create
115
123
  page = create
116
124
  assert page.valid?
@@ -179,16 +187,16 @@ class PageTest < Camping::UnitTest
179
187
  end
180
188
 
181
189
  def test_unique_title
182
- page1 = create(:title => 'TestTitle')
190
+ page1 = create(:title => 'TestTitle12')
183
191
  assert page1.valid?
184
192
 
185
193
  # identical
186
- page2 = create
194
+ page2 = create(:title => 'TestTitle12')
187
195
  deny page2.valid?
188
196
  assert_not_nil page2.errors.on(:title)
189
197
 
190
198
  # lowercase
191
- page2 = create(:title => 'testtitle')
199
+ page2 = create(:title => 'testtitle12')
192
200
  assert page2.valid?
193
201
  end
194
202
 
@@ -275,10 +283,11 @@ class UserTest < Camping::UnitTest
275
283
  end
276
284
 
277
285
  def test_spaces
278
- user = create(:username => 'aaaaaa ', :password =>'aaaaaa ')
286
+ user = create(:username => 'bbbbbb ', :password =>'bbbbbb ')
287
+ # puts user.inspect
279
288
  assert user.valid?
280
- assert user.username == 'aaaaaa'
281
- assert user.password == 'aaaaaa'
289
+ assert user.username == 'bbbbbb'
290
+ assert user.password == 'bbbbbb'
282
291
  end
283
292
 
284
293
  def test_lowercase
metadata CHANGED
@@ -3,8 +3,8 @@ 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.27
7
- date: 2006-12-18 00:00:00 -08:00
6
+ version: 0.0.28
7
+ date: 2007-01-20 00:00:00 -08:00
8
8
  summary: Junebug is a minimalist ruby wiki running on Camping.
9
9
  require_paths:
10
10
  - lib
@@ -49,7 +49,6 @@ files:
49
49
  - lib/junebug/controllers.rb
50
50
  - lib/junebug/ext/acts_as_versioned.rb
51
51
  - lib/junebug/ext/diff.rb
52
- - lib/junebug/ext/mosquito.rb
53
52
  - lib/junebug/ext/redcloth.rb
54
53
  - lib/junebug/ext/redcloth/all_formats.rb
55
54
  - lib/junebug/ext/redcloth/base.rb
@@ -69,9 +68,9 @@ files:
69
68
  - test/fixtures/junebug_pages.yml
70
69
  - test/fixtures/junebug_users.yml
71
70
  - test/test_helper.rb
72
- - test/wiki_test.rb
73
- test_files:
74
- - test/wiki_test.rb
71
+ - test/test_wiki.rb
72
+ test_files: []
73
+
75
74
  rdoc_options: []
76
75
 
77
76
  extra_rdoc_files: []
@@ -90,7 +89,7 @@ dependencies:
90
89
  requirements:
91
90
  - - ">="
92
91
  - !ruby/object:Gem::Version
93
- version: 0.3.13.3
92
+ version: "1.0"
94
93
  version:
95
94
  - !ruby/object:Gem::Dependency
96
95
  name: camping
@@ -108,7 +107,7 @@ dependencies:
108
107
  requirements:
109
108
  - - ">="
110
109
  - !ruby/object:Gem::Version
111
- version: 1.0.3
110
+ version: 1.0.4
112
111
  version:
113
112
  - !ruby/object:Gem::Dependency
114
113
  name: sqlite3-ruby
@@ -126,5 +125,5 @@ dependencies:
126
125
  requirements:
127
126
  - - ">="
128
127
  - !ruby/object:Gem::Version
129
- version: 1.14.4
128
+ version: 1.15.1
130
129
  version:
@@ -1,210 +0,0 @@
1
- %w(
2
- rubygems
3
- test/unit
4
- active_record
5
- active_record/fixtures
6
- active_support/binding_of_caller
7
- camping
8
- fileutils
9
- stringio
10
- cgi
11
- ).each { |lib| require lib }
12
-
13
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ":memory:")
14
- ActiveRecord::Base.logger = Logger.new("test/test.log")
15
-
16
- Test::Unit::TestCase.fixture_path = "test/fixtures/"
17
-
18
- class Test::Unit::TestCase #:nodoc:
19
- def create_fixtures(*table_names)
20
- if block_given?
21
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
22
- else
23
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
24
- end
25
- end
26
-
27
- # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
28
- self.use_transactional_fixtures = true
29
- # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
30
- self.use_instantiated_fixtures = false
31
- end
32
-
33
- class MockRequest
34
- def initialize
35
- @headers = {
36
- 'SERVER_NAME' => 'localhost',
37
- 'PATH_INFO' => '',
38
- 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
39
- 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060214 Camino/1.0',
40
- 'SCRIPT_NAME' => '/',
41
- 'SERVER_PROTOCOL' => 'HTTP/1.1',
42
- 'HTTP_CACHE_CONTROL' => 'max-age=0',
43
- 'HTTP_ACCEPT_LANGUAGE' => 'en,ja;q=0.9,fr;q=0.9,de;q=0.8,es;q=0.7,it;q=0.7,nl;q=0.6,sv;q=0.5,nb;q=0.5,da;q=0.4,fi;q=0.3,pt;q=0.3,zh-Hans;q=0.2,zh-Hant;q=0.1,ko;q=0.1',
44
- 'HTTP_HOST' => 'localhost',
45
- 'REMOTE_ADDR' => '127.0.0.1',
46
- 'SERVER_SOFTWARE' => 'Mongrel 0.3.12.4',
47
- 'HTTP_KEEP_ALIVE' => '300',
48
- 'HTTP_REFERER' => 'http://localhost/',
49
- 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
50
- 'HTTP_VERSION' => 'HTTP/1.1',
51
- 'REQUEST_URI' => '/',
52
- 'SERVER_PORT' => '80',
53
- 'GATEWAY_INTERFACE' => 'CGI/1.2',
54
- 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
55
- 'HTTP_CONNECTION' => 'keep-alive',
56
- 'REQUEST_METHOD' => 'GET',
57
- }
58
- end
59
-
60
- def set(key, val)
61
- @headers[key] = val
62
- end
63
-
64
- def to_hash
65
- @headers
66
- end
67
-
68
- def [](key)
69
- @headers[key]
70
- end
71
-
72
- def []=(key, value)
73
- @headers[key] = value
74
- end
75
-
76
- ##
77
- # Allow getters like this:
78
- # o.REQUEST_METHOD
79
-
80
- def method_missing(method_name, *args)
81
- if @headers.has_key?(method_name.to_s)
82
- return @headers[method_name.to_s]
83
- else
84
- super(method_name, args)
85
- end
86
- end
87
-
88
- end
89
-
90
-
91
- module Camping
92
-
93
- class Test < Test::Unit::TestCase
94
-
95
- def test_dummy; end
96
-
97
- def deny(condition, message='')
98
- assert !condition, message
99
- end
100
-
101
- # http://project.ioni.st/post/217#post-217
102
- #
103
- # def test_new_publication
104
- # assert_difference(Publication, :count) do
105
- # post :create, :publication_title => ...
106
- # # ...
107
- # end
108
- # end
109
- #
110
- # Is the number of items different?
111
- #
112
- # Can be used for increment and decrement.
113
- #
114
- def assert_difference(object, method = :count, difference = 1)
115
- initial_value = object.send(method)
116
- yield
117
- assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
118
- end
119
- def assert_no_difference(object, method, &block)
120
- assert_difference object, method, 0, &block
121
- end
122
-
123
- end
124
-
125
- class FunctionalTest < Test
126
-
127
- def setup
128
- @class_name_abbr = self.class.name.gsub(/Test$/, '')
129
- @request = MockRequest.new
130
- end
131
-
132
- def get(url='/')
133
- send_request url, {}, 'GET'
134
- end
135
-
136
- def post(url, post_vars={})
137
- send_request url, post_vars, 'POST'
138
- end
139
-
140
- def send_request(url, post_vars, method)
141
- @request['REQUEST_METHOD'] = method
142
- @request['SCRIPT_NAME'] = '/' + @class_name_abbr.downcase
143
- @request['PATH_INFO'] = '/' + url
144
- @request['REQUEST_URI'] = [@request.SCRIPT_NAME, @request.PATH_INFO].join('')
145
-
146
- @request['HTTP_COOKIE'] = @cookies.map {|k,v| "#{k}=#{v}" }.join('; ') if @cookies
147
-
148
- @response = eval("#{@class_name_abbr}.run StringIO.new('#{qs_build(post_vars)}'), @request")
149
-
150
- @cookies = @response.headers['Set-Cookie'].inject(@cookies||{}) do |res,header|
151
- data = header.split(';').first
152
- name, value = data.split('=')
153
- res[name] = value
154
- res
155
- end
156
-
157
- if @response.headers['X-Sendfile']
158
- @response.body = File.read(@response.headers['X-Sendfile'])
159
- end
160
- end
161
-
162
- def assert_response(status_code)
163
- case status_code
164
- when :success
165
- assert_equal 200, @response.status
166
- when :redirect
167
- assert_equal 302, @response.status
168
- when :error
169
- assert @response.status >= 500
170
- else
171
- assert_equal status_code, @response.status
172
- end
173
- end
174
-
175
- def assert_match_body(regex, message=nil)
176
- assert_match regex, @response.body, message
177
- end
178
- def assert_no_match_body(regex, message=nil)
179
- assert_no_match regex, @response.body, message
180
- end
181
-
182
- def assert_redirected_to(url, message=nil)
183
- assert_equal url,
184
- @response.headers['Location'].path.gsub(%r!/#{@class_name_abbr.downcase}!, ''),
185
- message
186
- end
187
-
188
- def assert_cookie(name, pat, message=nil)
189
- assert_match pat, @cookies[name], message
190
- end
191
-
192
- def test_dummy; end
193
-
194
- private
195
-
196
- def qs_build(var_hash)
197
- var_hash.map do |k, v|
198
- [Camping.escape(k.to_s), Camping.escape(v.to_s)].join('=')
199
- end.join('&')
200
- end
201
-
202
- end
203
-
204
- class UnitTest < Test
205
-
206
- def test_dummy; end
207
-
208
- end
209
-
210
- end