vanilla 1.17.13 → 2.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +8 -6
- data/Rakefile +8 -8
- data/bin/vanilla +2 -3
- data/lib/vanilla.rb +1 -1
- data/lib/vanilla/app.rb +1 -1
- data/lib/vanilla/atom_feed.rb +2 -2
- data/lib/vanilla/config.rb +8 -8
- data/lib/vanilla/dynasnip.rb +2 -2
- data/lib/vanilla/renderers/base.rb +2 -1
- data/lib/vanilla/renderers/erb.rb +2 -3
- data/lib/vanilla/snip_reference_parser.rb +9 -9
- data/pristine_app/Gemfile +1 -1
- data/pristine_app/README +6 -6
- data/pristine_app/config.ru +3 -1
- data/pristine_app/soups/extras/comments.rb +6 -6
- data/pristine_app/soups/extras/kind.rb +4 -4
- data/pristine_app/soups/extras/url_to.rb +1 -1
- data/test/core/atom_feed_test.rb +39 -39
- data/test/core/configuration_test.rb +2 -2
- data/test/core/snip_inclusion_test.rb +9 -9
- data/test/core/snip_reference_parser_test.rb +66 -66
- data/test/core/test_helper.rb +2 -2
- data/test/core/vanilla_app_test.rb +7 -7
- data/test/core/vanilla_presenting_test.rb +13 -13
- data/test/pristine_app/current_snip_test.rb +8 -8
- data/test/pristine_app/feed_test.rb +8 -8
- data/test/pristine_app/index_test.rb +8 -8
- data/test/pristine_app/link_to_current_snip_test.rb +3 -3
- data/test/pristine_app/link_to_test.rb +5 -5
- data/test/pristine_app/page_title_test.rb +4 -4
- data/test/pristine_app/raise_errors_test.rb +6 -6
- data/test/pristine_app/raw_test.rb +10 -10
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d83e6c8385826e4b39e61dab35894534d705de
|
4
|
+
data.tar.gz: 63c871399b4e3efdc76c75f6df836094fca48440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a1aff8f63e05e938e2f215ecf1ea5c663b15ddc08fec692e519569051e887ea13fcaac5763631840a4357e506a7cfe44cccc11a0bf168cea68a6ca81a225e6
|
7
|
+
data.tar.gz: 5d728473a4609f9557767e4db33229421f93c21b7505f413952b033cc309f753d44f8a89184c2792ed25ee7c986dc28c0d1dddd1804726d73acb8ea5a98b26c7
|
data/README
CHANGED
@@ -14,22 +14,24 @@ A Preface; A Warning
|
|
14
14
|
The base flavour. The classic ice cream. Except riddled through with blood-red gemstones - Ruby gemstones.
|
15
15
|
This mad gelato will break your teeth.
|
16
16
|
|
17
|
-
... and run the freakiest wiki-wonki-wiki-wonki-wiki-wonki-wickedy-wiki you've ever seen.
|
17
|
+
... and run the freakiest wiki-wonki-wiki-wonki-wiki-wonki-wickedy-wiki you've ever seen.
|
18
18
|
|
19
|
-
But you must not fear: fear is the mind-killer; fear is the little death that brings total oblivion;
|
20
|
-
fear is the chilling terror that makes you believe that *everything* is better when Model lays with
|
19
|
+
But you must not fear: fear is the mind-killer; fear is the little death that brings total oblivion;
|
20
|
+
fear is the chilling terror that makes you believe that *everything* is better when Model lays with
|
21
21
|
Controller and View in peace.
|
22
22
|
|
23
23
|
Vanilla.rb cries "HERESY!" upon that layered orgy of filth. Vanilla.rb says "EMBRACE CHAOS!". Vanilla.rb
|
24
24
|
says "EVERY SNIP FOR THEMSELVES!". Vanilla.rb waits quietly, in the dark corners.
|
25
25
|
|
26
|
-
Use at your own risk; really. I showed it to a cat, and the cat started talking in French.
|
26
|
+
Use at your own risk; really. I showed it to a cat, and the cat started talking in French.
|
27
27
|
It was MESSED. UP.
|
28
28
|
|
29
29
|
|
30
30
|
Thee Darke Invocation
|
31
31
|
=====================
|
32
32
|
|
33
|
+
(Ruby 1.9 and above, please)
|
34
|
+
|
33
35
|
$ gem install vanilla
|
34
36
|
|
35
37
|
$ vanilla my_app_name
|
@@ -39,7 +41,7 @@ $ vanilla my_app_name
|
|
39
41
|
$ cd my_app_name
|
40
42
|
$ rackup
|
41
43
|
|
42
|
-
... the wonki starts. THE PAIN BEGINS.
|
44
|
+
... the wonki starts. THE PAIN BEGINS.
|
43
45
|
|
44
46
|
(Try going to http://localhost:9292/vanilla-rb-tutorial to salve the chafing.)
|
45
47
|
|
@@ -50,4 +52,4 @@ Working with Vanilla
|
|
50
52
|
Currently unknowable; soon I hope to compile such a nercronomicon as to allow mortal kind to
|
51
53
|
conjure up Snips and Dynasnips and Renderers...
|
52
54
|
|
53
|
-
For the moment, see http://interblah.net/vanilla-rb-tutorial
|
55
|
+
For the moment, see http://interblah.net/vanilla-rb-tutorial
|
data/Rakefile
CHANGED
@@ -5,9 +5,9 @@ require "rdoc/task"
|
|
5
5
|
require "bundler/setup"
|
6
6
|
require "vanilla"
|
7
7
|
|
8
|
-
task :
|
8
|
+
task default: :test
|
9
9
|
|
10
|
-
task :
|
10
|
+
task test: ["test:core", "test:app"]
|
11
11
|
|
12
12
|
namespace :test do
|
13
13
|
require "rake/testtask"
|
@@ -67,12 +67,12 @@ if Object.const_defined?(:Gem)
|
|
67
67
|
|
68
68
|
# All the other gems we need.
|
69
69
|
s.add_dependency("rack", ">= 0.9.1")
|
70
|
-
s.add_dependency("soup", ">= 1.0.
|
70
|
+
s.add_dependency("soup", ">= 1.0.13")
|
71
71
|
s.add_dependency("ratom", ">= 0.3.5")
|
72
72
|
s.add_dependency("RedCloth", ">= 4.1.1")
|
73
73
|
s.add_dependency("BlueCloth", ">= 1.0.0")
|
74
74
|
s.add_dependency("haml", ">=3.1")
|
75
|
-
s.add_dependency("parslet", "
|
75
|
+
s.add_dependency("parslet", ">= 1.5.0")
|
76
76
|
s.add_dependency("rack-test", ">=0.5.7")
|
77
77
|
|
78
78
|
s.add_development_dependency("rake", ">= 0.9.1")
|
@@ -115,7 +115,7 @@ if Object.const_defined?(:Gem)
|
|
115
115
|
File.open(file, "w") {|f| f << output }
|
116
116
|
end
|
117
117
|
|
118
|
-
task :
|
118
|
+
task package: :gemspec
|
119
119
|
|
120
120
|
# Generate documentation
|
121
121
|
Rake::RDocTask.new do |rd|
|
@@ -125,10 +125,10 @@ if Object.const_defined?(:Gem)
|
|
125
125
|
end
|
126
126
|
|
127
127
|
desc 'Clear out RDoc and generated packages'
|
128
|
-
task :
|
128
|
+
task clean: [:clobber_rdoc, :clobber_package]
|
129
129
|
|
130
130
|
desc 'Tag the repository in git with gem version number'
|
131
|
-
task :
|
131
|
+
task tag: [:gemspec, :package] do
|
132
132
|
if `git diff --cached`.empty?
|
133
133
|
if `git tag`.split("\n").include?("v#{spec.version}")
|
134
134
|
raise "Version #{spec.version} has already been released"
|
@@ -144,7 +144,7 @@ if Object.const_defined?(:Gem)
|
|
144
144
|
end
|
145
145
|
|
146
146
|
desc "Tag and publish the gem to rubygems.org"
|
147
|
-
task :
|
147
|
+
task publish: :tag do
|
148
148
|
`gem push pkg/#{spec.name}-#{spec.version}.gem`
|
149
149
|
end
|
150
150
|
else
|
data/bin/vanilla
CHANGED
@@ -5,9 +5,8 @@ def create(new_app_dir)
|
|
5
5
|
pristine_app = File.expand_path("../../pristine_app", __FILE__)
|
6
6
|
FileUtils.cp_r(pristine_app, new_app_dir)
|
7
7
|
FileUtils.mkdir_p(File.join(new_app_dir, "tmp"))
|
8
|
-
require 'vanilla'
|
9
8
|
File.open(File.join(new_app_dir, "Gemfile"), "w") do |f|
|
10
|
-
f.write "source
|
9
|
+
f.write "source 'https://rubygems.org'\n\n# Vanilla itself.\ngem 'vanilla'"
|
11
10
|
end
|
12
11
|
puts File.readlines(File.join(new_app_dir, "README"))[0..16].join
|
13
12
|
end
|
@@ -51,7 +50,7 @@ def console
|
|
51
50
|
require "irb"
|
52
51
|
require "vanilla/console"
|
53
52
|
puts "The Soup is simmering."
|
54
|
-
IRB.start
|
53
|
+
IRB.start
|
55
54
|
end
|
56
55
|
|
57
56
|
case ARGV[0]
|
data/lib/vanilla.rb
CHANGED
data/lib/vanilla/app.rb
CHANGED
data/lib/vanilla/atom_feed.rb
CHANGED
@@ -50,8 +50,8 @@ module Vanilla
|
|
50
50
|
e.updated = atom_time(snip.updated_at || snip.created_at)
|
51
51
|
e.content = Atom::Content::Html.new(externalise_links(app.render(snip)))
|
52
52
|
e.title = snip.title || snip.name
|
53
|
-
e.authors = [Atom::Person.new(:
|
54
|
-
e.links << Atom::Link.new(:
|
53
|
+
e.authors = [Atom::Person.new(name: snip.author || domain)]
|
54
|
+
e.links << Atom::Link.new(href: "http://#{domain}#{app.url_to(snip.name)}")
|
55
55
|
e.id = "tag:#{domain},#{atom_time(snip.created_at || Time.now).split("T")[0]}:#{app.url_to(snip.name)}"
|
56
56
|
end
|
57
57
|
end
|
data/lib/vanilla/config.rb
CHANGED
@@ -19,14 +19,14 @@ module Vanilla
|
|
19
19
|
class Config
|
20
20
|
def initialize
|
21
21
|
@attributes = {
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
22
|
+
root: Dir.pwd,
|
23
|
+
root_snip: "start",
|
24
|
+
soup: nil,
|
25
|
+
soups: ["soups/base", "soups/system"],
|
26
|
+
default_layout_snip: "layout",
|
27
|
+
default_renderer: Vanilla::Renderers::Base,
|
28
|
+
raise_errors: false,
|
29
|
+
renderers: {
|
30
30
|
"base" => Vanilla::Renderers::Base,
|
31
31
|
"markdown" => Vanilla::Renderers::Markdown,
|
32
32
|
"bold" => Vanilla::Renderers::Bold,
|
data/lib/vanilla/dynasnip.rb
CHANGED
@@ -43,7 +43,7 @@ class Dynasnip < Vanilla::Renderers::Base
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.snip_attributes
|
46
|
-
full_snip_attributes = {:
|
46
|
+
full_snip_attributes = {name: snip_name, content: self.name, render_as: "Ruby"}
|
47
47
|
@attributes ? full_snip_attributes.merge!(@attributes) : full_snip_attributes
|
48
48
|
end
|
49
49
|
|
@@ -89,4 +89,4 @@ class Dynasnip < Vanilla::Renderers::Base
|
|
89
89
|
p.delete(:part)
|
90
90
|
p
|
91
91
|
end
|
92
|
-
end
|
92
|
+
end
|
@@ -112,7 +112,8 @@ module Vanilla
|
|
112
112
|
|
113
113
|
# Returns the raw content for the selected part of the selected snip
|
114
114
|
def raw_content(snip, part)
|
115
|
-
|
115
|
+
selected_part = (part || :content).to_sym
|
116
|
+
snip.__send__(selected_part) if snip.respond_to?(selected_part)
|
116
117
|
end
|
117
118
|
end
|
118
119
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'erb'
|
2
|
-
include ERB::Util
|
3
2
|
|
4
3
|
module Vanilla::Renderers
|
5
4
|
class Erb < Base
|
6
5
|
def prepare(snip, part=:content, args=[], enclosing_snip=snip)
|
7
6
|
@snip = snip
|
8
7
|
end
|
9
|
-
|
8
|
+
|
10
9
|
def process_text(content)
|
11
10
|
ERB.new(content).result(binding)
|
12
11
|
end
|
13
12
|
end
|
14
|
-
end
|
13
|
+
end
|
@@ -86,21 +86,21 @@ module Vanilla
|
|
86
86
|
end
|
87
87
|
|
88
88
|
class SnipTransform < Parslet::Transform
|
89
|
-
rule(:
|
90
|
-
rule(:
|
91
|
-
rule(:
|
92
|
-
rule(:
|
93
|
-
rule(:
|
89
|
+
rule(nil: simple(:x)) { nil }
|
90
|
+
rule(string: simple(:x)) { x.to_s }
|
91
|
+
rule(string_arg: simple(:x)) { x }
|
92
|
+
rule(string_arg_list: simple(:x)) { [x] }
|
93
|
+
rule(string_arg_list: sequence(:x)) { x }
|
94
94
|
|
95
95
|
class Arg
|
96
96
|
def initialize(k, v); @k, @v = k, v; end
|
97
97
|
def to_h; {@k.to_sym => @v}; end
|
98
98
|
end
|
99
99
|
|
100
|
-
rule(:
|
101
|
-
rule(:
|
102
|
-
rule(:
|
103
|
-
rule(:
|
100
|
+
rule(hash_arg: subtree(:x)) { Arg.new(x[:key], x[:value]) }
|
101
|
+
rule(named_arg: subtree(:x)) { Arg.new(x[:key], x[:value]) }
|
102
|
+
rule(key_value_arg_list: simple(:x)) { x.to_h }
|
103
|
+
rule(key_value_arg_list: sequence(:x)) { x.inject({}) { |h, kv| h.merge(kv.to_h) } }
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
data/pristine_app/Gemfile
CHANGED
data/pristine_app/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
WELCOME IN VANILLA
|
2
|
+
Vanilla
|
3
|
+
vanilla
|
4
|
+
.........vanillaaaaaAAAAAAAAAAA
|
5
5
|
|
6
6
|
What you've got:
|
7
7
|
|
@@ -24,7 +24,7 @@ slightly modified YAML files. Here's an example, which you might save
|
|
24
24
|
in a file called 'soup.snip':
|
25
25
|
|
26
26
|
|
27
|
-
Soup is a data store supporting the {link_to snip}-space that
|
27
|
+
Soup is a data store supporting the {link_to snip}-space that
|
28
28
|
{link_to vanilla-rb} expects.
|
29
29
|
|
30
30
|
It's hosted on github [here](http://github.com/lazyatom/soup).
|
@@ -44,4 +44,4 @@ The console
|
|
44
44
|
Within a vanilla app directory, you can run `vanilla console` to start
|
45
45
|
an IRB session and interact with your app and snips. The `app` method
|
46
46
|
returns your application object, and `app.soup['start']` will return
|
47
|
-
the start snip from your soup(s).
|
47
|
+
the start snip from your soup(s).
|
data/pristine_app/config.ru
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
|
1
3
|
require "application"
|
2
4
|
|
3
5
|
# If you're running your site under a proper webserver, you probably don't need this.
|
4
6
|
require 'vanilla/static'
|
5
7
|
use Vanilla::Static, File.join(File.dirname(__FILE__), 'public')
|
6
8
|
|
7
|
-
run Application.new
|
9
|
+
run Application.new
|
@@ -14,7 +14,7 @@ class Comments < Dynasnip
|
|
14
14
|
|
15
15
|
def get(disable_new_comments=false)
|
16
16
|
return usage if self.class.snip_name == app.request.snip_name
|
17
|
-
comments = app.soup.with(:
|
17
|
+
comments = app.soup.with(commenting_on: enclosing_snip.name)
|
18
18
|
comments_html = if app.request.snip_name == enclosing_snip.name
|
19
19
|
rendered_comments = render_comments(comments)
|
20
20
|
rendered_comments += comment_form.gsub('SNIP_NAME', enclosing_snip.name) unless disable_new_comments
|
@@ -27,16 +27,16 @@ class Comments < Dynasnip
|
|
27
27
|
|
28
28
|
def post(*args)
|
29
29
|
snip_name = app.request.params[:snip]
|
30
|
-
existing_comments = app.soup.with(:
|
30
|
+
existing_comments = app.soup.with(commenting_on: snip_name)
|
31
31
|
comment = app.request.params.reject { |k,v| ![:author, :email, :website, :content].include?(k) }
|
32
32
|
|
33
33
|
return "You need to add some details!" if comment.empty?
|
34
34
|
return "No spam today, thanks anyway" unless app.request.params[:human] == 'human'
|
35
35
|
|
36
36
|
app.soup << comment.merge({
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
37
|
+
name: "#{snip_name}-comment-#{existing_comments.length + 1}",
|
38
|
+
commenting_on: snip_name,
|
39
|
+
created_at: Time.now
|
40
40
|
})
|
41
41
|
"Thanks for your comment! Back to {link_to #{snip_name}}"
|
42
42
|
end
|
@@ -75,4 +75,4 @@ class Comments < Dynasnip
|
|
75
75
|
}
|
76
76
|
|
77
77
|
self
|
78
|
-
end
|
78
|
+
end
|
@@ -5,7 +5,7 @@ require 'date'
|
|
5
5
|
class Kind < Dynasnip
|
6
6
|
def handle(kind, limit=10, as=:html)
|
7
7
|
as = as.to_sym
|
8
|
-
snips = app.soup.with(:
|
8
|
+
snips = app.soup.with(kind: kind)
|
9
9
|
entries = snips.sort_by { |s| s.created_at || Time.at(0) }.reverse[0...limit.to_i].map do |snip|
|
10
10
|
render_entry_in_template(snip, as, kind)
|
11
11
|
end
|
@@ -27,8 +27,8 @@ class Kind < Dynasnip
|
|
27
27
|
e.updated = snip.updated_at || snip.created_at
|
28
28
|
e.content = Atom::Content::Html.new(rendered_contents)
|
29
29
|
e.title = snip.name
|
30
|
-
e.authors = [Atom::Person.new(:
|
31
|
-
e.links << Atom::Link.new(:
|
30
|
+
e.authors = [Atom::Person.new(name: snip.author || domain)]
|
31
|
+
e.links << Atom::Link.new(href: "http://#{domain}#{url_to(snip.name)}")
|
32
32
|
e.id = "tag:#{domain},#{(snip.created_at.to_s || Date.today.to_s).split[0]}:/#{snip.name}"
|
33
33
|
end
|
34
34
|
end
|
@@ -69,4 +69,4 @@ class Kind < Dynasnip
|
|
69
69
|
</div>
|
70
70
|
</div>
|
71
71
|
}
|
72
|
-
end
|
72
|
+
end
|
data/test/core/atom_feed_test.rb
CHANGED
@@ -3,17 +3,17 @@ require "atom"
|
|
3
3
|
|
4
4
|
context "An atom feed" do
|
5
5
|
should "include snips" do
|
6
|
-
stub_app_soup({:
|
7
|
-
{:
|
6
|
+
stub_app_soup({name: "Hello", content: "This is the content"},
|
7
|
+
{name: "Goodbye", content: "More content"})
|
8
8
|
|
9
|
-
feed_xml = Vanilla::AtomFeed.new(:
|
9
|
+
feed_xml = Vanilla::AtomFeed.new(domain: "yourdomain.example.com", app: app).to_s
|
10
10
|
feed = Atom::Feed.load_feed(feed_xml)
|
11
11
|
assert_equal 2, feed.entries.length
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when making links absolute" do
|
15
15
|
should "handle double quoted a tags" do
|
16
|
-
stub_app_soup({:
|
16
|
+
stub_app_soup({name: "x", content: %|<a href="/x">x</a>.|})
|
17
17
|
|
18
18
|
feed = get_feed
|
19
19
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x},
|
@@ -21,7 +21,7 @@ context "An atom feed" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
should "handle single quoted a tags" do
|
24
|
-
stub_app_soup({:
|
24
|
+
stub_app_soup({name: "x", content: %|<a href='/x'>x</a>.|})
|
25
25
|
|
26
26
|
feed = get_feed
|
27
27
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x},
|
@@ -29,7 +29,7 @@ context "An atom feed" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
should "handle double quoted a tags without slahes" do
|
32
|
-
stub_app_soup({:
|
32
|
+
stub_app_soup({name: "x", content: %|<a href="x">x</a>.|})
|
33
33
|
|
34
34
|
feed = get_feed
|
35
35
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x},
|
@@ -37,7 +37,7 @@ context "An atom feed" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
should "handle single quoted a tags without slashes" do
|
40
|
-
stub_app_soup({:
|
40
|
+
stub_app_soup({name: "x", content: %|<a href='x'>x</a>.|})
|
41
41
|
|
42
42
|
feed = get_feed
|
43
43
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x},
|
@@ -45,7 +45,7 @@ context "An atom feed" do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
should "handle double quoted img tags" do
|
48
|
-
stub_app_soup({:
|
48
|
+
stub_app_soup({name: "x", content: %|<img src="/x.jpg" />|})
|
49
49
|
|
50
50
|
feed = get_feed
|
51
51
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x.jpg},
|
@@ -53,7 +53,7 @@ context "An atom feed" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
should "handle single quoted img tags" do
|
56
|
-
stub_app_soup({:
|
56
|
+
stub_app_soup({name: "x", content: %|<img src='/x.jpg' />|})
|
57
57
|
|
58
58
|
feed = get_feed
|
59
59
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x.jpg},
|
@@ -61,7 +61,7 @@ context "An atom feed" do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
should "handle double quoted img tags without slashes" do
|
64
|
-
stub_app_soup({:
|
64
|
+
stub_app_soup({name: "x", content: %|<img src="x.jpg" />|})
|
65
65
|
|
66
66
|
feed = get_feed
|
67
67
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x.jpg},
|
@@ -69,7 +69,7 @@ context "An atom feed" do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
should "handle single quoted img tags without slashes" do
|
72
|
-
stub_app_soup({:
|
72
|
+
stub_app_soup({name: "x", content: %|<img src='x.jpg' />|})
|
73
73
|
|
74
74
|
feed = get_feed
|
75
75
|
assert feed.entries.first.content =~ %r{http://yourdomain\.example\.com/x.jpg},
|
@@ -77,7 +77,7 @@ context "An atom feed" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
should "not alter urls that are already absolute" do
|
80
|
-
stub_app_soup({:
|
80
|
+
stub_app_soup({name: "x", content: %|<img src='http://x.com/' />|})
|
81
81
|
|
82
82
|
feed = get_feed
|
83
83
|
assert feed.entries.first.content =~ %r{src='http://x\.com/'},
|
@@ -86,57 +86,57 @@ context "An atom feed" do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
should "allow inclusion of only specific snips" do
|
89
|
-
snip_a_data = {:
|
90
|
-
snip_b_data = {:
|
89
|
+
snip_a_data = {name: "a", content: "x"}
|
90
|
+
snip_b_data = {name: "b", content: "x"}
|
91
91
|
stub_app_soup(snip_a_data, snip_b_data)
|
92
92
|
|
93
|
-
feed_xml = app.atom_feed(:
|
93
|
+
feed_xml = app.atom_feed(domain: "whatever", snips: [app.soup["a"]]).to_s
|
94
94
|
feed = Atom::Feed.load_feed(feed_xml)
|
95
95
|
assert_equal 1, feed.entries.length
|
96
96
|
assert_equal "a", feed.entries.first.title
|
97
97
|
end
|
98
98
|
|
99
99
|
should "allow filtering of snips by matching criteria" do
|
100
|
-
stub_app_soup({:
|
101
|
-
{:
|
102
|
-
{:
|
100
|
+
stub_app_soup({name: "a", content: "x", kind: "blog"},
|
101
|
+
{name: "b", content: "x", kind: "draft"},
|
102
|
+
{name: "c", content: "x", kind: "blog"})
|
103
103
|
|
104
|
-
feed_xml = app.atom_feed(:
|
104
|
+
feed_xml = app.atom_feed(domain: "whatever", matching: {kind: "blog"}).to_s
|
105
105
|
feed = Atom::Feed.load_feed(feed_xml)
|
106
106
|
assert_equal 2, feed.entries.length
|
107
107
|
assert_same_elements ["a", "c"], feed.entries.map { |e| e.title }
|
108
108
|
end
|
109
109
|
|
110
110
|
should "allow limiting of the number of snips" do
|
111
|
-
stub_app_soup({:
|
112
|
-
{:
|
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
113
|
|
114
|
-
feed_xml = app.atom_feed(:
|
114
|
+
feed_xml = app.atom_feed(domain: "whatever", matching: {kind: "blog"}, count: 1).to_s
|
115
115
|
feed = Atom::Feed.load_feed(feed_xml)
|
116
116
|
assert_equal 1, feed.entries.length
|
117
117
|
assert_equal "a", feed.entries.first.title
|
118
118
|
end
|
119
119
|
|
120
120
|
should "set updated to be the latest updated_at of the included snips" do
|
121
|
-
snip_a_data = {:
|
122
|
-
snip_b_data = {:
|
123
|
-
snip_c_data = {:
|
121
|
+
snip_a_data = {name: "a", content: "x", updated_at: Time.parse("2011-05-22 12:00")}
|
122
|
+
snip_b_data = {name: "b", content: "x", updated_at: Time.parse("2011-05-23 12:34")}
|
123
|
+
snip_c_data = {name: "c", content: "x", updated_at: Time.parse("2011-05-24 12:34")}
|
124
124
|
stub_app_soup(snip_a_data, snip_b_data, snip_c_data)
|
125
125
|
|
126
|
-
feed_xml = app.atom_feed(:
|
126
|
+
feed_xml = app.atom_feed(domain: "whatever", snips: [app.soup["a"], app.soup["b"]]).to_s
|
127
127
|
feed = Atom::Feed.load_feed(feed_xml)
|
128
128
|
assert_equal Time.parse("2011-05-23 12:34"), feed.updated
|
129
129
|
end
|
130
130
|
|
131
131
|
should "format updated_at as an RFC-3339 date-time" do
|
132
|
-
stub_app_soup({:
|
132
|
+
stub_app_soup({name: "x", content: "y", updated_at: Time.parse("2011-01-01 12:23 +0000").to_s})
|
133
133
|
|
134
|
-
feed_xml = app.atom_feed(:
|
134
|
+
feed_xml = app.atom_feed(domain: "whatever", snips: [app.soup["x"]]).to_s
|
135
135
|
assert_match %r{2011\-01\-01T\d{2}\:23\:00[\+\-]\d{2}\:\d{2}}, feed_xml
|
136
136
|
end
|
137
137
|
|
138
138
|
should "work even without any snips" do
|
139
|
-
feed_xml = app.atom_feed(:
|
139
|
+
feed_xml = app.atom_feed(domain: "whatever", snips: []).to_s
|
140
140
|
feed = Atom::Feed.load_feed(feed_xml)
|
141
141
|
end
|
142
142
|
|
@@ -146,13 +146,13 @@ context "An atom feed" do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
should "be settable via the initialiser" do
|
149
|
-
feed_xml = app.atom_feed(:
|
149
|
+
feed_xml = app.atom_feed(domain: "yourdomain.example.com", title: "My Title").to_s
|
150
150
|
feed = Atom::Feed.load_feed(feed_xml)
|
151
151
|
assert_equal "My Title", feed.title
|
152
152
|
end
|
153
153
|
|
154
154
|
should "default to the domain" do
|
155
|
-
feed_xml = app.atom_feed(:
|
155
|
+
feed_xml = app.atom_feed(domain: "yourdomain.example.com").to_s
|
156
156
|
feed = Atom::Feed.load_feed(feed_xml)
|
157
157
|
assert_equal "yourdomain.example.com", feed.title
|
158
158
|
end
|
@@ -160,8 +160,8 @@ context "An atom feed" do
|
|
160
160
|
|
161
161
|
context "entry" do
|
162
162
|
setup do
|
163
|
-
stub_app_soup({:
|
164
|
-
:
|
163
|
+
stub_app_soup({name: "Hello", content: "The *content*",
|
164
|
+
render_as: "markdown", created_at: Time.parse("2011-01-01 12:23").to_s})
|
165
165
|
end
|
166
166
|
|
167
167
|
context "titles" do
|
@@ -170,7 +170,7 @@ context "An atom feed" do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
should "use the title of the snip if present" do
|
173
|
-
stub_app_soup({:
|
173
|
+
stub_app_soup({name: "hello-mammy", content: "x", title: "Hello, Mammy"})
|
174
174
|
assert_equal "Hello, Mammy", get_feed.entries.first.title
|
175
175
|
end
|
176
176
|
end
|
@@ -181,7 +181,7 @@ context "An atom feed" do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
should "set the authors if the snip provides" do
|
184
|
-
stub_app_soup({:
|
184
|
+
stub_app_soup({name: "a", content: "x", author: "james"})
|
185
185
|
assert_equal ["james"], get_feed.entries.first.authors.map { |a| a.name }
|
186
186
|
end
|
187
187
|
end
|
@@ -200,8 +200,8 @@ context "An atom feed" do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
should "not include snip name spaces in ID" do
|
203
|
-
stub_app_soup({:
|
204
|
-
:
|
203
|
+
stub_app_soup({name: "snip name", content: "The *content*",
|
204
|
+
render_as: "markdown", created_at: Time.parse("2011-01-01 12:23").to_s})
|
205
205
|
|
206
206
|
assert_equal "tag:yourdomain.example.com,2011-01-01:/snip+name", get_feed.entries.first.id
|
207
207
|
end
|
@@ -216,7 +216,7 @@ context "An atom feed" do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
should "set the updated at to the snip attribute if it exists" do
|
219
|
-
stub_app_soup({:
|
219
|
+
stub_app_soup({name: "Hello", content: "the content", updated_at: Time.parse("2011-01-02 13:45").to_s})
|
220
220
|
assert_equal Time.parse("2011-01-02 13:45"), get_feed.entries.first.updated
|
221
221
|
end
|
222
222
|
end
|
@@ -225,7 +225,7 @@ context "An atom feed" do
|
|
225
225
|
private
|
226
226
|
|
227
227
|
def get_feed
|
228
|
-
feed_xml = app.atom_feed(:
|
228
|
+
feed_xml = app.atom_feed(domain: "yourdomain.example.com").to_s
|
229
229
|
Atom::Feed.load_feed(feed_xml)
|
230
230
|
end
|
231
231
|
end
|