tributary 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -87,13 +87,13 @@ The settings altered by the user are kept in the given user’s session and so p
87
87
 
88
88
 
89
89
 
90
- Plugins
91
- -------
90
+ Plug-ins
91
+ --------
92
92
 
93
- Plugins (put in the `App.plugins` `Array`) are objects which can be sent a `handle` method with an `Item` as a parameter and are expected to return the `Item` (so the calls to subsequent plugins are chainable). See the `Mnml` plugin for an example implementation utilising a `SimpleDelegator` to filter the given `Item`’s `body` and `title` methods.
93
+ Plug-ins (put in the `App.plugins` `Array`) are objects which can be sent a `handle` method with an `Item` as a parameter and are expected to return the `Item` (so the calls to subsequent plug-ins are chainable). See the `Mnml` plug-in for an example implementation utilising a `SimpleDelegator` to filter the given `Item`’s `body` and `title` methods.
94
94
 
95
95
 
96
96
 
97
97
  ---
98
98
 
99
- © MMX Piotr Szotkowski <chastell@chastell.net>, licensed under AGPL 3 (see LICENCE)
99
+ © MMX-MMXI Piotr Szotkowski <chastell@chastell.net>, licensed under AGPL 3 (see LICENCE)
data/Rakefile CHANGED
@@ -1,5 +1,12 @@
1
1
  require 'rspec/core/rake_task'
2
-
3
2
  ENV['TZ'] = 'Europe/Warsaw'
4
-
5
3
  RSpec::Core::RakeTask.new :spec
4
+
5
+ desc 'Run Tributary console'
6
+ task :console do
7
+ require 'irb'
8
+ require_relative 'lib/tributary'
9
+ include Tributary
10
+ ARGV.clear
11
+ IRB.start
12
+ end
data/lib/tributary.rb CHANGED
@@ -3,6 +3,8 @@ require 'sinatra/base'
3
3
  require 'sinatra/r18n'
4
4
  require 'yaml'
5
5
 
6
- require_relative 'tributary/app'
7
- require_relative 'tributary/item'
8
- require_relative 'tributary/stream'
6
+ module Tributary
7
+ autoload :App, 'tributary/app'
8
+ autoload :Item, 'tributary/item'
9
+ autoload :Stream, 'tributary/stream'
10
+ end
data/lib/tributary/app.rb CHANGED
@@ -27,7 +27,7 @@ module Tributary class App < Sinatra::Base
27
27
 
28
28
  get '/set' do
29
29
  params.each { |key, value| session[key.to_sym] = value if App.user_prefs.map(&:to_s).include? key }
30
- redirect request.referer
30
+ URI.parse(request.referer).host == request.host ? redirect(request.referer) : redirect('/')
31
31
  end
32
32
 
33
33
  get '/:feed.xml' do |feed|
@@ -105,36 +105,36 @@ module Tributary describe App do
105
105
  it 'renders the Atom feed' do
106
106
  get '/index.xml'
107
107
  last_response.should be_ok
108
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
108
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
109
109
  last_response.body.should == File.read('spec/fixtures/index.xml')
110
110
  end
111
111
 
112
112
  it 'renders per-locale Atom feeds' do
113
113
  get '/index.en.xml'
114
114
  last_response.should be_ok
115
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
115
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
116
116
  last_response.body.should == File.read('spec/fixtures/index.en.xml')
117
117
 
118
118
  get '/index.pl.xml'
119
119
  last_response.should be_ok
120
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
120
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
121
121
  last_response.body.should == File.read('spec/fixtures/index.pl.xml')
122
122
  end
123
123
 
124
124
  it 'renders lang_limit-ed Atom feeds' do
125
125
  get '/index.en.en.xml'
126
126
  last_response.should be_ok
127
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
127
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
128
128
  last_response.body.should == File.read('spec/fixtures/index.en.en.xml')
129
129
 
130
130
  get '/index.pl.pl.xml'
131
131
  last_response.should be_ok
132
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
132
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
133
133
  last_response.body.should == File.read('spec/fixtures/index.pl.pl.xml')
134
134
 
135
135
  get '/index.en.en+pl.xml'
136
136
  last_response.should be_ok
137
- last_response.headers['Content-Type'].should == 'application/atom+xml;charset=utf-8'
137
+ last_response.headers['Content-Type'].should == 'application/atom+xml'
138
138
  last_response.body.should == File.read('spec/fixtures/index.en.en+pl.xml')
139
139
  end
140
140
 
@@ -166,7 +166,7 @@ module Tributary describe App do
166
166
  end
167
167
 
168
168
  it 'sets the right App settings and redirects properly' do
169
- get '/set?locale=pl', {}, 'HTTP_REFERER' => '/bilingual'
169
+ get '/set?locale=pl', {}, 'HTTP_REFERER' => 'http://example.org/bilingual'
170
170
  last_response.location.should == 'http://example.org/bilingual'
171
171
  follow_redirect!
172
172
  App.locale.should == 'pl'
@@ -188,6 +188,11 @@ module Tributary describe App do
188
188
  App.lang_limit.should == nil
189
189
  end
190
190
 
191
+ it 'doesn’t redirect outside of the current domain' do
192
+ get '/set', {}, 'HTTP_REFERER' => 'http://foo.bar/baz'
193
+ last_response.location.should == 'http://example.org/'
194
+ end
195
+
191
196
  it 'localises the output based on locale (defaulting to English)' do
192
197
  get '/set?locale=pl'
193
198
  get '/bilingual'
@@ -14,7 +14,7 @@ module Tributary describe Item do
14
14
  @welcome = Item.new 'spec/site/articles/welcome.md'
15
15
  end
16
16
 
17
- context '#<=>' do
17
+ describe '#<=>' do
18
18
 
19
19
  it 'sorts Items by date, date-less last' do
20
20
  [@bi_en, @beep, @welcome, @about, @battle].sort.should == [@battle, @bi_en, @welcome, @beep, @about]
@@ -34,7 +34,7 @@ module Tributary describe Item do
34
34
 
35
35
  end
36
36
 
37
- context '#body' do
37
+ describe '#body' do
38
38
 
39
39
  it 'returns the given Item’s markdown-processed body' do
40
40
  @about.body.should == "<p>tributary <em>about</em> page</p>\n\n<p>about this tributary install</p>\n"
@@ -43,7 +43,7 @@ module Tributary describe Item do
43
43
 
44
44
  end
45
45
 
46
- context '#date' do
46
+ describe '#date' do
47
47
 
48
48
  it 'returns the given Item’s parsed Time' do
49
49
  @about.date.should == nil
@@ -54,7 +54,7 @@ module Tributary describe Item do
54
54
 
55
55
  end
56
56
 
57
- context '#eql?' do
57
+ describe '#eql?' do
58
58
 
59
59
  it 'returns predicate for sane use of Items as Hash keys' do
60
60
  @about.should be_eql Item.new('spec/site/pages/about.md')
@@ -62,7 +62,7 @@ module Tributary describe Item do
62
62
 
63
63
  end
64
64
 
65
- context '#hash' do
65
+ describe '#hash' do
66
66
 
67
67
  it 'returns static value for sane use of Items as Hash keys' do
68
68
  @about.hash.should == Item.new('spec/site/pages/about.md').hash
@@ -70,7 +70,7 @@ module Tributary describe Item do
70
70
 
71
71
  end
72
72
 
73
- context '#lang' do
73
+ describe '#lang' do
74
74
 
75
75
  it 'returns the Item’s language (if defined)' do
76
76
  @about.lang.should == nil
@@ -80,7 +80,7 @@ module Tributary describe Item do
80
80
 
81
81
  end
82
82
 
83
- context '#path' do
83
+ describe '#path' do
84
84
 
85
85
  it 'returns the given Item’s path' do
86
86
  @about.path.should == 'about'
@@ -91,7 +91,7 @@ module Tributary describe Item do
91
91
 
92
92
  end
93
93
 
94
- context '#published?' do
94
+ describe '#published?' do
95
95
 
96
96
  it 'returns whether the given Item has a date in the past' do
97
97
  @about.should_not be_published
@@ -102,7 +102,7 @@ module Tributary describe Item do
102
102
 
103
103
  end
104
104
 
105
- context '#title' do
105
+ describe '#title' do
106
106
 
107
107
  it 'returns the given Item’s YAML-specified title' do
108
108
  @about.title.should == 'about tributary'
@@ -117,7 +117,7 @@ module Tributary describe Item do
117
117
 
118
118
  end
119
119
 
120
- context '#type' do
120
+ describe '#type' do
121
121
 
122
122
  it 'returns the given Item’s type' do
123
123
  @about.type.should == :pages
@@ -1,6 +1,6 @@
1
1
  module Tributary describe Plugins::Dummy do
2
2
 
3
- context '#handle' do
3
+ describe '#handle' do
4
4
 
5
5
  it 'returns an unmodified Item' do
6
6
  item = mock Item
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Tributary describe Plugins::Mnml do
4
4
 
5
- context '#handle' do
5
+ describe '#handle' do
6
6
 
7
7
  it 'minimalises the given Item’s title and body' do
8
8
  item = mock Item, body: 'a wonderful body', title: 'an interesting title'
@@ -20,7 +20,7 @@ module Tributary describe Stream do
20
20
  @stream = Stream.new
21
21
  end
22
22
 
23
- context '#initialize' do
23
+ describe '#initialize' do
24
24
 
25
25
  it 'filters the Items through the provided Plugins' do
26
26
  App.plugins = [Plugins::Mnml.new]
@@ -31,7 +31,7 @@ module Tributary describe Stream do
31
31
 
32
32
  end
33
33
 
34
- context '#langs' do
34
+ describe '#langs' do
35
35
 
36
36
  it 'returns an Array of langs used in the Items' do
37
37
  @stream.langs.should == ['en', 'pl']
@@ -39,7 +39,7 @@ module Tributary describe Stream do
39
39
 
40
40
  end
41
41
 
42
- context '#pick_item' do
42
+ describe '#pick_item' do
43
43
 
44
44
  it 'returns the relevant Item based on the provided path' do
45
45
  @stream.pick_item('about').should == @about
@@ -69,7 +69,7 @@ module Tributary describe Stream do
69
69
 
70
70
  end
71
71
 
72
- context '#previous' do
72
+ describe '#previous' do
73
73
 
74
74
  it 'returns an Item previous to the given Item' do
75
75
  @stream.previous(@battle).should == @bi_en
@@ -89,7 +89,7 @@ module Tributary describe Stream do
89
89
 
90
90
  end
91
91
 
92
- context '#recent' do
92
+ describe '#recent' do
93
93
 
94
94
  it 'returns published Items, newest-first' do
95
95
  @stream.recent.should == [@polish, @english, @battle, @bi_en, @dated, @welcome]
@@ -124,7 +124,7 @@ module Tributary describe Stream do
124
124
 
125
125
  end
126
126
 
127
- context '#subsequent' do
127
+ describe '#subsequent' do
128
128
 
129
129
  it 'returns an Item subsequent to the given Item' do
130
130
  @stream.subsequent(@welcome).should == @dated
@@ -144,7 +144,7 @@ module Tributary describe Stream do
144
144
 
145
145
  end
146
146
 
147
- context '#types' do
147
+ describe '#types' do
148
148
 
149
149
  it 'returns an Array of the Items’ types' do
150
150
  @stream.types.should == [:articles, :beeps, :pages]
data/tributary.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'tributary'
3
- gem.version = '0.0.1'
3
+ gem.version = '0.0.2'
4
4
  gem.summary = 'tributary: a tiny, toto-inspired blogging engine'
5
5
  gem.homepage = 'http://github.com/chastell/tributary'
6
6
  gem.author = 'Piotr Szotkowski'
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
 
12
12
  gem.add_dependency 'haml'
13
13
  gem.add_dependency 'kramdown'
14
- gem.add_dependency 'sinatra', '>= 1.1'
14
+ gem.add_dependency 'sinatra', '>= 1.1.2'
15
15
  gem.add_dependency 'sinatra-r18n'
16
16
  gem.add_development_dependency 'rack-test'
17
17
  gem.add_development_dependency 'rspec', '>= 2'
metadata CHANGED
@@ -1,110 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tributary
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease: !!null
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Piotr Szotkowski
13
- autorequire:
9
+ autorequire: !!null
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-31 01:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-03-04 00:00:00.000000000 +01:00
13
+ default_executable: !!null
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: haml
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &22181920 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
31
23
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: kramdown
35
24
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *22181920
26
+ - !ruby/object:Gem::Dependency
27
+ name: kramdown
28
+ requirement: &22181480 !ruby/object:Gem::Requirement
37
29
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
44
34
  type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: sinatra
48
35
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *22181480
37
+ - !ruby/object:Gem::Dependency
38
+ name: sinatra
39
+ requirement: &22180980 !ruby/object:Gem::Requirement
50
40
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 1
56
- - 1
57
- version: "1.1"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: 1.1.2
58
45
  type: :runtime
59
- version_requirements: *id003
60
- - !ruby/object:Gem::Dependency
61
- name: sinatra-r18n
62
46
  prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *22180980
48
+ - !ruby/object:Gem::Dependency
49
+ name: sinatra-r18n
50
+ requirement: &22180560 !ruby/object:Gem::Requirement
64
51
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
71
56
  type: :runtime
72
- version_requirements: *id004
73
- - !ruby/object:Gem::Dependency
74
- name: rack-test
75
57
  prerelease: false
76
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *22180560
59
+ - !ruby/object:Gem::Dependency
60
+ name: rack-test
61
+ requirement: &22180100 !ruby/object:Gem::Requirement
77
62
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- segments:
82
- - 0
83
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
84
67
  type: :development
85
- version_requirements: *id005
86
- - !ruby/object:Gem::Dependency
87
- name: rspec
88
68
  prerelease: false
89
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *22180100
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &22179600 !ruby/object:Gem::Requirement
90
73
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- segments:
95
- - 2
96
- version: "2"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '2'
97
78
  type: :development
98
- version_requirements: *id006
99
- description:
79
+ prerelease: false
80
+ version_requirements: *22179600
81
+ description: !!null
100
82
  email: chastell@chastell.net
101
83
  executables: []
102
-
103
84
  extensions: []
104
-
105
85
  extra_rdoc_files: []
106
-
107
- files:
86
+ files:
108
87
  - .gitignore
109
88
  - .rspec
110
89
  - LICENCE
@@ -166,36 +145,29 @@ files:
166
145
  has_rdoc: true
167
146
  homepage: http://github.com/chastell/tributary
168
147
  licenses: []
169
-
170
- post_install_message:
148
+ post_install_message: !!null
171
149
  rdoc_options: []
172
-
173
- require_paths:
150
+ require_paths:
174
151
  - lib
175
- required_ruby_version: !ruby/object:Gem::Requirement
152
+ required_ruby_version: !ruby/object:Gem::Requirement
176
153
  none: false
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- segments:
181
- - 0
182
- version: "0"
183
- required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
159
  none: false
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- segments:
189
- - 0
190
- version: "0"
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
191
164
  requirements: []
192
-
193
- rubyforge_project:
194
- rubygems_version: 1.3.7
195
- signing_key:
165
+ rubyforge_project: !!null
166
+ rubygems_version: 1.5.0
167
+ signing_key: !!null
196
168
  specification_version: 3
197
- summary: "tributary: a tiny, toto-inspired blogging engine"
198
- test_files:
169
+ summary: ! 'tributary: a tiny, toto-inspired blogging engine'
170
+ test_files:
199
171
  - spec/tributary/app_spec.rb
200
172
  - spec/tributary/stream_spec.rb
201
173
  - spec/tributary/item_spec.rb