utopia 1.9.11 → 2.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/.codeclimate.yml +3 -2
- data/.gitignore +4 -1
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/.yardopts +2 -0
- data/Gemfile +8 -1
- data/README.md +2 -2
- data/Rakefile +10 -10
- data/benchmarks/call_vs_check.rb +36 -0
- data/benchmarks/const_vs_hash.rb +33 -0
- data/documentation/Gemfile +5 -0
- data/documentation/Guardfile +20 -0
- data/documentation/config.ru +6 -13
- data/documentation/config/puma.rb +20 -0
- data/documentation/pages/_editor.xnode +64 -0
- data/documentation/pages/_heading.xnode +2 -2
- data/documentation/pages/_page.xnode +1 -2
- data/documentation/pages/errors/exception.xnode +3 -3
- data/documentation/pages/errors/file-not-found.xnode +3 -3
- data/documentation/pages/wiki/bower-integration/content.md +1 -1
- data/documentation/pages/wiki/content.md +6 -8
- data/documentation/pages/wiki/controller.rb +3 -3
- data/documentation/pages/wiki/edit.xnode +7 -19
- data/documentation/pages/wiki/middleware/content/content.md +4 -10
- data/documentation/pages/wiki/{controller → middleware/controller}/actions/content.md +0 -0
- data/documentation/pages/wiki/{controller → middleware/controller}/links.yaml +0 -0
- data/documentation/pages/wiki/{controller → middleware/controller}/rewrite/content.md +3 -3
- data/documentation/pages/wiki/show.xnode +4 -6
- data/documentation/pages/wiki/updating-utopia/content.md +55 -0
- data/documentation/pages/wiki/your-first-page/content.md +5 -3
- data/documentation/public/materials +1 -0
- data/lib/utopia.rb +3 -4
- data/lib/utopia/command.rb +4 -284
- data/lib/utopia/command/server.rb +115 -0
- data/lib/utopia/command/setup.rb +78 -0
- data/lib/utopia/command/site.rb +183 -0
- data/lib/utopia/content.rb +83 -59
- data/lib/utopia/content/{transaction.rb → document.rb} +116 -110
- data/lib/utopia/content/link.rb +7 -2
- data/lib/utopia/content/links.rb +2 -1
- data/lib/utopia/content/markup.rb +7 -2
- data/lib/utopia/{tags/deferred.rb → content/namespace.rb} +25 -6
- data/lib/utopia/content/node.rb +74 -76
- data/lib/utopia/content/response.rb +22 -3
- data/lib/utopia/content/tags.rb +66 -0
- data/lib/utopia/controller.rb +10 -18
- data/lib/utopia/controller/actions.rb +10 -0
- data/lib/utopia/controller/base.rb +2 -1
- data/lib/utopia/controller/respond.rb +1 -1
- data/lib/utopia/controller/rewrite.rb +8 -4
- data/lib/utopia/exceptions.rb +1 -0
- data/lib/utopia/exceptions/handler.rb +7 -2
- data/lib/utopia/exceptions/mailer.rb +33 -12
- data/lib/utopia/{tags/node.rb → extensions/array_split.rb} +11 -9
- data/lib/utopia/{tags/environment.rb → extensions/date_comparisons.rb} +24 -14
- data/lib/utopia/http.rb +2 -0
- data/lib/utopia/locale.rb +1 -0
- data/lib/utopia/localization.rb +37 -28
- data/lib/utopia/logger.rb +1 -0
- data/lib/utopia/logger/compact_formatter.rb +1 -0
- data/lib/utopia/middleware.rb +11 -1
- data/lib/utopia/path.rb +1 -0
- data/lib/utopia/path/matcher.rb +14 -2
- data/lib/utopia/redirection.rb +13 -16
- data/lib/utopia/session.rb +14 -6
- data/lib/utopia/setup.rb +3 -1
- data/lib/utopia/static.rb +11 -12
- data/lib/utopia/version.rb +1 -1
- data/setup/server/git/hooks/post-receive +0 -4
- data/setup/site/.gitignore +9 -0
- data/setup/site/.rspec +1 -0
- data/setup/site/Gemfile +4 -0
- data/setup/site/Guardfile +17 -0
- data/setup/site/Rakefile +2 -2
- data/setup/site/config.ru +5 -12
- data/setup/site/pages/_heading.xnode +2 -2
- data/setup/site/pages/_page.xnode +1 -1
- data/setup/site/pages/errors/exception.xnode +3 -3
- data/setup/site/pages/errors/file-not-found.xnode +3 -3
- data/setup/site/pages/welcome/index.xnode +3 -3
- data/setup/site/public/_static/site.css +4 -0
- data/setup/site/spec/spec_helper.rb +29 -0
- data/setup/site/tasks/deploy.rake +13 -0
- data/setup/site/tasks/development.rake +34 -0
- data/setup/site/tasks/environment.rake +17 -0
- data/spec/mock_node.rb +15 -0
- data/spec/spec_helper.rb +29 -0
- data/{lib/utopia/extensions/date.rb → spec/utopia/content/document_spec.rb} +31 -21
- data/spec/utopia/content/markup_spec.rb +2 -2
- data/spec/utopia/content/{tag_spec.rb → namespace_spec.rb} +17 -10
- data/spec/utopia/content/tags_spec.rb +80 -0
- data/spec/utopia/content_spec.rb +1 -1
- data/spec/utopia/content_spec.ru +1 -6
- data/spec/utopia/content_spec/_heading.xnode +1 -1
- data/spec/utopia/content_spec/content/test-partial.xnode +1 -1
- data/spec/utopia/content_spec/index.xnode +1 -1
- data/spec/utopia/controller/middleware_spec.ru +1 -3
- data/spec/utopia/controller/respond_spec.rb +2 -22
- data/spec/utopia/controller/respond_spec.ru +1 -5
- data/spec/utopia/controller/respond_spec/errors/file-not-found.xnode +7 -6
- data/spec/utopia/exceptions/handler_spec.ru +1 -2
- data/spec/utopia/exceptions/mailer_spec.ru +1 -2
- data/spec/utopia/extensions_spec.rb +2 -2
- data/spec/utopia/localization_spec.ru +1 -2
- data/spec/utopia/performance_spec.rb +2 -6
- data/spec/utopia/performance_spec/config.ru +5 -12
- data/spec/utopia/performance_spec/pages/_heading.xnode +2 -2
- data/spec/utopia/performance_spec/pages/_page.xnode +1 -1
- data/spec/utopia/performance_spec/pages/errors/exception.xnode +3 -3
- data/spec/utopia/performance_spec/pages/errors/file-not-found.xnode +3 -3
- data/spec/utopia/performance_spec/pages/welcome/index.xnode +3 -3
- data/spec/utopia/setup_spec.rb +79 -15
- data/utopia.gemspec +3 -3
- metadata +41 -27
- data/.simplecov +0 -9
- data/documentation/pages/welcome/index.xnode +0 -41
- data/lib/utopia/content/tag.rb +0 -90
- data/lib/utopia/extensions/array.rb +0 -29
- data/lib/utopia/tags/override.rb +0 -33
- data/setup/site/.simplecov +0 -9
- data/setup/site/tasks/test.rake +0 -10
- data/setup/site/tasks/utopia.rake +0 -41
- data/spec/utopia/controller/respond_spec/rewrite/controller.rb +0 -12
data/.simplecov
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<page class="front">
|
|
2
|
-
<heading>Welcome to Utopia...</heading>
|
|
3
|
-
|
|
4
|
-
<section class="features">
|
|
5
|
-
<div>
|
|
6
|
-
<i class="fa fa-bolt"></i>
|
|
7
|
-
<h2>Low latency and high throughput</h2>
|
|
8
|
-
<p>Utopia has been carefully tuned for low-latency and algorithmic efficiency. During development, requests reload the entire stack, while in production everything is cached using <a href="http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Map.html">thread-safe data-structures</a>. Serve thousands of requests per second with ease.</p>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<div>
|
|
12
|
-
<i class="fa fa-cubes"></i>
|
|
13
|
-
<h2>Modular code and structure</h2>
|
|
14
|
-
<p>Utopia provides independently useful <a href="https://github.com/rack/rack">Rack</a> middleware and has been designed with simplicify in mind. Several fully-featured webapps and a ton of commercial websites have guided the development of the Utopia stack. It is capable of handling a diverse range of requirements.</p>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<div>
|
|
18
|
-
<i class="fa fa-code"></i>
|
|
19
|
-
<h2>Well tested and maintained</h2>
|
|
20
|
-
<p>Utopia comprises a <a href="https://github.com/ioquatix/utopia">core gem</a> and several supporting libraries, the main ones being <a href="https://github.com/ioquatix/trenni">trenni</a> for templates and parsing, and <a href="https://github.com/ioquatix/http-accept">http-accept</a> for HTTP header processing. Together, these gems have over 90% test coverage.</p>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div>
|
|
24
|
-
<i class="fa fa-server"></i>
|
|
25
|
-
<h2>Batteries included</h2>
|
|
26
|
-
<p>Utopia includes both a recommended development model and a server deployment model out of the box. This is exposed via the <code>utopia</code> command. We recommend use of <a href="https://www.nginx.com">Nginx</a> and <a href="https://www.phusionpassenger.com">Passenger</a> for server side deployment.</p>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div>
|
|
30
|
-
<i class="fa fa-globe"></i>
|
|
31
|
-
<h2>Standards compliant localization</h2>
|
|
32
|
-
<p>Utopia supports the <code>Accept-Language</code> header and transparently selects the correct view to render. Build multi-lingual websites and webapps easily: translate content incrementally as required, or not at all.</p>
|
|
33
|
-
</div>
|
|
34
|
-
</section>
|
|
35
|
-
|
|
36
|
-
<section>
|
|
37
|
-
<h2>Documentation</h2>
|
|
38
|
-
|
|
39
|
-
<p>For up-to-date documentation, please browse the included <a href="/wiki/">wiki</a>. Feel free to improve it and submit a PR :)</p>
|
|
40
|
-
</section>
|
|
41
|
-
</page>
|
data/lib/utopia/content/tag.rb
DELETED
|
@@ -1,90 +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 'trenni/markup'
|
|
22
|
-
|
|
23
|
-
module Utopia
|
|
24
|
-
class Content
|
|
25
|
-
# This represents an individual SGML tag, e.g. <a>, </a> or <a />, with attributes. Attribute values must be escaped.
|
|
26
|
-
Tag = Struct.new(:name, :closed, :attributes) do
|
|
27
|
-
include Trenni::Markup
|
|
28
|
-
|
|
29
|
-
def self.closed(name, **attributes)
|
|
30
|
-
self.new(name, true, attributes)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.opened(name, **attributes)
|
|
34
|
-
self.new(name, false, attributes)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def [] key
|
|
38
|
-
attributes[key]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
alias to_hash attributes
|
|
42
|
-
|
|
43
|
-
def to_s(content = nil)
|
|
44
|
-
buffer = String.new.force_encoding(name.encoding)
|
|
45
|
-
|
|
46
|
-
write(buffer, content)
|
|
47
|
-
|
|
48
|
-
return buffer
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
alias to_str to_s
|
|
52
|
-
|
|
53
|
-
def self_closed?
|
|
54
|
-
closed
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def write_opening_tag(buffer, self_closing = false)
|
|
58
|
-
buffer << "<#{name}"
|
|
59
|
-
|
|
60
|
-
attributes.each do |key, value|
|
|
61
|
-
if value
|
|
62
|
-
buffer << " #{key}=\"#{value}\""
|
|
63
|
-
else
|
|
64
|
-
buffer << " #{key}"
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
if self_closing
|
|
69
|
-
buffer << "/>"
|
|
70
|
-
else
|
|
71
|
-
buffer << ">"
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def write_closing_tag(buffer)
|
|
76
|
-
buffer << "</#{name}>"
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def write(buffer, content = nil)
|
|
80
|
-
if closed and content.nil?
|
|
81
|
-
write_opening_tag(buffer, true)
|
|
82
|
-
else
|
|
83
|
-
write_opening_tag(buffer)
|
|
84
|
-
buffer << content if content
|
|
85
|
-
write_closing_tag(buffer)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,29 +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 Array
|
|
22
|
-
def split_at(*args, &block)
|
|
23
|
-
if middle = index(*args, &block)
|
|
24
|
-
[self[0...middle], self[middle], self[middle+1..-1]]
|
|
25
|
-
else
|
|
26
|
-
[[], nil, []]
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/lib/utopia/tags/override.rb
DELETED
|
@@ -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
|
-
module Utopia
|
|
22
|
-
module Tags
|
|
23
|
-
class Override
|
|
24
|
-
def self.tag_begin(transaction, state)
|
|
25
|
-
state.overrides[state[:name]] = state[:with]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def self.call(transaction, state)
|
|
29
|
-
transaction.parse_markup(state.content)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/setup/site/.simplecov
DELETED
data/setup/site/tasks/test.rake
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
desc 'Run by git post-update hook when deployed to a web server'
|
|
3
|
-
task :deploy do
|
|
4
|
-
# This task is typiclly run after the site is updated but before the server is restarted.
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
desc 'Restart the application server'
|
|
8
|
-
task :restart do
|
|
9
|
-
# This task is run after the deployment task above.
|
|
10
|
-
if passenger_config = `which passenger-config`.chomp!
|
|
11
|
-
sh(passenger_config, 'restart-app', '--ignore-passenger-not-running', File.dirname(__dir__))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
desc 'Set up the environment for running your web application'
|
|
16
|
-
task :environment do
|
|
17
|
-
require_relative '../config/environment'
|
|
18
|
-
|
|
19
|
-
# We ensure this is part of the shell environment so if other commands are invoked they will work correctly.
|
|
20
|
-
ENV['RACK_ENV'] = RACK_ENV.to_s
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
desc 'Run a server for testing your web application'
|
|
24
|
-
task :server => :environment do
|
|
25
|
-
port = ENV.fetch('SERVER_PORT', 9292).to_s
|
|
26
|
-
exec('puma', '-v', '-p', port)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc 'Start an interactive console for your web application'
|
|
30
|
-
task :console => :environment do
|
|
31
|
-
require 'pry'
|
|
32
|
-
require 'rack/test'
|
|
33
|
-
|
|
34
|
-
include Rack::Test::Methods
|
|
35
|
-
|
|
36
|
-
def app
|
|
37
|
-
@app ||= Rack::Builder.parse_file(File.expand_path("../config.ru", __dir__)).first
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
Pry.start
|
|
41
|
-
end
|