vanilla 1.17.2 → 1.17.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "rubygems"
2
- require "rake/gempackagetask"
3
- require "rake/rdoctask"
2
+ require "rubygems/package_task"
3
+ require "rdoc/task"
4
4
 
5
5
  require "bundler/setup"
6
6
  require "vanilla"
@@ -75,6 +75,7 @@ if Object.const_defined?(:Gem)
75
75
  s.add_dependency("parslet", ">= 1.2.0")
76
76
  s.add_dependency("rack-test", ">=0.5.7")
77
77
 
78
+ s.add_development_dependency("rake", ">= 0.9.1")
78
79
  s.add_development_dependency("kintama", ">= 0.1.7") # add any other gems for testing/development
79
80
  s.add_development_dependency("mocha")
80
81
  s.add_development_dependency("capybara")
@@ -90,9 +91,9 @@ if Object.const_defined?(:Gem)
90
91
  # be automatically building a gem for this project. If you're not
91
92
  # using GitHub, edit as appropriate.
92
93
  #
93
- # To publish your gem online, install the 'gemcutter' gem; Read more
94
+ # To publish your gem online, install the 'gemcutter' gem; Read more
94
95
  # about that here: http://gemcutter.org/pages/gem_docs
95
- Rake::GemPackageTask.new(spec) do |pkg|
96
+ Gem::PackageTask.new(spec) do |pkg|
96
97
  pkg.gem_spec = spec
97
98
  end
98
99
 
@@ -148,4 +149,4 @@ if Object.const_defined?(:Gem)
148
149
  end
149
150
  else
150
151
  puts "Gem management tasks unavailable, as rubygems was not fully loaded."
151
- end
152
+ end
@@ -17,6 +17,7 @@ module Vanilla
17
17
  @snips = app.soup[@criteria]
18
18
  end
19
19
  end
20
+ @count = params[:count] || @snips.length
20
21
  end
21
22
 
22
23
  def to_s
@@ -31,7 +32,7 @@ module Vanilla
31
32
  private
32
33
 
33
34
  def snips
34
- @snips.sort_by { |s| atom_time(s.updated_at) }.reverse
35
+ @snips.sort_by { |s| atom_time(s.updated_at) }.reverse[0, @count]
35
36
  end
36
37
 
37
38
  def most_recent_updated_at
@@ -63,15 +64,21 @@ module Vanilla
63
64
  end
64
65
 
65
66
  def externalise_links(content)
66
- content.gsub(/(href|src)=(["'])(\/?.*)\2/) do
67
- type, quote, link = $1, $2, $3
68
- if link =~ /^http/
69
- "#{type}=#{quote}#{link}#{quote}"
70
- else
71
- absolute_link = "http://#{domain}" + (link =~ /^\// ? "" : "/") + link
72
- "#{type}=#{quote}#{absolute_link}#{quote}"
73
- end
67
+ # "([^"]*)"
68
+ content.gsub(/(href|src)="([^"]*)"/) do
69
+ externalised_link($1, '"', $2)
70
+ end.gsub(/(href|src)='([^']*)'/) do
71
+ externalised_link($1, "'", $2)
72
+ end
73
+ end
74
+
75
+ def externalised_link(type, quote, link)
76
+ if link =~ /^http/
77
+ "#{type}=#{quote}#{link}#{quote}"
78
+ else
79
+ absolute_link = "http://#{domain}" + (link =~ /^\// ? "" : "/") + link
80
+ "#{type}=#{quote}#{absolute_link}#{quote}"
74
81
  end
75
82
  end
76
83
  end
77
- end
84
+ end
@@ -2,6 +2,7 @@ module Vanilla
2
2
  module Routing
3
3
 
4
4
  def url_to(snip_name, part=nil)
5
+ return "/" if snip_name == config.root_snip && part.nil?
5
6
  url = "/#{snip_name.gsub(" ", "+")}"
6
7
  url += "/#{part}" if part
7
8
  url
@@ -16,7 +16,7 @@ module Vanilla
16
16
  # to the application's soup without actually affecting the
17
17
  # app's content.
18
18
  config.soups ||= []
19
- config.soups.unshift test_soup_path
19
+ config.soups.unshift temp_soup_path
20
20
  end
21
21
  @__app = klass.new
22
22
  end
@@ -24,7 +24,7 @@ module Vanilla
24
24
  end
25
25
 
26
26
  def vanilla_setup
27
- FileUtils.mkdir_p(test_soup_path)
27
+ FileUtils.mkdir_p(temp_soup_path)
28
28
  end
29
29
 
30
30
  def vanilla_reset
@@ -49,12 +49,12 @@ module Vanilla
49
49
  app.soup << params
50
50
  end
51
51
 
52
- def test_soup_path
52
+ def temp_soup_path
53
53
  File.expand_path(File.join(Dir.tmpdir, "soup"))
54
54
  end
55
55
 
56
56
  def vanilla_teardown
57
- FileUtils.rm_rf(test_soup_path)
57
+ FileUtils.rm_rf(temp_soup_path)
58
58
  end
59
59
 
60
60
  def stub_app_soup(*snips)
data/lib/vanilla.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Vanilla
2
- VERSION = "1.17.2"
2
+ VERSION = "1.17.3"
3
3
 
4
4
  autoload :Renderers, "vanilla/renderers"
5
5
  autoload :App, "vanilla/app"
@@ -20,4 +20,4 @@ module Vanilla
20
20
  @apps ||= []
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -4,9 +4,9 @@ class Index < Dynasnip
4
4
  def get(*args)
5
5
  list = app.soup.all_snips.sort_by { |a| a.updated_at || Time.at(0) }.reverse.map { |snip|
6
6
  %{<li>{link_to "#{snip.name}"}</li>}
7
- }
7
+ }.join
8
8
  %{<ol id="index">#{list}</ol>}
9
9
  end
10
10
 
11
11
  self
12
- end
12
+ end
@@ -107,6 +107,16 @@ context "An atom feed" do
107
107
  assert_same_elements ["a", "c"], feed.entries.map { |e| e.title }
108
108
  end
109
109
 
110
+ should "allow limiting of the number of snips" do
111
+ stub_app_soup({:name => "a", :content => "x", :kind => "blog", :updated_at => (Time.now - 10)},
112
+ {:name => "b", :content => "x", :kind => "blog", :updated_at => (Time.now - 20)})
113
+
114
+ feed_xml = app.atom_feed(:domain => "whatever", :matching => {:kind => "blog"}, :count => 1).to_s
115
+ feed = Atom::Feed.load_feed(feed_xml)
116
+ assert_equal 1, feed.entries.length
117
+ assert_equal "a", feed.entries.first.title
118
+ end
119
+
110
120
  should "set updated to be the latest updated_at of the included snips" do
111
121
  snip_a_data = {:name => "a", :content => "x", :updated_at => Time.parse("2011-05-22 12:00")}
112
122
  snip_b_data = {:name => "b", :content => "x", :updated_at => Time.parse("2011-05-23 12:34")}
@@ -211,4 +221,4 @@ context "An atom feed" do
211
221
  feed_xml = app.atom_feed(:domain => "yourdomain.example.com").to_s
212
222
  Atom::Feed.load_feed(feed_xml)
213
223
  end
214
- end
224
+ end
@@ -27,4 +27,14 @@ context "Parsing routes" do
27
27
  end
28
28
  end
29
29
 
30
- end
30
+ end
31
+
32
+ context "Generating routes" do
33
+ should "generate root path for root snip" do
34
+ assert_equal "/", app.url_to(app.config.root_snip)
35
+ end
36
+
37
+ should "include the full snip and part if the root snip part was requested" do
38
+ assert_equal "/start/part", app.url_to(app.config.root_snip, "part")
39
+ end
40
+ end
@@ -25,4 +25,15 @@ context "The feed dynasnip" do
25
25
  feed = Atom::Feed.load_feed(page.source)
26
26
  assert_equal "<p>This is <em>the</em> content</p>", feed.entries.first.content
27
27
  end
28
+
29
+ should "ensure relative links are made absolute" do
30
+ stub_app_soup({:name => "Hello", :content => "a [relative](/link)",
31
+ :render_as => "markdown", :kind => "blog"},
32
+ Feed.snip_attributes)
33
+
34
+ visit "/feed.xml"
35
+
36
+ feed = Atom::Feed.load_feed(page.source)
37
+ assert_equal %{<p>a <a href="http://yourdomain.example.com/link">relative</a></p>}, feed.entries.first.content
38
+ end
28
39
  end
@@ -41,4 +41,4 @@ context "The index dynasnip" do
41
41
  def snip(attributes)
42
42
  Soup::Snip.new(attributes, nil)
43
43
  end
44
- end
44
+ end
@@ -14,7 +14,7 @@ module TestHelper
14
14
  end
15
15
 
16
16
  Kintama.include TestHelper
17
- Kintama.include Capybara
17
+ Kintama.include Capybara::DSL
18
18
 
19
19
  Kintama.setup do
20
20
  vanilla_setup
@@ -23,4 +23,4 @@ end
23
23
 
24
24
  Kintama.teardown do
25
25
  vanilla_teardown
26
- end
26
+ end
metadata CHANGED
@@ -1,217 +1,232 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vanilla
3
- version: !ruby/object:Gem::Version
4
- hash: 87
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.17.3
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 17
9
- - 2
10
- version: 1.17.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - James Adam
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-01 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rack
23
- prerelease: false
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 57
30
- segments:
31
- - 0
32
- - 9
33
- - 1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.9.1
35
22
  type: :runtime
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: soup
39
23
  prerelease: false
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
41
25
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 5
46
- segments:
47
- - 1
48
- - 0
49
- - 9
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: soup
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
50
37
  version: 1.0.9
51
38
  type: :runtime
52
- requirement: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: ratom
55
39
  prerelease: false
56
- version_requirements: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
57
41
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 25
62
- segments:
63
- - 0
64
- - 3
65
- - 5
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.9
46
+ - !ruby/object:Gem::Dependency
47
+ name: ratom
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
66
53
  version: 0.3.5
67
54
  type: :runtime
68
- requirement: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: RedCloth
71
55
  prerelease: false
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: RedCloth
64
+ requirement: !ruby/object:Gem::Requirement
73
65
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 57
78
- segments:
79
- - 4
80
- - 1
81
- - 1
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
82
69
  version: 4.1.1
83
70
  type: :runtime
84
- requirement: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: BlueCloth
87
71
  prerelease: false
88
- version_requirements: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 4.1.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: BlueCloth
80
+ requirement: !ruby/object:Gem::Requirement
89
81
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- hash: 23
94
- segments:
95
- - 1
96
- - 0
97
- - 0
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
98
85
  version: 1.0.0
99
86
  type: :runtime
100
- requirement: *id005
101
- - !ruby/object:Gem::Dependency
102
- name: haml
103
87
  prerelease: false
104
- version_requirements: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: haml
96
+ requirement: !ruby/object:Gem::Requirement
105
97
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 5
110
- segments:
111
- - 3
112
- - 1
113
- version: "3.1"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '3.1'
114
102
  type: :runtime
115
- requirement: *id006
116
- - !ruby/object:Gem::Dependency
117
- name: parslet
118
103
  prerelease: false
119
- version_requirements: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
120
105
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 31
125
- segments:
126
- - 1
127
- - 2
128
- - 0
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '3.1'
110
+ - !ruby/object:Gem::Dependency
111
+ name: parslet
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
129
117
  version: 1.2.0
130
118
  type: :runtime
131
- requirement: *id007
132
- - !ruby/object:Gem::Dependency
133
- name: rack-test
134
119
  prerelease: false
135
- version_requirements: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
136
121
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 5
141
- segments:
142
- - 0
143
- - 5
144
- - 7
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 1.2.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: rack-test
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
145
133
  version: 0.5.7
146
134
  type: :runtime
147
- requirement: *id008
148
- - !ruby/object:Gem::Dependency
149
- name: kintama
150
135
  prerelease: false
151
- version_requirements: &id009 !ruby/object:Gem::Requirement
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: 0.5.7
142
+ - !ruby/object:Gem::Dependency
143
+ name: rake
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: 0.9.1
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: 0.9.1
158
+ - !ruby/object:Gem::Dependency
159
+ name: kintama
160
+ requirement: !ruby/object:Gem::Requirement
152
161
  none: false
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- hash: 21
157
- segments:
158
- - 0
159
- - 1
160
- - 7
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
161
165
  version: 0.1.7
162
166
  type: :development
163
- requirement: *id009
164
- - !ruby/object:Gem::Dependency
165
- name: mocha
166
167
  prerelease: false
167
- version_requirements: &id010 !ruby/object:Gem::Requirement
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.1.7
174
+ - !ruby/object:Gem::Dependency
175
+ name: mocha
176
+ requirement: !ruby/object:Gem::Requirement
168
177
  none: false
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- hash: 3
173
- segments:
174
- - 0
175
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
176
182
  type: :development
177
- requirement: *id010
178
- - !ruby/object:Gem::Dependency
179
- name: capybara
180
183
  prerelease: false
181
- version_requirements: &id011 !ruby/object:Gem::Requirement
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: capybara
192
+ requirement: !ruby/object:Gem::Requirement
182
193
  none: false
183
- requirements:
184
- - - ">="
185
- - !ruby/object:Gem::Version
186
- hash: 3
187
- segments:
188
- - 0
189
- version: "0"
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
190
198
  type: :development
191
- requirement: *id011
192
- - !ruby/object:Gem::Dependency
193
- name: launchy
194
199
  prerelease: false
195
- version_requirements: &id012 !ruby/object:Gem::Requirement
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: launchy
208
+ requirement: !ruby/object:Gem::Requirement
196
209
  none: false
197
- requirements:
198
- - - ">="
199
- - !ruby/object:Gem::Version
200
- hash: 3
201
- segments:
202
- - 0
203
- version: "0"
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
204
214
  type: :development
205
- requirement: *id012
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
206
222
  description:
207
223
  email: james@lazyatom.com.com
208
- executables:
224
+ executables:
209
225
  - vanilla
210
226
  extensions: []
211
-
212
- extra_rdoc_files:
227
+ extra_rdoc_files:
213
228
  - README
214
- files:
229
+ files:
215
230
  - Rakefile
216
231
  - README
217
232
  - .gemtest
@@ -298,40 +313,36 @@ files:
298
313
  - pristine_app/soups/tutorial/tutorial.snip.markdown
299
314
  - pristine_app/soups/tutorial/vanilla-rb.snip
300
315
  - pristine_app/soups/tutorial/vanilla.snip
301
- has_rdoc: true
302
316
  homepage: http://github.com/lazyatom/vanilla-rb
303
317
  licenses: []
304
-
305
318
  post_install_message:
306
- rdoc_options:
319
+ rdoc_options:
307
320
  - --main
308
321
  - README
309
- require_paths:
322
+ require_paths:
310
323
  - lib
311
- required_ruby_version: !ruby/object:Gem::Requirement
324
+ required_ruby_version: !ruby/object:Gem::Requirement
312
325
  none: false
313
- requirements:
314
- - - ">="
315
- - !ruby/object:Gem::Version
316
- hash: 3
317
- segments:
326
+ requirements:
327
+ - - ! '>='
328
+ - !ruby/object:Gem::Version
329
+ version: '0'
330
+ segments:
318
331
  - 0
319
- version: "0"
320
- required_rubygems_version: !ruby/object:Gem::Requirement
332
+ hash: 110256896921410377
333
+ required_rubygems_version: !ruby/object:Gem::Requirement
321
334
  none: false
322
- requirements:
323
- - - ">="
324
- - !ruby/object:Gem::Version
325
- hash: 3
326
- segments:
335
+ requirements:
336
+ - - ! '>='
337
+ - !ruby/object:Gem::Version
338
+ version: '0'
339
+ segments:
327
340
  - 0
328
- version: "0"
341
+ hash: 110256896921410377
329
342
  requirements: []
330
-
331
343
  rubyforge_project: vanilla
332
- rubygems_version: 1.6.2
344
+ rubygems_version: 1.8.23
333
345
  signing_key:
334
346
  specification_version: 3
335
347
  summary: A bliki-type web content thing.
336
348
  test_files: []
337
-