utopia 1.8.3 → 1.9.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/documentation/.bowerrc +4 -0
  4. data/documentation/.rspec +4 -0
  5. data/documentation/Gemfile +27 -0
  6. data/documentation/Rakefile +5 -0
  7. data/documentation/config.ru +50 -0
  8. data/documentation/config/README.md +7 -0
  9. data/documentation/config/environment.rb +10 -0
  10. data/documentation/lib/readme.txt +1 -0
  11. data/documentation/pages/_heading.xnode +2 -0
  12. data/documentation/pages/_page.xnode +28 -0
  13. data/documentation/pages/errors/exception.xnode +5 -0
  14. data/documentation/pages/errors/file-not-found.xnode +5 -0
  15. data/documentation/pages/links.yaml +2 -0
  16. data/documentation/pages/welcome/index.xnode +41 -0
  17. data/documentation/pages/wiki/content.md +7 -0
  18. data/{setup/examples → documentation/pages}/wiki/controller.rb +8 -6
  19. data/documentation/pages/wiki/development-environment-setup/content.md +14 -0
  20. data/{setup/examples → documentation/pages}/wiki/edit.xnode +1 -1
  21. data/documentation/pages/wiki/server-setup/content.md +40 -0
  22. data/documentation/pages/wiki/show.xnode +12 -0
  23. data/documentation/pages/wiki/your-first-page/content.md +31 -0
  24. data/documentation/public +1 -0
  25. data/documentation/spec/website_context.rb +11 -0
  26. data/documentation/spec/website_spec.rb +15 -0
  27. data/documentation/tasks/test.rake +10 -0
  28. data/documentation/tasks/utopia.rake +38 -0
  29. data/lib/utopia/content.rb +2 -2
  30. data/lib/utopia/content/link.rb +5 -1
  31. data/lib/utopia/content/markup.rb +86 -66
  32. data/lib/utopia/content/tag.rb +28 -45
  33. data/lib/utopia/content/transaction.rb +31 -25
  34. data/lib/utopia/controller/actions.rb +1 -0
  35. data/lib/utopia/redirection.rb +4 -4
  36. data/lib/utopia/version.rb +1 -1
  37. data/setup/site/public/_static/site.css +20 -8
  38. data/spec/utopia/content/markup_spec.rb +10 -10
  39. data/spec/utopia/content/tag_spec.rb +36 -0
  40. data/spec/utopia/controller/middleware_spec.ru +4 -1
  41. data/spec/utopia/controller/middleware_spec/controller/controller.rb +2 -0
  42. data/spec/utopia/controller/middleware_spec/controller/nested/controller.rb +2 -0
  43. data/spec/utopia/controller/middleware_spec/redirect/controller.rb +2 -0
  44. data/spec/utopia/controller/middleware_spec/redirect/test/controller.rb +2 -0
  45. data/spec/utopia/controller/respond_spec.ru +5 -2
  46. data/spec/utopia/exceptions/handler_spec.ru +3 -1
  47. data/spec/utopia/exceptions/handler_spec/controller.rb +2 -0
  48. data/spec/utopia/exceptions/mailer_spec.ru +6 -2
  49. data/spec/utopia/localization_spec.rb +2 -2
  50. data/spec/utopia/localization_spec.ru +2 -1
  51. data/spec/utopia/localization_spec/controller.rb +2 -0
  52. data/spec/utopia/performance_spec/config.ru +1 -0
  53. data/spec/utopia/performance_spec/pages/api/controller.rb +1 -1
  54. data/utopia.gemspec +3 -3
  55. metadata +36 -14
  56. data/ext/utopia/xnode/fast_scanner/extconf.rb +0 -6
  57. data/ext/utopia/xnode/fast_scanner/parser.c +0 -289
  58. data/setup/examples/wiki/index.xnode +0 -10
  59. data/setup/examples/wiki/welcome/content.md +0 -3
@@ -133,6 +133,7 @@ module Utopia
133
133
  end
134
134
  end
135
135
 
136
+ # TODO: Test this functionality and confirm working. Document.
136
137
  def otherwise(request, path)
137
138
  end
138
139
 
@@ -78,7 +78,7 @@ module Utopia
78
78
  # We cache 301 redirects for 24 hours.
79
79
  DEFAULT_MAX_AGE = 3600*24
80
80
 
81
- class Redirection
81
+ class ClientRedirect
82
82
  def initialize(app, status: 307, max_age: DEFAULT_MAX_AGE)
83
83
  @app = app
84
84
  @status = status
@@ -123,7 +123,7 @@ module Utopia
123
123
  end
124
124
  end
125
125
 
126
- class DirectoryIndex < Redirection
126
+ class DirectoryIndex < ClientRedirect
127
127
  def initialize(app, index: 'index')
128
128
  @app = app
129
129
  @index = index
@@ -138,7 +138,7 @@ module Utopia
138
138
  end
139
139
  end
140
140
 
141
- class Rewrite < Redirection
141
+ class Rewrite < ClientRedirect
142
142
  def initialize(app, patterns, status: 301)
143
143
  @patterns = patterns
144
144
 
@@ -152,7 +152,7 @@ module Utopia
152
152
  end
153
153
  end
154
154
 
155
- class Moved < Redirection
155
+ class Moved < ClientRedirect
156
156
  def initialize(app, pattern, prefix, status: 301, flatten: false)
157
157
  @app = app
158
158
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.8.3"
22
+ VERSION = "1.9.0"
23
23
  end
@@ -1,15 +1,16 @@
1
1
 
2
2
  html {
3
3
  font-family: "PT Sans", Verdana, Helvetica, Arial, sans-serif;
4
+ font-size: 16px;
4
5
  }
5
6
 
6
- @media (min-width: 48em) {
7
+ @media (min-width: 40em) {
7
8
  html {
8
- font-size: 16px;
9
+ font-size: 18px;
9
10
  }
10
11
  }
11
12
 
12
- @media (min-width: 58em) {
13
+ @media (min-width: 80em) {
13
14
  html {
14
15
  font-size: 20px;
15
16
  }
@@ -23,7 +24,7 @@ body {
23
24
  }
24
25
 
25
26
  body > header {
26
- margin: 1em 0 1em 0;
27
+ margin: 1rem 0 1rem 0;
27
28
 
28
29
  background-color: white;
29
30
 
@@ -35,7 +36,7 @@ body > header {
35
36
  body > header img {
36
37
  display: block;
37
38
  margin: auto;
38
- height: 4em;
39
+ height: 4rem;
39
40
  }
40
41
 
41
42
  p {
@@ -47,7 +48,7 @@ p strong {
47
48
  }
48
49
 
49
50
  h1, h2, h3, h4, h5, h6 {
50
- margin: 2em 1em 1em 1em;
51
+ margin: 2rem 1rem 1rem 1rem;
51
52
  color: #4E8DD9;
52
53
  }
53
54
 
@@ -64,7 +65,16 @@ a:hover {
64
65
  }
65
66
 
66
67
  p, ul, ol, dl, h3 {
67
- margin: 2em;
68
+ margin: 2rem;
69
+ }
70
+
71
+ pre {
72
+ padding: 1rem 3rem;
73
+
74
+ border-top: 1px solid #ccc;
75
+ border-bottom: 1px solid #ccc;
76
+
77
+ background-color: #eee;
68
78
  }
69
79
 
70
80
  h3 {
@@ -72,7 +82,7 @@ h3 {
72
82
  }
73
83
 
74
84
  ul {
75
- margin-bottom: 1em;
85
+ margin-bottom: 1rem;
76
86
  }
77
87
 
78
88
  h2, h3, h4, h5, h6 {
@@ -90,6 +100,8 @@ body.front h1 {
90
100
  footer {
91
101
  text-align: right;
92
102
  margin: 2rem;
103
+ font-size: 0.65rem;
104
+ color: #aaa;
93
105
  }
94
106
 
95
107
  section.features {
@@ -35,9 +35,9 @@ module Utopia::Content::MarkupSpec
35
35
  end
36
36
  end
37
37
 
38
- describe Utopia::Content::Markup do
38
+ describe Utopia::Content::MarkupParser do
39
39
  it "should format open tags correctly" do
40
- foo_tag = Utopia::Content::Tag.new("foo", bar: nil, baz: 'bob')
40
+ foo_tag = Utopia::Content::Tag.opened("foo", bar: nil, baz: 'bob')
41
41
 
42
42
  expect(foo_tag[:bar]).to be nil
43
43
  expect(foo_tag[:baz]).to be == 'bob'
@@ -49,7 +49,7 @@ module Utopia::Content::MarkupSpec
49
49
  delegate = TestDelegate.new
50
50
 
51
51
  buffer = Trenni::Buffer.new(string)
52
- Utopia::Content::Markup.new(buffer, delegate).parse!
52
+ Utopia::Content::MarkupParser.new(buffer, delegate).parse!
53
53
 
54
54
  return delegate
55
55
  end
@@ -58,7 +58,7 @@ module Utopia::Content::MarkupSpec
58
58
 
59
59
  delegate = parse %Q{<foo></foo>}
60
60
 
61
- foo_tag = Utopia::Content::Tag.new("foo")
61
+ foo_tag = Utopia::Content::Tag.opened("foo")
62
62
  expected_events = [
63
63
  [:tag_begin, foo_tag],
64
64
  [:tag_end, foo_tag],
@@ -72,12 +72,12 @@ module Utopia::Content::MarkupSpec
72
72
  it "should parse and escape text" do
73
73
  delegate = parse %Q{<foo>Bob &amp; Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
74
74
 
75
- foo_tag = Utopia::Content::Tag.new("foo")
75
+ foo_tag = Utopia::Content::Tag.opened("foo")
76
76
  expected_events = [
77
77
  [:tag_begin, foo_tag],
78
- [:cdata, "Bob &amp; Barley"],
79
- [:cdata, "<!-- Comment -->"],
80
- [:cdata, "<![CDATA[Hello & World]]>"],
78
+ [:text, "Bob & Barley"],
79
+ [:write, "<!-- Comment -->"],
80
+ [:write, "<![CDATA[Hello & World]]>"],
81
81
  [:tag_end, foo_tag],
82
82
  ]
83
83
 
@@ -85,11 +85,11 @@ module Utopia::Content::MarkupSpec
85
85
  end
86
86
 
87
87
  it "should fail with incorrect closing tag" do
88
- expect{parse %Q{<p>Foobar</dl>}}.to raise_exception(Utopia::Content::Markup::UnbalancedTagError)
88
+ expect{parse %Q{<p>Foobar</dl>}}.to raise_exception(Utopia::Content::MarkupParser::UnbalancedTagError)
89
89
  end
90
90
 
91
91
  it "should fail with unclosed tag" do
92
- expect{parse %Q{<p>Foobar}}.to raise_exception(Utopia::Content::Markup::UnbalancedTagError)
92
+ expect{parse %Q{<p>Foobar}}.to raise_exception(Utopia::Content::MarkupParser::UnbalancedTagError)
93
93
  end
94
94
  end
95
95
  end
@@ -0,0 +1,36 @@
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 'utopia/content/tag'
22
+
23
+ RSpec.describe Utopia::Content::Tag.new("body", false, 'class' => 'main') do
24
+ it "should have name" do
25
+ expect(subject.name).to be == "body"
26
+ end
27
+
28
+ it "should be open by default" do
29
+ expect(subject).to_not be_self_closed
30
+ end
31
+
32
+ it "should have a attribute" do
33
+ expect(subject.attributes).to include('class')
34
+ expect(subject['class']).to be == 'main'
35
+ end
36
+ end
@@ -1,4 +1,7 @@
1
1
 
2
- use Utopia::Controller, root: File.expand_path('middleware_spec', __dir__), cache_controllers: true
2
+ use Utopia::Controller,
3
+ root: File.expand_path('middleware_spec', __dir__),
4
+ base: Utopia::Controller::Base,
5
+ cache_controllers: true
3
6
 
4
7
  run lambda {|env| [404, {}, []]}
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  on 'flat' do
3
5
  succeed! content: "flat"
4
6
  end
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  on 'foobar' do
3
5
  succeed! content: "Foobar"
4
6
  end
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  on '**' do |request, path|
3
5
  # puts "**: #{URI_PATH.inspect}"
4
6
 
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  on 'bar' do |request, path|
3
5
  # puts "bar: #{URI_PATH.inspect}"
4
6
 
@@ -1,6 +1,9 @@
1
1
 
2
- use Utopia::Controller, root: File.expand_path('respond_spec', __dir__)
2
+ use Utopia::Controller,
3
+ root: File.expand_path('respond_spec', __dir__),
4
+ base: Utopia::Controller::Base
3
5
 
4
- use Utopia::Content, root: File.expand_path('respond_spec', __dir__)
6
+ use Utopia::Content,
7
+ root: File.expand_path('respond_spec', __dir__)
5
8
 
6
9
  run lambda {|env| [404, {}, []]}
@@ -1,6 +1,8 @@
1
1
 
2
2
  use Utopia::Exceptions::Handler, '/exception'
3
3
 
4
- use Utopia::Controller, root: File.expand_path('handler_spec', __dir__)
4
+ use Utopia::Controller,
5
+ root: File.expand_path('handler_spec', __dir__),
6
+ base: Utopia::Controller::Base
5
7
 
6
8
  run lambda {|env| [404, {}, []]}
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  class TharSheBlows < StandardError
3
5
  end
4
6
 
@@ -1,6 +1,10 @@
1
1
 
2
- use Utopia::Exceptions::Mailer, delivery_method: :test, from: 'test@localhost'
2
+ use Utopia::Exceptions::Mailer,
3
+ delivery_method: :test,
4
+ from: 'test@localhost'
3
5
 
4
- use Utopia::Controller, root: File.expand_path('handler_spec', __dir__)
6
+ use Utopia::Controller,
7
+ root: File.expand_path('handler_spec', __dir__),
8
+ base: Utopia::Controller::Base
5
9
 
6
10
  run lambda {|env| [404, {}, []]}
@@ -27,8 +27,8 @@ require 'utopia/content'
27
27
  require 'utopia/controller'
28
28
  require 'utopia/localization'
29
29
 
30
- module Utopia::StaticSpec
31
- describe Utopia::Static do
30
+ module Utopia::LocalizationSpec
31
+ describe Utopia::Localization do
32
32
  include Rack::Test::Methods
33
33
 
34
34
  let(:app) {Rack::Builder.parse_file(File.expand_path('../localization_spec.ru', __FILE__)).first}
@@ -6,7 +6,8 @@ use Utopia::Localization,
6
6
  hosts: {/foobar\.com$/ => 'en', /foobar\.co\.jp$/ => 'ja', /foobar\.de$/ => 'de'}
7
7
 
8
8
  use Utopia::Controller,
9
- root: localization_spec_root
9
+ root: localization_spec_root,
10
+ base: Utopia::Controller::Base
10
11
 
11
12
  use Utopia::Static,
12
13
  root: localization_spec_root
@@ -1,4 +1,6 @@
1
1
 
2
+ prepend Actions
3
+
2
4
  on 'all_locales' do |request, path|
3
5
  wrapper = Utopia::Localization[request]
4
6
 
@@ -21,6 +21,7 @@ use Utopia::Redirection::Errors,
21
21
 
22
22
  use Utopia::Controller,
23
23
  root: File.expand_path('pages', __dir__),
24
+ base: Utopia::Controller::Base,
24
25
  cache_controllers: true
25
26
 
26
27
  use Utopia::Static,
@@ -1,5 +1,5 @@
1
1
 
2
- prepend Respond
2
+ prepend Respond, Actions
3
3
  respond.with_json
4
4
 
5
5
  on 'fetch' do
data/utopia.gemspec CHANGED
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '~> 2.2'
26
26
 
27
- spec.add_dependency 'trenni', '~> 1.6'
27
+ spec.add_dependency 'trenni', '~> 2.0'
28
28
  spec.add_dependency 'mime-types', '~> 3.0'
29
29
 
30
- spec.add_dependency 'samovar', '~> 1.1'
30
+ spec.add_dependency 'samovar', '~> 1.2'
31
31
 
32
32
  spec.add_dependency 'rack', '~> 2.0'
33
33
 
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency 'concurrent-ruby', '~> 1.0'
39
39
 
40
40
  spec.add_development_dependency 'bundler', '~> 1.3'
41
- spec.add_development_dependency 'rspec', '~> 3.4.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.4'
42
42
  spec.add_development_dependency 'puma'
43
43
  spec.add_development_dependency 'rake'
44
44
  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: 1.8.3
4
+ version: 1.9.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: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2016-11-28 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.6'
19
+ version: '2.0'
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.6'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mime-types
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.1'
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.1'
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.4.0
131
+ version: '3.4'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.4.0
138
+ version: '3.4'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: puma
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -186,8 +186,32 @@ files:
186
186
  - benchmarks/string_vs_symbol.rb
187
187
  - benchmarks/struct_vs_class.rb
188
188
  - bin/utopia
189
- - ext/utopia/xnode/fast_scanner/extconf.rb
190
- - ext/utopia/xnode/fast_scanner/parser.c
189
+ - documentation/.bowerrc
190
+ - documentation/.rspec
191
+ - documentation/Gemfile
192
+ - documentation/Rakefile
193
+ - documentation/config.ru
194
+ - documentation/config/README.md
195
+ - documentation/config/environment.rb
196
+ - documentation/lib/readme.txt
197
+ - documentation/pages/_heading.xnode
198
+ - documentation/pages/_page.xnode
199
+ - documentation/pages/errors/exception.xnode
200
+ - documentation/pages/errors/file-not-found.xnode
201
+ - documentation/pages/links.yaml
202
+ - documentation/pages/welcome/index.xnode
203
+ - documentation/pages/wiki/content.md
204
+ - documentation/pages/wiki/controller.rb
205
+ - documentation/pages/wiki/development-environment-setup/content.md
206
+ - documentation/pages/wiki/edit.xnode
207
+ - documentation/pages/wiki/server-setup/content.md
208
+ - documentation/pages/wiki/show.xnode
209
+ - documentation/pages/wiki/your-first-page/content.md
210
+ - documentation/public
211
+ - documentation/spec/website_context.rb
212
+ - documentation/spec/website_spec.rb
213
+ - documentation/tasks/test.rake
214
+ - documentation/tasks/utopia.rake
191
215
  - lib/utopia.rb
192
216
  - lib/utopia/command.rb
193
217
  - lib/utopia/content.rb
@@ -229,10 +253,6 @@ files:
229
253
  - materials/utopia.png
230
254
  - materials/utopia.svg
231
255
  - setup/.bowerrc
232
- - setup/examples/wiki/controller.rb
233
- - setup/examples/wiki/edit.xnode
234
- - setup/examples/wiki/index.xnode
235
- - setup/examples/wiki/welcome/content.md
236
256
  - setup/server/config/environment.yaml
237
257
  - setup/server/git/hooks/post-receive
238
258
  - setup/site/.bowerrc
@@ -288,6 +308,7 @@ files:
288
308
  - spec/utopia/content/node/related/links.yaml
289
309
  - spec/utopia/content/node_spec.rb
290
310
  - spec/utopia/content/response_spec.rb
311
+ - spec/utopia/content/tag_spec.rb
291
312
  - spec/utopia/content_spec.rb
292
313
  - spec/utopia/content_spec.ru
293
314
  - spec/utopia/content_spec/_heading.xnode
@@ -405,6 +426,7 @@ test_files:
405
426
  - spec/utopia/content/node/related/links.yaml
406
427
  - spec/utopia/content/node_spec.rb
407
428
  - spec/utopia/content/response_spec.rb
429
+ - spec/utopia/content/tag_spec.rb
408
430
  - spec/utopia/content_spec.rb
409
431
  - spec/utopia/content_spec.ru
410
432
  - spec/utopia/content_spec/_heading.xnode