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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -2
  3. data/Gemfile +6 -0
  4. data/README.md +48 -14
  5. data/Rakefile +5 -0
  6. data/bin/utopia +132 -15
  7. data/lib/utopia.rb +13 -10
  8. data/lib/utopia/content.rb +140 -0
  9. data/lib/utopia/content/link.rb +124 -0
  10. data/lib/utopia/content/links.rb +228 -0
  11. data/lib/utopia/content/node.rb +387 -0
  12. data/lib/utopia/content/processor.rb +128 -0
  13. data/lib/utopia/content/tag.rb +102 -0
  14. data/lib/utopia/controller.rb +137 -0
  15. data/lib/utopia/controller/action.rb +112 -0
  16. data/lib/utopia/controller/base.rb +174 -0
  17. data/lib/utopia/{middleware/controller → controller}/variables.rb +36 -38
  18. data/lib/utopia/exception_handler.rb +79 -0
  19. data/lib/utopia/extensions/array.rb +2 -2
  20. data/lib/utopia/localization.rb +143 -0
  21. data/lib/utopia/mail_exceptions.rb +136 -0
  22. data/lib/utopia/middleware.rb +7 -22
  23. data/lib/utopia/path.rb +150 -60
  24. data/lib/utopia/redirector.rb +152 -0
  25. data/lib/utopia/{extensions/hash.rb → session.rb} +4 -6
  26. data/lib/utopia/session/encrypted_cookie.rb +46 -48
  27. data/lib/utopia/{middleware/directory_index.rb → session/lazy_hash.rb} +44 -27
  28. data/lib/utopia/static.rb +255 -0
  29. data/lib/utopia/tags/deferred.rb +12 -8
  30. data/lib/utopia/tags/environment.rb +18 -6
  31. data/lib/utopia/tags/node.rb +12 -8
  32. data/lib/utopia/tags/override.rb +12 -12
  33. data/lib/utopia/version.rb +1 -1
  34. data/setup/.bowerrc +3 -0
  35. data/{lib/utopia/setup → setup}/Gemfile +1 -1
  36. data/setup/Rakefile +4 -0
  37. data/{lib/utopia/setup → setup}/cache/head/readme.txt +0 -0
  38. data/{lib/utopia/setup → setup}/cache/meta/readme.txt +0 -0
  39. data/setup/config.ru +64 -0
  40. data/{lib/utopia/setup → setup}/lib/readme.txt +0 -0
  41. data/{lib/utopia/setup → setup}/pages/_heading.xnode +0 -0
  42. data/{lib/utopia/setup → setup}/pages/_page.xnode +1 -1
  43. data/{lib/utopia/setup → setup}/pages/_static/icon.png +0 -0
  44. data/setup/pages/_static/site.css +70 -0
  45. data/{lib/utopia/setup → setup}/pages/errors/exception.xnode +0 -0
  46. data/{lib/utopia/setup → setup}/pages/errors/file-not-found.xnode +0 -0
  47. data/{lib/utopia/setup → setup}/pages/links.yaml +0 -0
  48. data/setup/pages/welcome/index.xnode +17 -0
  49. data/{lib/utopia/setup → setup}/public/readme.txt +0 -0
  50. data/spec/utopia/content/link_spec.rb +108 -0
  51. data/spec/utopia/content/links/foo/index.xnode +0 -0
  52. data/spec/utopia/content/links/foo/links.yaml +2 -0
  53. data/spec/utopia/content/links/foo/test.de.xnode +0 -0
  54. data/spec/utopia/content/links/foo/test.en.xnode +0 -0
  55. data/spec/utopia/content/links/links.yaml +9 -0
  56. data/spec/utopia/content/links/welcome.xnode +0 -0
  57. data/spec/utopia/content/localized/five/index.en.xnode +0 -0
  58. data/spec/utopia/content/localized/four/index.en.xnode +0 -0
  59. data/spec/utopia/content/localized/four/index.zh.xnode +0 -0
  60. data/spec/utopia/content/localized/four/links.yaml +4 -0
  61. data/spec/utopia/content/localized/links.yaml +16 -0
  62. data/spec/utopia/content/localized/one.xnode +0 -0
  63. data/spec/utopia/content/localized/three/index.xnode +0 -0
  64. data/spec/utopia/content/localized/two.en.xnode +0 -0
  65. data/spec/utopia/content/localized/two.zh.xnode +0 -0
  66. data/spec/utopia/content/node/ordered/first.xnode +0 -0
  67. data/spec/utopia/content/node/ordered/index.xnode +0 -0
  68. data/spec/utopia/content/node/ordered/links.yaml +4 -0
  69. data/spec/utopia/content/node/ordered/second.xnode +0 -0
  70. data/spec/utopia/content/node/related/foo.en.xnode +0 -0
  71. data/spec/utopia/content/node/related/foo.ja.xnode +0 -0
  72. data/spec/utopia/content/node/related/links.yaml +4 -0
  73. data/spec/utopia/content/node_spec.rb +63 -0
  74. data/spec/utopia/{middleware/content_spec.rb → content/processor_spec.rb} +34 -23
  75. data/spec/utopia/content_spec.rb +87 -0
  76. data/spec/utopia/content_spec.ru +10 -0
  77. data/spec/utopia/{middleware/controller_spec.rb → controller_spec.rb} +61 -16
  78. data/spec/utopia/controller_spec.ru +4 -0
  79. data/spec/utopia/extensions_spec.rb +6 -17
  80. data/spec/utopia/localization_spec.rb +60 -0
  81. data/spec/utopia/localization_spec.ru +11 -0
  82. data/{lib/utopia/tags.rb → spec/utopia/middleware_spec.rb} +8 -14
  83. data/spec/utopia/{middleware/content_root → pages}/_heading.xnode +0 -0
  84. data/spec/utopia/pages/content/_show-value.xnode +1 -0
  85. data/spec/utopia/pages/content/test-partial.xnode +1 -0
  86. data/spec/utopia/pages/controller/controller.rb +28 -0
  87. data/spec/utopia/pages/controller/index.xnode +1 -0
  88. data/spec/utopia/pages/controller/nested/controller.rb +4 -0
  89. data/spec/utopia/{middleware/content_root → pages}/index.xnode +0 -0
  90. data/spec/utopia/pages/localized.de.txt +1 -0
  91. data/spec/utopia/pages/localized.en.txt +1 -0
  92. data/spec/utopia/pages/localized.jp.txt +1 -0
  93. data/spec/utopia/pages/node/index.xnode +1 -0
  94. data/spec/utopia/pages/test.txt +1 -0
  95. data/spec/utopia/path_spec.rb +109 -0
  96. data/spec/utopia/rack_spec.rb +2 -0
  97. data/spec/utopia/session_spec.rb +82 -0
  98. data/spec/utopia/session_spec.ru +20 -0
  99. data/spec/utopia/spec_helper.rb +16 -0
  100. data/{lib/utopia/extensions/string.rb → spec/utopia/static_spec.rb} +24 -15
  101. data/spec/utopia/static_spec.ru +4 -0
  102. data/utopia.gemspec +3 -3
  103. metadata +138 -54
  104. data/lib/utopia/extensions/regexp.rb +0 -33
  105. data/lib/utopia/link.rb +0 -288
  106. data/lib/utopia/middleware/all.rb +0 -33
  107. data/lib/utopia/middleware/content.rb +0 -157
  108. data/lib/utopia/middleware/content/node.rb +0 -386
  109. data/lib/utopia/middleware/content/processor.rb +0 -123
  110. data/lib/utopia/middleware/controller.rb +0 -130
  111. data/lib/utopia/middleware/controller/action.rb +0 -121
  112. data/lib/utopia/middleware/controller/base.rb +0 -184
  113. data/lib/utopia/middleware/exception_handler.rb +0 -80
  114. data/lib/utopia/middleware/localization.rb +0 -147
  115. data/lib/utopia/middleware/localization/name.rb +0 -69
  116. data/lib/utopia/middleware/mail_exceptions.rb +0 -138
  117. data/lib/utopia/middleware/redirector.rb +0 -146
  118. data/lib/utopia/middleware/requester.rb +0 -126
  119. data/lib/utopia/middleware/static.rb +0 -295
  120. data/lib/utopia/setup.rb +0 -60
  121. data/lib/utopia/setup/config.ru +0 -47
  122. data/lib/utopia/setup/pages/_static/background.png +0 -0
  123. data/lib/utopia/setup/pages/_static/site.css +0 -48
  124. data/lib/utopia/setup/pages/welcome/index.xnode +0 -7
  125. data/lib/utopia/tag.rb +0 -105
  126. data/lib/utopia/tags/all.rb +0 -34
@@ -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, {}, []] }
@@ -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 &amp; Documentation</a></p>
7
- </page>
@@ -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
@@ -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
-