utopia 0.12.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/utopia/setup/config.ru
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rackup
|
2
|
-
|
3
|
-
UTOPIA_ENV = (ENV['UTOPIA_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
4
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "lib")
|
5
|
-
|
6
|
-
require 'utopia'
|
7
|
-
|
8
|
-
# Utopia relies heavily on a local cache:
|
9
|
-
require 'rack/cache'
|
10
|
-
|
11
|
-
if UTOPIA_ENV == :development
|
12
|
-
use Rack::ShowExceptions
|
13
|
-
else
|
14
|
-
use Utopia::Middleware::ExceptionHandler, "/errors/exception"
|
15
|
-
use Utopia::Middleware::MailExceptions
|
16
|
-
end
|
17
|
-
|
18
|
-
use Rack::ContentLength
|
19
|
-
|
20
|
-
use Utopia::Middleware::Redirector, {
|
21
|
-
:strings => {
|
22
|
-
'/' => '/welcome/index',
|
23
|
-
},
|
24
|
-
:errors => {
|
25
|
-
404 => "/errors/file-not-found"
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
use Utopia::Middleware::Requester
|
30
|
-
use Utopia::Middleware::DirectoryIndex
|
31
|
-
use Utopia::Middleware::Controller
|
32
|
-
|
33
|
-
# To enable full Sendfile support, please refer to the Rack::Sendfile documentation for your webserver.
|
34
|
-
use Rack::Sendfile
|
35
|
-
use Utopia::Middleware::Static
|
36
|
-
|
37
|
-
if UTOPIA_ENV == :production
|
38
|
-
use Rack::Cache, {
|
39
|
-
:metastore => "file:#{Utopia::Middleware::default_root("cache/meta")}",
|
40
|
-
:entitystore => "file:#{Utopia::Middleware::default_root("cache/body")}",
|
41
|
-
:verbose => false
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
use Utopia::Middleware::Content
|
46
|
-
|
47
|
-
run lambda { |env| [404, {}, []] }
|
Binary file
|
@@ -1,48 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2010 Orion Transfer Ltd. All Rights Reserved. */
|
2
|
-
|
3
|
-
body, p, ol, ul, blockquote {
|
4
|
-
font-family: "Skia", verdana, arial, helvetica, sans-serif;
|
5
|
-
|
6
|
-
color: #339;
|
7
|
-
}
|
8
|
-
|
9
|
-
h1, h2, h3, h4, h5, h6 {
|
10
|
-
font-family: menlo, monospace;
|
11
|
-
color: #303;
|
12
|
-
|
13
|
-
margin-top: 2em;
|
14
|
-
margin-bottom: 1em;
|
15
|
-
}
|
16
|
-
|
17
|
-
body {
|
18
|
-
background: url(/_static/background.png) #fff center no-repeat fixed;
|
19
|
-
padding: 50px;
|
20
|
-
}
|
21
|
-
|
22
|
-
img {
|
23
|
-
border: none;
|
24
|
-
}
|
25
|
-
|
26
|
-
a {
|
27
|
-
color: #33a;
|
28
|
-
}
|
29
|
-
|
30
|
-
a:hover {
|
31
|
-
color: #55c;
|
32
|
-
}
|
33
|
-
|
34
|
-
p, dl, h3 {
|
35
|
-
margin: 1em;
|
36
|
-
}
|
37
|
-
|
38
|
-
h3 {
|
39
|
-
border-bottom: 1px solid #ccf;
|
40
|
-
}
|
41
|
-
|
42
|
-
ul {
|
43
|
-
margin-bottom: 1em;
|
44
|
-
}
|
45
|
-
|
46
|
-
h3, h4, h5, h6 {
|
47
|
-
font-weight: normal;
|
48
|
-
}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<page>
|
2
|
-
<heading>Welcome to Utopia</heading>
|
3
|
-
|
4
|
-
<p>Utopia is designed to simply your life. It is not an application development framework. It is not a content management system. It does not require a database. It isn't model view controller. It is simply a platform on which websites can be easily developed with a minimum of effort.</p>
|
5
|
-
|
6
|
-
<p><a href="http://www.oriontransfer.co.nz/software/utopia/setup">Utopia Project Page & Documentation</a></p>
|
7
|
-
</page>
|
data/lib/utopia/tag.rb
DELETED
@@ -1,105 +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
|
-
class Tag
|
23
|
-
def == other
|
24
|
-
if Tag === other
|
25
|
-
[@name, @attributes, @closed] == [other.name, other.attributes, other.closed]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.closed(name, attributes = {})
|
30
|
-
tag = Tag.new(name, attributes)
|
31
|
-
tag.closed = true
|
32
|
-
|
33
|
-
return tag
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize(name, attributes = {})
|
37
|
-
@name = name
|
38
|
-
@attributes = attributes
|
39
|
-
@closed = false
|
40
|
-
end
|
41
|
-
|
42
|
-
attr :name
|
43
|
-
attr :attributes
|
44
|
-
attr :closed, true
|
45
|
-
|
46
|
-
def [](key)
|
47
|
-
@attributes[key]
|
48
|
-
end
|
49
|
-
|
50
|
-
def append(text)
|
51
|
-
@content ||= StringIO.new
|
52
|
-
@content.write text
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_html(content = nil, buffer = StringIO.new)
|
56
|
-
write_full_html(buffer, content)
|
57
|
-
|
58
|
-
return buffer.string
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_hash
|
62
|
-
@attributes
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_s
|
66
|
-
buffer = StringIO.new
|
67
|
-
write_full_html(buffer)
|
68
|
-
return buffer.string
|
69
|
-
end
|
70
|
-
|
71
|
-
def write_open_html(buffer, terminate = false)
|
72
|
-
buffer ||= StringIO.new
|
73
|
-
buffer.write "<#{name}"
|
74
|
-
|
75
|
-
@attributes.each do |key, value|
|
76
|
-
if value
|
77
|
-
buffer.write " #{key}=\"#{value}\""
|
78
|
-
else
|
79
|
-
buffer.write " #{key}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
if terminate
|
84
|
-
buffer.write "/>"
|
85
|
-
else
|
86
|
-
buffer.write ">"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def write_close_html(buffer)
|
91
|
-
buffer.write "</#{name}>"
|
92
|
-
end
|
93
|
-
|
94
|
-
def write_full_html(buffer, content = nil)
|
95
|
-
if @closed && content == nil
|
96
|
-
write_open_html(buffer, true)
|
97
|
-
else
|
98
|
-
write_open_html(buffer)
|
99
|
-
buffer.write(content)
|
100
|
-
write_close_html(buffer)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
data/lib/utopia/tags/all.rb
DELETED
@@ -1,34 +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 'pathname'
|
22
|
-
|
23
|
-
warn "require 'utopia/tags/all' is deprecated. Require specific tags instead."
|
24
|
-
|
25
|
-
Pathname.new(__FILE__).dirname.entries.each do |path|
|
26
|
-
next unless /\.rb$/ === path.to_s
|
27
|
-
|
28
|
-
name = File.basename(path.to_s, ".rb")
|
29
|
-
|
30
|
-
if name != "all"
|
31
|
-
require "utopia/tags/#{name}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|