utopia 0.12.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/Gemfile +6 -0
- data/README.md +48 -14
- data/Rakefile +5 -0
- data/bin/utopia +132 -15
- data/lib/utopia.rb +13 -10
- data/lib/utopia/content.rb +140 -0
- data/lib/utopia/content/link.rb +124 -0
- data/lib/utopia/content/links.rb +228 -0
- data/lib/utopia/content/node.rb +387 -0
- data/lib/utopia/content/processor.rb +128 -0
- data/lib/utopia/content/tag.rb +102 -0
- data/lib/utopia/controller.rb +137 -0
- data/lib/utopia/controller/action.rb +112 -0
- data/lib/utopia/controller/base.rb +174 -0
- data/lib/utopia/{middleware/controller → controller}/variables.rb +36 -38
- data/lib/utopia/exception_handler.rb +79 -0
- data/lib/utopia/extensions/array.rb +2 -2
- data/lib/utopia/localization.rb +143 -0
- data/lib/utopia/mail_exceptions.rb +136 -0
- data/lib/utopia/middleware.rb +7 -22
- data/lib/utopia/path.rb +150 -60
- data/lib/utopia/redirector.rb +152 -0
- data/lib/utopia/{extensions/hash.rb → session.rb} +4 -6
- data/lib/utopia/session/encrypted_cookie.rb +46 -48
- data/lib/utopia/{middleware/directory_index.rb → session/lazy_hash.rb} +44 -27
- data/lib/utopia/static.rb +255 -0
- data/lib/utopia/tags/deferred.rb +12 -8
- data/lib/utopia/tags/environment.rb +18 -6
- data/lib/utopia/tags/node.rb +12 -8
- data/lib/utopia/tags/override.rb +12 -12
- data/lib/utopia/version.rb +1 -1
- data/setup/.bowerrc +3 -0
- data/{lib/utopia/setup → setup}/Gemfile +1 -1
- data/setup/Rakefile +4 -0
- data/{lib/utopia/setup → setup}/cache/head/readme.txt +0 -0
- data/{lib/utopia/setup → setup}/cache/meta/readme.txt +0 -0
- data/setup/config.ru +64 -0
- data/{lib/utopia/setup → setup}/lib/readme.txt +0 -0
- data/{lib/utopia/setup → setup}/pages/_heading.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/_page.xnode +1 -1
- data/{lib/utopia/setup → setup}/pages/_static/icon.png +0 -0
- data/setup/pages/_static/site.css +70 -0
- data/{lib/utopia/setup → setup}/pages/errors/exception.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/errors/file-not-found.xnode +0 -0
- data/{lib/utopia/setup → setup}/pages/links.yaml +0 -0
- data/setup/pages/welcome/index.xnode +17 -0
- data/{lib/utopia/setup → setup}/public/readme.txt +0 -0
- data/spec/utopia/content/link_spec.rb +108 -0
- data/spec/utopia/content/links/foo/index.xnode +0 -0
- data/spec/utopia/content/links/foo/links.yaml +2 -0
- data/spec/utopia/content/links/foo/test.de.xnode +0 -0
- data/spec/utopia/content/links/foo/test.en.xnode +0 -0
- data/spec/utopia/content/links/links.yaml +9 -0
- data/spec/utopia/content/links/welcome.xnode +0 -0
- data/spec/utopia/content/localized/five/index.en.xnode +0 -0
- data/spec/utopia/content/localized/four/index.en.xnode +0 -0
- data/spec/utopia/content/localized/four/index.zh.xnode +0 -0
- data/spec/utopia/content/localized/four/links.yaml +4 -0
- data/spec/utopia/content/localized/links.yaml +16 -0
- data/spec/utopia/content/localized/one.xnode +0 -0
- data/spec/utopia/content/localized/three/index.xnode +0 -0
- data/spec/utopia/content/localized/two.en.xnode +0 -0
- data/spec/utopia/content/localized/two.zh.xnode +0 -0
- data/spec/utopia/content/node/ordered/first.xnode +0 -0
- data/spec/utopia/content/node/ordered/index.xnode +0 -0
- data/spec/utopia/content/node/ordered/links.yaml +4 -0
- data/spec/utopia/content/node/ordered/second.xnode +0 -0
- data/spec/utopia/content/node/related/foo.en.xnode +0 -0
- data/spec/utopia/content/node/related/foo.ja.xnode +0 -0
- data/spec/utopia/content/node/related/links.yaml +4 -0
- data/spec/utopia/content/node_spec.rb +63 -0
- data/spec/utopia/{middleware/content_spec.rb → content/processor_spec.rb} +34 -23
- data/spec/utopia/content_spec.rb +87 -0
- data/spec/utopia/content_spec.ru +10 -0
- data/spec/utopia/{middleware/controller_spec.rb → controller_spec.rb} +61 -16
- data/spec/utopia/controller_spec.ru +4 -0
- data/spec/utopia/extensions_spec.rb +6 -17
- data/spec/utopia/localization_spec.rb +60 -0
- data/spec/utopia/localization_spec.ru +11 -0
- data/{lib/utopia/tags.rb → spec/utopia/middleware_spec.rb} +8 -14
- data/spec/utopia/{middleware/content_root → pages}/_heading.xnode +0 -0
- data/spec/utopia/pages/content/_show-value.xnode +1 -0
- data/spec/utopia/pages/content/test-partial.xnode +1 -0
- data/spec/utopia/pages/controller/controller.rb +28 -0
- data/spec/utopia/pages/controller/index.xnode +1 -0
- data/spec/utopia/pages/controller/nested/controller.rb +4 -0
- data/spec/utopia/{middleware/content_root → pages}/index.xnode +0 -0
- data/spec/utopia/pages/localized.de.txt +1 -0
- data/spec/utopia/pages/localized.en.txt +1 -0
- data/spec/utopia/pages/localized.jp.txt +1 -0
- data/spec/utopia/pages/node/index.xnode +1 -0
- data/spec/utopia/pages/test.txt +1 -0
- data/spec/utopia/path_spec.rb +109 -0
- data/spec/utopia/rack_spec.rb +2 -0
- data/spec/utopia/session_spec.rb +82 -0
- data/spec/utopia/session_spec.ru +20 -0
- data/spec/utopia/spec_helper.rb +16 -0
- data/{lib/utopia/extensions/string.rb → spec/utopia/static_spec.rb} +24 -15
- data/spec/utopia/static_spec.ru +4 -0
- data/utopia.gemspec +3 -3
- metadata +138 -54
- data/lib/utopia/extensions/regexp.rb +0 -33
- data/lib/utopia/link.rb +0 -288
- data/lib/utopia/middleware/all.rb +0 -33
- data/lib/utopia/middleware/content.rb +0 -157
- data/lib/utopia/middleware/content/node.rb +0 -386
- data/lib/utopia/middleware/content/processor.rb +0 -123
- data/lib/utopia/middleware/controller.rb +0 -130
- data/lib/utopia/middleware/controller/action.rb +0 -121
- data/lib/utopia/middleware/controller/base.rb +0 -184
- data/lib/utopia/middleware/exception_handler.rb +0 -80
- data/lib/utopia/middleware/localization.rb +0 -147
- data/lib/utopia/middleware/localization/name.rb +0 -69
- data/lib/utopia/middleware/mail_exceptions.rb +0 -138
- data/lib/utopia/middleware/redirector.rb +0 -146
- data/lib/utopia/middleware/requester.rb +0 -126
- data/lib/utopia/middleware/static.rb +0 -295
- data/lib/utopia/setup.rb +0 -60
- data/lib/utopia/setup/config.ru +0 -47
- data/lib/utopia/setup/pages/_static/background.png +0 -0
- data/lib/utopia/setup/pages/_static/site.css +0 -48
- data/lib/utopia/setup/pages/welcome/index.xnode +0 -7
- data/lib/utopia/tag.rb +0 -105
- data/lib/utopia/tags/all.rb +0 -34
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env rspec
|
|
2
|
+
# Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
2
3
|
#
|
|
3
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
5
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,22 +19,30 @@
|
|
|
18
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
20
|
# THE SOFTWARE.
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
require_relative 'spec_helper'
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Trenni::Strings::to_html(self)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def to_quoted_string
|
|
29
|
-
Trenni::Strings::to_quoted_string(self)
|
|
30
|
-
end
|
|
24
|
+
require 'rack'
|
|
25
|
+
require 'rack/test'
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
Trenni::Strings::to_title(self)
|
|
34
|
-
end
|
|
27
|
+
require 'utopia/static'
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
module Utopia::StaticSpec
|
|
30
|
+
describe Utopia::Static do
|
|
31
|
+
include Rack::Test::Methods
|
|
32
|
+
|
|
33
|
+
let(:app) {Rack::Builder.parse_file(File.expand_path('../static_spec.ru', __FILE__)).first}
|
|
34
|
+
|
|
35
|
+
it "should give the correct mime type" do
|
|
36
|
+
get "/test.txt"
|
|
37
|
+
|
|
38
|
+
expect(last_response.header['Content-Type']).to be == 'text/plain'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should return partial content" do
|
|
42
|
+
get "/test.txt", {}, 'HTTP_RANGE' => 'bytes=0-4'
|
|
43
|
+
|
|
44
|
+
expect(last_response.status).to be == 206
|
|
45
|
+
expect(last_response.body).to be == "Hello"
|
|
46
|
+
end
|
|
38
47
|
end
|
|
39
48
|
end
|
data/utopia.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
|
-
spec.add_dependency "trenni", "~> 1.
|
|
25
|
+
spec.add_dependency "trenni", "~> 1.4.1"
|
|
26
26
|
spec.add_dependency "mime-types", "~> 2.0"
|
|
27
27
|
|
|
28
28
|
spec.add_dependency "rack", "~> 1.5"
|
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_dependency "mail", "~> 2.6.1"
|
|
32
32
|
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 1.3"
|
|
34
|
-
spec.add_development_dependency "rspec", "~> 3.
|
|
35
|
-
spec.add_development_dependency "
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
|
35
|
+
spec.add_development_dependency "puma"
|
|
36
36
|
spec.add_development_dependency "rake"
|
|
37
37
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utopia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: trenni
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.
|
|
19
|
+
version: 1.4.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.
|
|
26
|
+
version: 1.4.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: mime-types
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,16 +100,16 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 3.
|
|
103
|
+
version: 3.1.0
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 3.
|
|
110
|
+
version: 3.1.0
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: puma
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - ">="
|
|
@@ -154,64 +154,103 @@ files:
|
|
|
154
154
|
- Rakefile
|
|
155
155
|
- bin/utopia
|
|
156
156
|
- lib/utopia.rb
|
|
157
|
+
- lib/utopia/content.rb
|
|
158
|
+
- lib/utopia/content/link.rb
|
|
159
|
+
- lib/utopia/content/links.rb
|
|
160
|
+
- lib/utopia/content/node.rb
|
|
161
|
+
- lib/utopia/content/processor.rb
|
|
162
|
+
- lib/utopia/content/tag.rb
|
|
163
|
+
- lib/utopia/controller.rb
|
|
164
|
+
- lib/utopia/controller/action.rb
|
|
165
|
+
- lib/utopia/controller/base.rb
|
|
166
|
+
- lib/utopia/controller/variables.rb
|
|
167
|
+
- lib/utopia/exception_handler.rb
|
|
157
168
|
- lib/utopia/extensions/array.rb
|
|
158
169
|
- lib/utopia/extensions/date.rb
|
|
159
|
-
- lib/utopia/extensions/hash.rb
|
|
160
170
|
- lib/utopia/extensions/rack.rb
|
|
161
|
-
- lib/utopia/extensions/regexp.rb
|
|
162
|
-
- lib/utopia/extensions/string.rb
|
|
163
171
|
- lib/utopia/http.rb
|
|
164
|
-
- lib/utopia/
|
|
172
|
+
- lib/utopia/localization.rb
|
|
173
|
+
- lib/utopia/mail_exceptions.rb
|
|
165
174
|
- lib/utopia/middleware.rb
|
|
166
|
-
- lib/utopia/middleware/all.rb
|
|
167
|
-
- lib/utopia/middleware/content.rb
|
|
168
|
-
- lib/utopia/middleware/content/node.rb
|
|
169
|
-
- lib/utopia/middleware/content/processor.rb
|
|
170
|
-
- lib/utopia/middleware/controller.rb
|
|
171
|
-
- lib/utopia/middleware/controller/action.rb
|
|
172
|
-
- lib/utopia/middleware/controller/base.rb
|
|
173
|
-
- lib/utopia/middleware/controller/variables.rb
|
|
174
|
-
- lib/utopia/middleware/directory_index.rb
|
|
175
|
-
- lib/utopia/middleware/exception_handler.rb
|
|
176
|
-
- lib/utopia/middleware/localization.rb
|
|
177
|
-
- lib/utopia/middleware/localization/name.rb
|
|
178
|
-
- lib/utopia/middleware/mail_exceptions.rb
|
|
179
|
-
- lib/utopia/middleware/redirector.rb
|
|
180
|
-
- lib/utopia/middleware/requester.rb
|
|
181
|
-
- lib/utopia/middleware/static.rb
|
|
182
175
|
- lib/utopia/path.rb
|
|
176
|
+
- lib/utopia/redirector.rb
|
|
177
|
+
- lib/utopia/session.rb
|
|
183
178
|
- lib/utopia/session/encrypted_cookie.rb
|
|
184
|
-
- lib/utopia/
|
|
185
|
-
- lib/utopia/
|
|
186
|
-
- lib/utopia/setup/cache/head/readme.txt
|
|
187
|
-
- lib/utopia/setup/cache/meta/readme.txt
|
|
188
|
-
- lib/utopia/setup/config.ru
|
|
189
|
-
- lib/utopia/setup/lib/readme.txt
|
|
190
|
-
- lib/utopia/setup/pages/_heading.xnode
|
|
191
|
-
- lib/utopia/setup/pages/_page.xnode
|
|
192
|
-
- lib/utopia/setup/pages/_static/background.png
|
|
193
|
-
- lib/utopia/setup/pages/_static/icon.png
|
|
194
|
-
- lib/utopia/setup/pages/_static/site.css
|
|
195
|
-
- lib/utopia/setup/pages/errors/exception.xnode
|
|
196
|
-
- lib/utopia/setup/pages/errors/file-not-found.xnode
|
|
197
|
-
- lib/utopia/setup/pages/links.yaml
|
|
198
|
-
- lib/utopia/setup/pages/welcome/index.xnode
|
|
199
|
-
- lib/utopia/setup/public/readme.txt
|
|
200
|
-
- lib/utopia/tag.rb
|
|
201
|
-
- lib/utopia/tags.rb
|
|
202
|
-
- lib/utopia/tags/all.rb
|
|
179
|
+
- lib/utopia/session/lazy_hash.rb
|
|
180
|
+
- lib/utopia/static.rb
|
|
203
181
|
- lib/utopia/tags/deferred.rb
|
|
204
182
|
- lib/utopia/tags/environment.rb
|
|
205
183
|
- lib/utopia/tags/node.rb
|
|
206
184
|
- lib/utopia/tags/override.rb
|
|
207
185
|
- lib/utopia/version.rb
|
|
186
|
+
- setup/.bowerrc
|
|
187
|
+
- setup/Gemfile
|
|
188
|
+
- setup/Rakefile
|
|
189
|
+
- setup/cache/head/readme.txt
|
|
190
|
+
- setup/cache/meta/readme.txt
|
|
191
|
+
- setup/config.ru
|
|
192
|
+
- setup/lib/readme.txt
|
|
193
|
+
- setup/pages/_heading.xnode
|
|
194
|
+
- setup/pages/_page.xnode
|
|
195
|
+
- setup/pages/_static/icon.png
|
|
196
|
+
- setup/pages/_static/site.css
|
|
197
|
+
- setup/pages/errors/exception.xnode
|
|
198
|
+
- setup/pages/errors/file-not-found.xnode
|
|
199
|
+
- setup/pages/links.yaml
|
|
200
|
+
- setup/pages/welcome/index.xnode
|
|
201
|
+
- setup/public/readme.txt
|
|
202
|
+
- spec/utopia/content/link_spec.rb
|
|
203
|
+
- spec/utopia/content/links/foo/index.xnode
|
|
204
|
+
- spec/utopia/content/links/foo/links.yaml
|
|
205
|
+
- spec/utopia/content/links/foo/test.de.xnode
|
|
206
|
+
- spec/utopia/content/links/foo/test.en.xnode
|
|
207
|
+
- spec/utopia/content/links/links.yaml
|
|
208
|
+
- spec/utopia/content/links/welcome.xnode
|
|
209
|
+
- spec/utopia/content/localized/five/index.en.xnode
|
|
210
|
+
- spec/utopia/content/localized/four/index.en.xnode
|
|
211
|
+
- spec/utopia/content/localized/four/index.zh.xnode
|
|
212
|
+
- spec/utopia/content/localized/four/links.yaml
|
|
213
|
+
- spec/utopia/content/localized/links.yaml
|
|
214
|
+
- spec/utopia/content/localized/one.xnode
|
|
215
|
+
- spec/utopia/content/localized/three/index.xnode
|
|
216
|
+
- spec/utopia/content/localized/two.en.xnode
|
|
217
|
+
- spec/utopia/content/localized/two.zh.xnode
|
|
218
|
+
- spec/utopia/content/node/ordered/first.xnode
|
|
219
|
+
- spec/utopia/content/node/ordered/index.xnode
|
|
220
|
+
- spec/utopia/content/node/ordered/links.yaml
|
|
221
|
+
- spec/utopia/content/node/ordered/second.xnode
|
|
222
|
+
- spec/utopia/content/node/related/foo.en.xnode
|
|
223
|
+
- spec/utopia/content/node/related/foo.ja.xnode
|
|
224
|
+
- spec/utopia/content/node/related/links.yaml
|
|
225
|
+
- spec/utopia/content/node_spec.rb
|
|
226
|
+
- spec/utopia/content/processor_spec.rb
|
|
227
|
+
- spec/utopia/content_spec.rb
|
|
228
|
+
- spec/utopia/content_spec.ru
|
|
229
|
+
- spec/utopia/controller_spec.rb
|
|
230
|
+
- spec/utopia/controller_spec.ru
|
|
208
231
|
- spec/utopia/extensions_spec.rb
|
|
209
|
-
- spec/utopia/
|
|
210
|
-
- spec/utopia/
|
|
211
|
-
- spec/utopia/
|
|
212
|
-
- spec/utopia/
|
|
232
|
+
- spec/utopia/localization_spec.rb
|
|
233
|
+
- spec/utopia/localization_spec.ru
|
|
234
|
+
- spec/utopia/middleware_spec.rb
|
|
235
|
+
- spec/utopia/pages/_heading.xnode
|
|
236
|
+
- spec/utopia/pages/content/_show-value.xnode
|
|
237
|
+
- spec/utopia/pages/content/test-partial.xnode
|
|
238
|
+
- spec/utopia/pages/controller/controller.rb
|
|
239
|
+
- spec/utopia/pages/controller/index.xnode
|
|
240
|
+
- spec/utopia/pages/controller/nested/controller.rb
|
|
241
|
+
- spec/utopia/pages/index.xnode
|
|
242
|
+
- spec/utopia/pages/localized.de.txt
|
|
243
|
+
- spec/utopia/pages/localized.en.txt
|
|
244
|
+
- spec/utopia/pages/localized.jp.txt
|
|
245
|
+
- spec/utopia/pages/node/index.xnode
|
|
246
|
+
- spec/utopia/pages/test.txt
|
|
213
247
|
- spec/utopia/path_spec.rb
|
|
214
248
|
- spec/utopia/rack_spec.rb
|
|
249
|
+
- spec/utopia/session_spec.rb
|
|
250
|
+
- spec/utopia/session_spec.ru
|
|
251
|
+
- spec/utopia/spec_helper.rb
|
|
252
|
+
- spec/utopia/static_spec.rb
|
|
253
|
+
- spec/utopia/static_spec.ru
|
|
215
254
|
- utopia.gemspec
|
|
216
255
|
homepage: https://github.com/ioquatix/utopia
|
|
217
256
|
licenses: []
|
|
@@ -237,10 +276,55 @@ signing_key:
|
|
|
237
276
|
specification_version: 4
|
|
238
277
|
summary: Utopia is a framework for building dynamic content-driven websites.
|
|
239
278
|
test_files:
|
|
279
|
+
- spec/utopia/content/link_spec.rb
|
|
280
|
+
- spec/utopia/content/links/foo/index.xnode
|
|
281
|
+
- spec/utopia/content/links/foo/links.yaml
|
|
282
|
+
- spec/utopia/content/links/foo/test.de.xnode
|
|
283
|
+
- spec/utopia/content/links/foo/test.en.xnode
|
|
284
|
+
- spec/utopia/content/links/links.yaml
|
|
285
|
+
- spec/utopia/content/links/welcome.xnode
|
|
286
|
+
- spec/utopia/content/localized/five/index.en.xnode
|
|
287
|
+
- spec/utopia/content/localized/four/index.en.xnode
|
|
288
|
+
- spec/utopia/content/localized/four/index.zh.xnode
|
|
289
|
+
- spec/utopia/content/localized/four/links.yaml
|
|
290
|
+
- spec/utopia/content/localized/links.yaml
|
|
291
|
+
- spec/utopia/content/localized/one.xnode
|
|
292
|
+
- spec/utopia/content/localized/three/index.xnode
|
|
293
|
+
- spec/utopia/content/localized/two.en.xnode
|
|
294
|
+
- spec/utopia/content/localized/two.zh.xnode
|
|
295
|
+
- spec/utopia/content/node/ordered/first.xnode
|
|
296
|
+
- spec/utopia/content/node/ordered/index.xnode
|
|
297
|
+
- spec/utopia/content/node/ordered/links.yaml
|
|
298
|
+
- spec/utopia/content/node/ordered/second.xnode
|
|
299
|
+
- spec/utopia/content/node/related/foo.en.xnode
|
|
300
|
+
- spec/utopia/content/node/related/foo.ja.xnode
|
|
301
|
+
- spec/utopia/content/node/related/links.yaml
|
|
302
|
+
- spec/utopia/content/node_spec.rb
|
|
303
|
+
- spec/utopia/content/processor_spec.rb
|
|
304
|
+
- spec/utopia/content_spec.rb
|
|
305
|
+
- spec/utopia/content_spec.ru
|
|
306
|
+
- spec/utopia/controller_spec.rb
|
|
307
|
+
- spec/utopia/controller_spec.ru
|
|
240
308
|
- spec/utopia/extensions_spec.rb
|
|
241
|
-
- spec/utopia/
|
|
242
|
-
- spec/utopia/
|
|
243
|
-
- spec/utopia/
|
|
244
|
-
- spec/utopia/
|
|
309
|
+
- spec/utopia/localization_spec.rb
|
|
310
|
+
- spec/utopia/localization_spec.ru
|
|
311
|
+
- spec/utopia/middleware_spec.rb
|
|
312
|
+
- spec/utopia/pages/_heading.xnode
|
|
313
|
+
- spec/utopia/pages/content/_show-value.xnode
|
|
314
|
+
- spec/utopia/pages/content/test-partial.xnode
|
|
315
|
+
- spec/utopia/pages/controller/controller.rb
|
|
316
|
+
- spec/utopia/pages/controller/index.xnode
|
|
317
|
+
- spec/utopia/pages/controller/nested/controller.rb
|
|
318
|
+
- spec/utopia/pages/index.xnode
|
|
319
|
+
- spec/utopia/pages/localized.de.txt
|
|
320
|
+
- spec/utopia/pages/localized.en.txt
|
|
321
|
+
- spec/utopia/pages/localized.jp.txt
|
|
322
|
+
- spec/utopia/pages/node/index.xnode
|
|
323
|
+
- spec/utopia/pages/test.txt
|
|
245
324
|
- spec/utopia/path_spec.rb
|
|
246
325
|
- spec/utopia/rack_spec.rb
|
|
326
|
+
- spec/utopia/session_spec.rb
|
|
327
|
+
- spec/utopia/session_spec.ru
|
|
328
|
+
- spec/utopia/spec_helper.rb
|
|
329
|
+
- spec/utopia/static_spec.rb
|
|
330
|
+
- spec/utopia/static_spec.ru
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
class Regexp
|
|
22
|
-
def self.starts_with(string)
|
|
23
|
-
return /^#{Regexp.escape(string)}/
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def self.ends_with(string)
|
|
27
|
-
return /#{Regexp.escape(string)}$/
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.contains(string)
|
|
31
|
-
return Regexp.new(string)
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/utopia/link.rb
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
require 'yaml'
|
|
22
|
-
|
|
23
|
-
require 'utopia/extensions/string'
|
|
24
|
-
require 'utopia/extensions/hash'
|
|
25
|
-
require 'utopia/extensions/array'
|
|
26
|
-
|
|
27
|
-
module Utopia
|
|
28
|
-
|
|
29
|
-
class Link
|
|
30
|
-
XNODE_EXT = ".xnode"
|
|
31
|
-
|
|
32
|
-
def initialize(kind, path, info = nil)
|
|
33
|
-
path = Path.create(path)
|
|
34
|
-
|
|
35
|
-
@info = info ? info.symbolize_keys : {}
|
|
36
|
-
@locale = @info.delete(:locale) || path.locale(XNODE_EXT)
|
|
37
|
-
@kind = kind
|
|
38
|
-
|
|
39
|
-
case @kind
|
|
40
|
-
when :file
|
|
41
|
-
@name = path.basename(XNODE_EXT)
|
|
42
|
-
@path = path
|
|
43
|
-
when :directory
|
|
44
|
-
@name = path.dirname.basename(XNODE_EXT)
|
|
45
|
-
@path = path
|
|
46
|
-
when :virtual
|
|
47
|
-
@name = path.to_s
|
|
48
|
-
@path = @info[:path] ? Path.create(@info[:path]) : nil
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
@components = @name.split(".")
|
|
52
|
-
@title = components[0]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
attr :kind
|
|
56
|
-
attr :name
|
|
57
|
-
attr :path
|
|
58
|
-
attr :locale
|
|
59
|
-
attr :info
|
|
60
|
-
attr :components
|
|
61
|
-
|
|
62
|
-
def [] (key)
|
|
63
|
-
if key == :title
|
|
64
|
-
return @title
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
return @info[key]
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def href
|
|
71
|
-
@info.fetch(:uri) do
|
|
72
|
-
if @path
|
|
73
|
-
@path.to_s
|
|
74
|
-
else
|
|
75
|
-
nil
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def href?
|
|
81
|
-
return href != nil
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def title
|
|
85
|
-
@info[:title] || @title.to_title
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def to_href(options = {})
|
|
89
|
-
options[:content] ||= title
|
|
90
|
-
options[:class] ||= "link"
|
|
91
|
-
|
|
92
|
-
if href?
|
|
93
|
-
"<a class=#{options[:class].dump} href=\"#{href.to_html}\">#{options[:content].to_html}</a>"
|
|
94
|
-
else
|
|
95
|
-
"<span class=#{options[:class].dump}>#{options[:content].to_html}</span>"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def eql? other
|
|
100
|
-
if other && self.class == other.class
|
|
101
|
-
return kind.eql?(other.kind) &&
|
|
102
|
-
name.eql?(other.name) &&
|
|
103
|
-
path.eql?(other.path) &&
|
|
104
|
-
info.eql?(other.info)
|
|
105
|
-
else
|
|
106
|
-
return false
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def == other
|
|
111
|
-
return other && kind == other.kind && name == other.name && path == other.path
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def default_locale
|
|
115
|
-
@locale == ''
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
module Links
|
|
120
|
-
XNODE_FILTER = /^(.+)\.xnode$/
|
|
121
|
-
INDEX_XNODE_FILTER = /^(index(\..+)*)\.xnode$/
|
|
122
|
-
LINKS_YAML = "links.yaml"
|
|
123
|
-
|
|
124
|
-
def self.metadata(path)
|
|
125
|
-
links_path = File.join(path, LINKS_YAML)
|
|
126
|
-
if File.exist?(links_path)
|
|
127
|
-
return YAML::load(File.read(links_path)) || {}
|
|
128
|
-
else
|
|
129
|
-
return {}
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def self.indices(path, &block)
|
|
134
|
-
entries = Dir.entries(path).delete_if{|filename| !filename.match(INDEX_XNODE_FILTER)}
|
|
135
|
-
|
|
136
|
-
if block_given?
|
|
137
|
-
entries.each &block
|
|
138
|
-
else
|
|
139
|
-
return entries
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
DEFAULT_OPTIONS = {
|
|
144
|
-
:directories => true,
|
|
145
|
-
:files => true,
|
|
146
|
-
:virtual => true,
|
|
147
|
-
:indices => false,
|
|
148
|
-
:sort => :order,
|
|
149
|
-
:display => :display,
|
|
150
|
-
:locale => nil
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
def self.index(root, top = Path.new, options = {})
|
|
154
|
-
options = DEFAULT_OPTIONS.merge(options)
|
|
155
|
-
path = File.join(root, top.components)
|
|
156
|
-
metadata = Links.metadata(path)
|
|
157
|
-
|
|
158
|
-
virtual_metadata = metadata.dup
|
|
159
|
-
|
|
160
|
-
links = []
|
|
161
|
-
|
|
162
|
-
Dir.entries(path).each do |filename|
|
|
163
|
-
next if filename.match(/^[\._]/)
|
|
164
|
-
|
|
165
|
-
fullpath = File.join(path, filename)
|
|
166
|
-
|
|
167
|
-
if File.directory?(fullpath) && options[:directories]
|
|
168
|
-
name = filename
|
|
169
|
-
indices_metadata = Links.metadata(fullpath)
|
|
170
|
-
directory_metadata = metadata.delete(name) || {}
|
|
171
|
-
|
|
172
|
-
indices = 0
|
|
173
|
-
Links.indices(fullpath) do |index|
|
|
174
|
-
index_name = File.basename(index, ".xnode")
|
|
175
|
-
# Values in indices_metadata will override values in directory_metadata:
|
|
176
|
-
index_metadata = directory_metadata.merge(indices_metadata[index_name] || {})
|
|
177
|
-
|
|
178
|
-
directory_link = Link.new(:directory, top + [filename, index_name], index_metadata)
|
|
179
|
-
|
|
180
|
-
# Check for localized directory metadata and update the link:
|
|
181
|
-
if directory_link.locale
|
|
182
|
-
localized_metadata = metadata.delete(name + "." + directory_link.locale)
|
|
183
|
-
|
|
184
|
-
if localized_metadata
|
|
185
|
-
directory_link.info.update(localized_metadata.symbolize_keys)
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
links << directory_link
|
|
190
|
-
|
|
191
|
-
indices += 1
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
if indices == 0
|
|
195
|
-
# Specify a nil uri if no index could be found for the directory:
|
|
196
|
-
links << Link.new(:directory, top + [filename, ""], {'uri' => nil}.merge(directory_metadata))
|
|
197
|
-
end
|
|
198
|
-
elsif filename.match(INDEX_XNODE_FILTER) && options[:indices] == false
|
|
199
|
-
name = $1
|
|
200
|
-
metadata.delete(name)
|
|
201
|
-
|
|
202
|
-
# We don't include indices in the list of pages.
|
|
203
|
-
next
|
|
204
|
-
elsif filename.match(XNODE_FILTER) && options[:files]
|
|
205
|
-
name = $1
|
|
206
|
-
|
|
207
|
-
links << Link.new(:file, top + name, metadata.delete(name))
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
if options[:virtual]
|
|
212
|
-
metadata.each do |name, details|
|
|
213
|
-
# Given a virtual named such as "welcome.cn", merge it with metadata from "welcome" if it exists:
|
|
214
|
-
basename, locale = name.split(".", 2)
|
|
215
|
-
|
|
216
|
-
if virtual_metadata[basename]
|
|
217
|
-
details = virtual_metadata[basename].merge(details || {})
|
|
218
|
-
name = basename
|
|
219
|
-
details[:locale] = locale
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
links << Link.new(:virtual, name, details)
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
if options[:display]
|
|
227
|
-
links = links.delete_if{|link| link[options[:display]] == false}
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
if options[:name]
|
|
231
|
-
case options[:name]
|
|
232
|
-
when Regexp
|
|
233
|
-
links.reject!{|link| !link.name.match(options[:name])}
|
|
234
|
-
when String
|
|
235
|
-
links.reject!{|link| link.name.index(options[:name]) != 0}
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
if options[:locale]
|
|
240
|
-
reduced = []
|
|
241
|
-
|
|
242
|
-
links.group_by(&:name).each do |name, links|
|
|
243
|
-
specific = nil
|
|
244
|
-
|
|
245
|
-
links.each do |link|
|
|
246
|
-
if link.locale == options[:locale]
|
|
247
|
-
specific = link
|
|
248
|
-
break
|
|
249
|
-
elsif link.default_locale
|
|
250
|
-
specific ||= link
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
reduced << specific if specific
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
links = reduced
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
if options[:sort]
|
|
261
|
-
sort_key = options[:sort]
|
|
262
|
-
sort_default = options[:sort_default] || 0
|
|
263
|
-
|
|
264
|
-
links = links.sort do |a, b|
|
|
265
|
-
result = nil
|
|
266
|
-
|
|
267
|
-
lhs = a[sort_key] || sort_default
|
|
268
|
-
rhs = b[sort_key] || sort_default
|
|
269
|
-
|
|
270
|
-
begin
|
|
271
|
-
result ||= lhs <=> rhs
|
|
272
|
-
rescue
|
|
273
|
-
# LOG.debug("Invalid comparison between #{a.path} and #{b.path} using key #{options[:sort]}!")
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
if result == 0 || result == nil
|
|
277
|
-
a.title <=> b.title
|
|
278
|
-
else
|
|
279
|
-
result
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
return links
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
end
|