spontaneous 0.2.0.beta4 → 0.2.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/Gemfile +11 -6
  4. data/Readme.markdown +136 -69
  5. data/application/css/core.css.scss +27 -7
  6. data/application/css/editing.css.scss +4 -26
  7. data/application/css/schema_error.css.scss +22 -0
  8. data/application/js/content.js +11 -3
  9. data/application/js/edit_panel.js +1 -4
  10. data/application/js/field/file.js +17 -0
  11. data/application/js/field/image.js +30 -21
  12. data/application/js/field/string.js +4 -1
  13. data/application/js/field_preview.js +21 -16
  14. data/application/js/publish.js +6 -6
  15. data/application/js/types.js +5 -13
  16. data/application/js/views.js +2 -2
  17. data/application/js/views/box_view.js +3 -2
  18. data/application/js/views/page_piece_view.js +1 -1
  19. data/application/js/views/piece_view.js +1 -1
  20. data/application/views/schema_modification_error.html.erb +13 -3
  21. data/db/migrations/20131104101935_site_must_publish_all.rb +14 -0
  22. data/lib/spontaneous.rb +0 -1
  23. data/lib/spontaneous/box_style.rb +15 -9
  24. data/lib/spontaneous/capistrano/deploy.rb +13 -1
  25. data/lib/spontaneous/change.rb +11 -13
  26. data/lib/spontaneous/cli.rb +5 -2
  27. data/lib/spontaneous/cli/assets.rb +7 -1
  28. data/lib/spontaneous/cli/console.rb +7 -1
  29. data/lib/spontaneous/cli/content.rb +35 -0
  30. data/lib/spontaneous/cli/fields.rb +3 -2
  31. data/lib/spontaneous/cli/generate.rb +5 -2
  32. data/lib/spontaneous/cli/server.rb +12 -8
  33. data/lib/spontaneous/cli/site.rb +12 -12
  34. data/lib/spontaneous/cli/user.rb +28 -14
  35. data/lib/spontaneous/collections/box_set.rb +4 -4
  36. data/lib/spontaneous/collections/field_set.rb +4 -4
  37. data/lib/spontaneous/collections/prototype_set.rb +12 -4
  38. data/lib/spontaneous/data_mapper.rb +11 -7
  39. data/lib/spontaneous/data_mapper/content_model.rb +8 -0
  40. data/lib/spontaneous/data_mapper/content_model/associations.rb +1 -1
  41. data/lib/spontaneous/data_mapper/dataset.rb +14 -2
  42. data/lib/spontaneous/data_mapper/scope.rb +33 -13
  43. data/lib/spontaneous/facet.rb +4 -0
  44. data/lib/spontaneous/field.rb +12 -12
  45. data/lib/spontaneous/field/base.rb +27 -22
  46. data/lib/spontaneous/field/boolean.rb +4 -4
  47. data/lib/spontaneous/field/date.rb +2 -2
  48. data/lib/spontaneous/field/file.rb +24 -18
  49. data/lib/spontaneous/field/html.rb +1 -1
  50. data/lib/spontaneous/field/image.rb +6 -19
  51. data/lib/spontaneous/field/location.rb +1 -1
  52. data/lib/spontaneous/field/long_string.rb +3 -3
  53. data/lib/spontaneous/field/markdown.rb +3 -3
  54. data/lib/spontaneous/field/select.rb +2 -2
  55. data/lib/spontaneous/field/string.rb +2 -2
  56. data/lib/spontaneous/field/tags.rb +2 -2
  57. data/lib/spontaneous/field/update.rb +21 -20
  58. data/lib/spontaneous/field/webvideo.rb +6 -6
  59. data/lib/spontaneous/field/webvideo/fallback.rb +2 -2
  60. data/lib/spontaneous/field/webvideo/vimeo.rb +7 -7
  61. data/lib/spontaneous/generators/site.rb +2 -2
  62. data/lib/spontaneous/generators/site/Gemfile.tt +5 -1
  63. data/lib/spontaneous/layout.rb +2 -2
  64. data/lib/spontaneous/media.rb +1 -0
  65. data/lib/spontaneous/media/file.rb +6 -5
  66. data/lib/spontaneous/media/image/attributes.rb +4 -0
  67. data/lib/spontaneous/media/image/renderable.rb +4 -4
  68. data/lib/spontaneous/media/store.rb +22 -0
  69. data/lib/spontaneous/{storage → media/store}/backend.rb +1 -1
  70. data/lib/spontaneous/{storage → media/store}/cloud.rb +1 -1
  71. data/lib/spontaneous/{storage → media/store}/local.rb +1 -1
  72. data/lib/spontaneous/media/temp_file.rb +1 -1
  73. data/lib/spontaneous/model.rb +10 -7
  74. data/lib/spontaneous/model/action.rb +7 -0
  75. data/lib/spontaneous/model/action/clean.rb +87 -0
  76. data/lib/spontaneous/model/box/allowed_types.rb +15 -1
  77. data/lib/spontaneous/model/core.rb +10 -0
  78. data/lib/spontaneous/model/core/aliases.rb +1 -1
  79. data/lib/spontaneous/model/core/content_groups.rb +1 -1
  80. data/lib/spontaneous/model/core/fields.rb +1 -1
  81. data/lib/spontaneous/model/core/modifications.rb +2 -2
  82. data/lib/spontaneous/model/core/page_search.rb +4 -0
  83. data/lib/spontaneous/model/core/publishing.rb +4 -17
  84. data/lib/spontaneous/model/core/render.rb +4 -4
  85. data/lib/spontaneous/model/core/styles.rb +2 -2
  86. data/lib/spontaneous/model/core/visibility.rb +6 -2
  87. data/lib/spontaneous/model/page.rb +6 -2
  88. data/lib/spontaneous/model/page/controllers.rb +55 -17
  89. data/lib/spontaneous/model/page/formats.rb +12 -7
  90. data/lib/spontaneous/model/page/layouts.rb +2 -2
  91. data/lib/spontaneous/model/page/locks.rb +4 -1
  92. data/lib/spontaneous/model/page/page_tree.rb +40 -6
  93. data/lib/spontaneous/output.rb +14 -52
  94. data/lib/spontaneous/output/context.rb +11 -39
  95. data/lib/spontaneous/output/context/navigation.rb +31 -0
  96. data/lib/spontaneous/output/format.rb +15 -19
  97. data/lib/spontaneous/output/renderable.rb +99 -0
  98. data/lib/spontaneous/output/store.rb +24 -0
  99. data/lib/spontaneous/output/store/backend.rb +52 -0
  100. data/lib/spontaneous/output/store/file.rb +77 -0
  101. data/lib/spontaneous/output/store/moneta.rb +117 -0
  102. data/lib/spontaneous/output/store/revision.rb +34 -0
  103. data/lib/spontaneous/output/store/store.rb +15 -0
  104. data/lib/spontaneous/output/store/transaction.rb +44 -0
  105. data/lib/spontaneous/output/template/engine.rb +17 -7
  106. data/lib/spontaneous/output/template/renderer.rb +66 -40
  107. data/lib/spontaneous/page_lock.rb +5 -7
  108. data/lib/spontaneous/page_piece.rb +2 -2
  109. data/lib/spontaneous/permissions/user.rb +14 -7
  110. data/lib/spontaneous/plugins/application/features.rb +8 -4
  111. data/lib/spontaneous/plugins/application/state.rb +12 -6
  112. data/lib/spontaneous/prototypes/box_prototype.rb +9 -10
  113. data/lib/spontaneous/prototypes/field_prototype.rb +66 -15
  114. data/lib/spontaneous/publishing/immediate.rb +30 -26
  115. data/lib/spontaneous/rack.rb +12 -7
  116. data/lib/spontaneous/rack/back.rb +43 -37
  117. data/lib/spontaneous/rack/back/base.rb +4 -4
  118. data/lib/spontaneous/rack/back/changes.rb +2 -2
  119. data/lib/spontaneous/rack/back/file.rb +16 -24
  120. data/lib/spontaneous/rack/back/map.rb +5 -5
  121. data/lib/spontaneous/rack/back/preview.rb +3 -4
  122. data/lib/spontaneous/rack/back/schema.rb +1 -1
  123. data/lib/spontaneous/rack/back/site.rb +6 -7
  124. data/lib/spontaneous/rack/front.rb +19 -16
  125. data/lib/spontaneous/rack/middleware/authenticate.rb +3 -3
  126. data/lib/spontaneous/rack/middleware/reloader.rb +3 -2
  127. data/lib/spontaneous/rack/middleware/scope.rb +25 -19
  128. data/lib/spontaneous/rack/page_controller.rb +164 -13
  129. data/lib/spontaneous/rack/public.rb +23 -62
  130. data/lib/spontaneous/rack/static.rb +2 -3
  131. data/lib/spontaneous/schema.rb +27 -8
  132. data/lib/spontaneous/schema/schema_modification.rb +9 -1
  133. data/lib/spontaneous/schema/uid.rb +2 -2
  134. data/lib/spontaneous/schema/uid_map.rb +3 -2
  135. data/lib/spontaneous/search/database.rb +2 -2
  136. data/lib/spontaneous/search/field.rb +5 -3
  137. data/lib/spontaneous/search/index.rb +12 -7
  138. data/lib/spontaneous/search/results.rb +5 -3
  139. data/lib/spontaneous/server.rb +2 -2
  140. data/lib/spontaneous/site.rb +10 -3
  141. data/lib/spontaneous/site/features.rb +26 -6
  142. data/lib/spontaneous/site/helpers.rb +9 -12
  143. data/lib/spontaneous/site/level.rb +7 -9
  144. data/lib/spontaneous/site/map.rb +9 -11
  145. data/lib/spontaneous/site/paths.rb +5 -5
  146. data/lib/spontaneous/site/publishing.rb +83 -80
  147. data/lib/spontaneous/site/schema.rb +1 -7
  148. data/lib/spontaneous/site/search.rb +8 -18
  149. data/lib/spontaneous/site/selectors.rb +60 -54
  150. data/lib/spontaneous/site/state.rb +36 -30
  151. data/lib/spontaneous/site/storage.rb +10 -16
  152. data/lib/spontaneous/state.rb +8 -0
  153. data/lib/spontaneous/style.rb +32 -33
  154. data/lib/spontaneous/version.rb +1 -1
  155. data/spontaneous.gemspec +22 -21
  156. data/test/fixtures/public/templates/layouts/default.html.cut +1 -1
  157. data/test/fixtures/public/templates/layouts/default.pdf.cut +1 -1
  158. data/test/fixtures/public/templates/layouts/default.rss.cut +1 -1
  159. data/test/fixtures/search/config/indexes.rb +1 -1
  160. data/test/fixtures/serialisation/class_hash.yaml.erb +13 -1
  161. data/test/fixtures/serialisation/root_hash.yaml.erb +10 -0
  162. data/test/functional/test_application.rb +20 -24
  163. data/test/functional/test_back.rb +26 -27
  164. data/test/functional/test_cli.rb +146 -0
  165. data/test/functional/test_front.rb +287 -216
  166. data/test/functional/test_user_manager.rb +1 -1
  167. data/test/test_helper.rb +15 -11
  168. data/test/unit/test_alias.rb +32 -25
  169. data/test/unit/test_asset_bundler.rb +1 -1
  170. data/test/unit/test_assets.rb +34 -33
  171. data/test/unit/test_authentication.rb +1 -1
  172. data/test/unit/test_boxes.rb +16 -2
  173. data/test/unit/test_changesets.rb +23 -11
  174. data/test/unit/test_content.rb +15 -0
  175. data/test/unit/test_context.rb +139 -0
  176. data/test/unit/test_controllers.rb +374 -0
  177. data/test/{experimental → unit}/test_crypt.rb +0 -0
  178. data/test/unit/test_datamapper.rb +260 -237
  179. data/test/unit/test_datamapper_content.rb +42 -12
  180. data/test/{experimental → unit}/test_features.rb +85 -3
  181. data/test/unit/test_fields.rb +117 -42
  182. data/test/unit/test_formats.rb +11 -1
  183. data/test/unit/test_generators.rb +2 -2
  184. data/test/unit/test_helpers.rb +7 -8
  185. data/test/unit/test_images.rb +39 -2
  186. data/test/unit/test_layouts.rb +14 -12
  187. data/test/unit/test_media.rb +32 -23
  188. data/test/unit/test_output_store.rb +342 -0
  189. data/test/unit/test_page.rb +8 -1
  190. data/test/unit/test_permissions.rb +11 -7
  191. data/test/unit/test_plugins.rb +3 -3
  192. data/test/unit/test_prototype_set.rb +8 -1
  193. data/test/unit/test_publishing.rb +67 -54
  194. data/test/unit/test_render.rb +91 -38
  195. data/test/unit/test_revisions.rb +4 -4
  196. data/test/unit/test_schema.rb +109 -84
  197. data/test/unit/test_search.rb +42 -42
  198. data/test/unit/test_serialisation.rb +3 -2
  199. data/test/unit/test_site.rb +39 -27
  200. data/test/unit/test_storage.rb +9 -6
  201. data/test/unit/test_styles.rb +25 -32
  202. data/test/unit/test_templates.rb +8 -4
  203. metadata +89 -54
  204. data/lib/spontaneous/model/page/request.rb +0 -105
  205. data/lib/spontaneous/storage.rb +0 -22
@@ -20,20 +20,6 @@ class Spontaneous::Site
20
20
  module Storage
21
21
  extend Spontaneous::Concern
22
22
 
23
- module ClassMethods
24
- def storage(mimetype = nil)
25
- instance.storage(mimetype)
26
- end
27
-
28
- def local_storage
29
- instance.local_storage
30
- end
31
-
32
- def default_storage
33
- instance.default_storage
34
- end
35
- end # ClassMethods
36
-
37
23
  def storage(mimetype = nil)
38
24
  storage_for_mimetype(mimetype)
39
25
  end
@@ -54,14 +40,22 @@ class Spontaneous::Site
54
40
  storage_backends = []
55
41
  storage_settings = config[:storage] || []
56
42
  storage_settings.each do |name, config|
57
- backend = Spontaneous::Storage.create(config)
43
+ backend = Spontaneous::Media::Store.create(config)
58
44
  storage_backends << backend
59
45
  end
60
46
  storage_backends << default_storage
61
47
  end
62
48
 
63
49
  def default_storage
64
- @default_storage ||= Spontaneous::Storage::Local.new(Spontaneous.media_dir, '/media', accepts=nil)
50
+ @default_storage ||= Spontaneous::Media::Store::Local.new(Spontaneous.media_dir, '/media', accepts=nil)
51
+ end
52
+
53
+ def file(owner, filename, headers = {})
54
+ Spontaneous::Media::File.new(self, owner, filename, headers)
55
+ end
56
+
57
+ def tempfile(owner, filename, headers = {})
58
+ Spontaneous::Media::TempFile.new(self, owner, filename, headers)
65
59
  end
66
60
  end
67
61
  end
@@ -53,6 +53,14 @@ module Spontaneous
53
53
  instance.modified_at || Time.now
54
54
  end
55
55
 
56
+ def must_publish_all?
57
+ instance.must_publish_all
58
+ end
59
+
60
+ def must_publish_all!(state = true)
61
+ instance.update must_publish_all: state
62
+ end
63
+
56
64
  # Called by Page.after_create and Page.after_destroy in order to update
57
65
  # the Site's modification time
58
66
  def site_modified!
@@ -3,11 +3,6 @@
3
3
 
4
4
  module Spontaneous
5
5
  class Style
6
- def self.to_directory_name(klass)
7
- return nil if klass.name.blank?
8
- klass.name.demodulize.underscore
9
- end
10
-
11
6
  attr_reader :owner, :prototype
12
7
 
13
8
  def initialize(owner, prototype = nil)
@@ -18,52 +13,47 @@ module Spontaneous
18
13
  self.prototype.schema_id
19
14
  end
20
15
 
21
- def template(format = :html)
22
- inline_template(format) || external_template(format)
16
+ def template(format = :html, renderer = default_renderer)
17
+ inline_template(format) || external_template(format, renderer)
23
18
  end
24
19
 
25
- def external_template(format = :html)
26
- unless (template = (file_template(format) || supertype_template(format)))
20
+ def external_template(format = :html, renderer)
21
+ unless (template = (file_template(format, renderer) || supertype_template(format, renderer)))
27
22
  logger.warn("No template file found for style #{owner}:#{name}.#{format}")
28
23
  template = anonymous_template
29
24
  end
30
25
  template
31
26
  end
32
27
 
33
- def file_template(format)
34
- local_template(format)
28
+ def file_template(format, renderer)
29
+ local_template(format, renderer)
35
30
  end
36
31
 
37
32
  # Tests to see if a template file exists for the specified format.
38
33
  # If one doesn't exist then the style would fall back to an
39
34
  # 'anonymous' template.
40
- def template?(format = :html)
41
- !(inline_template(format) || file_template(format)).nil?
35
+ def template?(format = :html, renderer = default_renderer)
36
+ !(inline_template(format) || file_template(format, renderer)).nil?
42
37
  end
43
38
 
44
39
  alias_method :path, :template
45
40
 
46
- def local_template(format)
47
- template_path = nil
48
- Spontaneous::Site.paths(:templates).each do |template_root|
49
- template_path = try_template_paths.detect do |path|
50
- Spontaneous::Output.template_exists?(template_root, path, format)
51
- end
52
- return (template_root / template_path) if template_path
53
- end
54
- nil
41
+ def local_template(format, renderer)
42
+ template_path = try_template_paths.map { |path|
43
+ renderer.template_location(path, format)
44
+ }.detect { |path| !path.nil? }
55
45
  end
56
46
 
57
- def supertype_template(format)
58
- template = try_supertype_styles.each { |style|
59
- template = style.template(format)
47
+ def supertype_template(format, renderer)
48
+ template = try_supertype_styles(renderer).each { |style|
49
+ template = style.template(format, renderer)
60
50
  return template unless template.nil?
61
51
  }
62
52
  nil
63
53
  end
64
54
 
65
- def try_supertype_styles
66
- class_ancestors(owner).take_while { |a| a and a < Spontaneous::Content }.
55
+ def try_supertype_styles(renderer)
56
+ class_ancestors(owner).take_while { |a| a and a < owner.model }.
67
57
  map { |s| supertype_style_class.new(s, prototype) }
68
58
  end
69
59
 
@@ -106,8 +96,13 @@ module Spontaneous
106
96
  end
107
97
 
108
98
  def owner_directory_names
109
- classes = [owner].concat(owner.ancestors.take_while { |klass| klass < owner.content_model::Page or klass < owner.content_model::Piece })
110
- classes.map { |klass| self.class.to_directory_name(klass) }
99
+ classes = [owner].concat(owner.ancestors.take_while { |klass| klass < owner.model::Page or klass < owner.model::Piece })
100
+ classes.map { |klass| to_directory_name(klass) }
101
+ end
102
+
103
+ def to_directory_name(klass)
104
+ return nil if klass.name.blank?
105
+ klass.name.demodulize.underscore
111
106
  end
112
107
 
113
108
  def owner_directory_paths(basename)
@@ -126,6 +121,10 @@ module Spontaneous
126
121
  other.class == self.class && other.prototype == self.prototype && other.owner == self.owner
127
122
  end
128
123
 
124
+ def default_renderer
125
+ Spontaneous::Output.default_renderer
126
+ end
127
+
129
128
  class Default < Style
130
129
  def name
131
130
  "<default>"
@@ -145,7 +144,7 @@ module Spontaneous
145
144
  @template_code = template_code
146
145
  end
147
146
 
148
- def template(format = :html)
147
+ def template(format = :html, renderer = Spontaneous::Output.default_renderer)
149
148
  Proc.new { @template_code }
150
149
  end
151
150
 
@@ -167,13 +166,13 @@ module Spontaneous
167
166
  @instance = instance
168
167
  end
169
168
 
170
- def template(format = :html)
169
+ def template(format = :html, renderer = Spontaneous::Output.default_renderer)
171
170
  target_is_content = @instance.target.respond_to?(:resolve_style)
172
171
  if (style = @instance.resolve_style(@instance.style_sid))
173
- return style.template(format) if !target_is_content || style.template?(format)
172
+ return style.template(format, renderer) if !target_is_content || style.template?(format, renderer)
174
173
  end
175
174
  style = @instance.target.resolve_style(@instance.style_sid)
176
- style.template(format)
175
+ style.template(format, renderer)
177
176
  end
178
177
  end
179
178
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Spontaneous
4
- VERSION = "0.2.0.beta4"
4
+ VERSION = "0.2.0.beta5"
5
5
  GEM = false
6
6
  end
data/spontaneous.gemspec CHANGED
@@ -26,35 +26,36 @@ Gem::Specification.new do |s|
26
26
  # s.signing_key = '/Volumes/Keys/rubygems-garry-magnetised-net-private_key.pem'
27
27
  # s.cert_chain = ['gem-public_cert.pem']
28
28
 
29
- s.add_dependency('activesupport', ['~> 4.0.0'])
30
- s.add_dependency('coffee-script', ['~> 2.2.0'])
31
- s.add_dependency('bcrypt-ruby', ['~> 3.0.1'])
32
- s.add_dependency('bundler', ['> 1.0.15'])
33
- s.add_dependency('cutaneous', ['~> 0.1.6'])
29
+ s.add_dependency('activesupport', ['~> 4.0'])
30
+ s.add_dependency('coffee-script', ['~> 2.2'])
31
+ s.add_dependency('bcrypt-ruby', ['~> 3.0'])
32
+ s.add_dependency('bundler', ['> 1.0'])
33
+ s.add_dependency('cutaneous', ['~> 0.2'])
34
34
  s.add_dependency('erubis', ['~> 2.6'])
35
- s.add_dependency('fog', ['~> 1.6.0'])
36
- s.add_dependency('foreman', ['~> 0.60.2'])
37
- s.add_dependency('kramdown', ['~> 0.14.0'])
38
- s.add_dependency('launchy', ['~> 2.1.2'])
39
- s.add_dependency('nokogiri', ['~> 1.5.0'])
35
+ s.add_dependency('fog', ['~> 1.17'])
36
+ s.add_dependency('foreman', ['~> 0.60'])
37
+ s.add_dependency('kramdown', ['~> 0.14'])
38
+ s.add_dependency('launchy', ['~> 2.1'])
39
+ s.add_dependency('moneta', ['~> 0.7'])
40
+ s.add_dependency('nokogiri', ['~> 1.5'])
40
41
  s.add_dependency('posix-spawn', ['~> 0.3.6'])
41
42
  s.add_dependency('public_suffix', ['~> 1.0'])
42
- s.add_dependency('rack', ['~> 1.5.0'])
43
- s.add_dependency('rake', ['~> 0.9.2'])
44
- s.add_dependency('sass', ['~> 3.2.10'])
45
- s.add_dependency('sequel', ['~> 3.43.0'])
43
+ s.add_dependency('rack', ['~> 1.5'])
44
+ s.add_dependency('rake', ['~> 0.9'])
45
+ s.add_dependency('sass', ['~> 3.2'])
46
+ s.add_dependency('sequel', ['~> 4.8'])
46
47
  s.add_dependency('simultaneous', ['~> 0.4.2'])
47
- s.add_dependency('sinatra', ['~> 1.3.4'])
48
- s.add_dependency('skeptick', ['~> 0.1.0'])
49
- s.add_dependency('sprockets', ['~> 2.9.0'])
48
+ s.add_dependency('sinatra', ['~> 1.3'])
49
+ s.add_dependency('skeptick', ['~> 0.1'])
50
+ s.add_dependency('sprockets', ['~> 2.9'])
50
51
  s.add_dependency('stringex', ['= 1.3'])
51
52
  s.add_dependency('thin', ['~> 1.2'])
52
- s.add_dependency('thor', ['~> 0.16.0'])
53
- s.add_dependency('uglifier', ['~> 1.3.0'])
53
+ s.add_dependency('thor', ['~> 0.16'])
54
+ s.add_dependency('uglifier', ['~> 1.3'])
54
55
  s.add_dependency('xapian-fu', ['~> 1.5'])
55
- s.add_dependency('yajl-ruby', ['~> 1.1.0'])
56
+ s.add_dependency('yajl-ruby', ['~> 1.1'])
56
57
 
57
- s.add_development_dependency('minitest', ['~> 4.6.0'])
58
+ s.add_development_dependency('minitest', ['~> 4.7.0'])
58
59
  s.add_development_dependency('minitest-colorize', ['~> 0.0.5'])
59
60
  s.add_development_dependency('mocha', ['~> 0.13.2'])
60
61
  s.add_development_dependency('rack-test', ['~> 0.5'])
@@ -1 +1 @@
1
- #{ page.path }.html
1
+ ${ page.path }.html
@@ -1 +1 @@
1
- #{ page.path }.pdf
1
+ ${ page.path }.pdf
@@ -1 +1 @@
1
- #{ page.path }.rss
1
+ ${ page.path }.rss
@@ -1,4 +1,4 @@
1
1
 
2
- Site.index :fast do
2
+ Spontaneous::Site.instance.index :fast do
3
3
  include_types "PageClass1", PageClass2, :PageClass3
4
4
  end
@@ -18,12 +18,14 @@
18
18
  :title: Title
19
19
  :comment: ""
20
20
  :writable: true
21
+ :list: true
21
22
  - :name: location
22
23
  :schema_id: <%= @fp[:location].schema_id.to_s %>
23
24
  :type: Spontaneous.Field.String
24
25
  :title: Where
25
26
  :comment: Fill in the address
26
27
  :writable: true
28
+ :list: true
27
29
  - :name: date
28
30
  :schema_id: <%= @fp[:date].schema_id.to_s %>
29
31
  :type: Spontaneous.Field.Date
@@ -31,19 +33,28 @@
31
33
  :comment: ""
32
34
  :writable: true
33
35
  :date_format: "%A, %-d %B, %Y"
36
+ :list: true
34
37
  - :name: image
35
38
  :schema_id: <%= @fp[:image].schema_id.to_s %>
36
39
  :type: Spontaneous.Field.Image
37
40
  :title: Image
38
41
  :comment: ""
39
42
  :writable: true
43
+ :list: true
44
+ - :name: another
45
+ :schema_id: <%= @fp[:another].schema_id.to_s %>
46
+ :type: Spontaneous.Field.String
47
+ :title: Another
48
+ :comment: ""
49
+ :writable: true
50
+ :list: false
40
51
  :boxes:
41
52
  - :name: things
42
53
  :id: <%= SerialisedPiece.boxes[:things].schema_id.to_s %>
43
54
  :title: My Things
44
55
  :writable: true
45
56
  :allowed_types:
46
- - SerialisedPage
57
+ - :type: SerialisedPage
47
58
  :fields:
48
59
  - :name: title
49
60
  :schema_id: <%= SerialisedPiece.boxes[:things].field_prototypes[:title].schema_id.to_s %>
@@ -51,4 +62,5 @@
51
62
  :title: Title
52
63
  :comment: ""
53
64
  :writable: true
65
+ :list: true
54
66
  :source: <%= source %>
@@ -76,6 +76,11 @@
76
76
  :src: ""
77
77
  :__ui__:
78
78
  :src: ""
79
+ - :unprocessed_value: ""
80
+ :name: another
81
+ :processed_value: ""
82
+ :version: 0
83
+ :id: <%= SerialisedPiece.field_prototypes[:another].schema_id.to_s %>
79
84
 
80
85
  :style: <%= @freezing_style.to_s %>
81
86
  :hidden: true
@@ -168,6 +173,11 @@
168
173
  :src: ""
169
174
  :__ui__:
170
175
  :src: ""
176
+ - :unprocessed_value: ""
177
+ :name: another
178
+ :processed_value: ""
179
+ :version: 0
180
+ :id: <%= SerialisedPiece.field_prototypes[:another].schema_id.to_s %>
171
181
 
172
182
  :style: <%= @boiling_style.to_s %>
173
183
  :hidden: false
@@ -18,18 +18,9 @@ describe "Application" do
18
18
  end
19
19
 
20
20
  finish do
21
- Object.send :remove_const, :Page
22
- Object.send :remove_const, :Piece
23
- Object.send :remove_const, :Project
24
- Object.send :remove_const, :ProjectImage
25
- Object.send :remove_const, :ProjectsPage
26
- Object.send :remove_const, :Text
27
- Object.send :remove_const, :HomePage
28
- Object.send :remove_const, :InfoPage
29
- Object.send :remove_const, :ClientProject
30
- Object.send :remove_const, :ClientProjects
31
- Object.send :remove_const, :InlineImage
32
-
21
+ [:Page, :Piece, :Project, :ProjectImage, :ProjectsPage, :Text, :HomePage, :InfoPage, :ClientProject, :ClientProjects, :InlineImage].each do |klass|
22
+ Object.send :remove_const, klass rescue nil
23
+ end
33
24
  teardown_site(true)
34
25
  end
35
26
 
@@ -48,22 +39,27 @@ describe "Application" do
48
39
 
49
40
  describe "Site" do
50
41
  before do
51
- Spontaneous.init(:root => site_root, :mode => :back, :environment => :development)
42
+ @site = Spontaneous.init(:root => site_root, :mode => :back, :environment => :development)
52
43
  end
44
+
45
+ it "returns an instance of the site from Spontaneous.init" do
46
+ @site.must_be_instance_of Spontaneous::Site
47
+ end
48
+
53
49
  it "have the same config as Spontaneous" do
54
- Site.config.must_equal Spontaneous.config
50
+ @site.config.must_equal Spontaneous.config
55
51
  end
56
52
 
57
53
  it "enable setting config vars on Site" do
58
- Site.config.butter = "yummy"
59
- Site.config.butter.must_equal "yummy"
54
+ @site.config.butter = "yummy"
55
+ @site.config.butter.must_equal "yummy"
60
56
  end
61
57
  end
62
58
 
63
59
  describe "back, development" do
64
60
 
65
61
  before do
66
- Spontaneous.init(:root => site_root, :mode => :back, :environment => :development)
62
+ @site = Spontaneous.init(:root => site_root, :mode => :back, :environment => :development)
67
63
  Sequel::Migrator.apply(Spontaneous.database, 'db/migrations')
68
64
  end
69
65
 
@@ -88,8 +84,8 @@ describe "Application" do
88
84
  end
89
85
 
90
86
  it "have correct db settings" do
91
- Site.config.db[:adapter].must_equal "postgres"
92
- Site.config.db[:database].must_equal "spontaneous2_test"
87
+ @site.config.db[:adapter].must_equal "postgres"
88
+ @site.config.db[:database].must_equal "spontaneous2_test"
93
89
  # Site.config.db[:user].must_equal "root"
94
90
  # Site.config.db[:password].should be_nil
95
91
  # Site.config.db[:host].must_equal "localhost"
@@ -139,7 +135,7 @@ describe "Application" do
139
135
 
140
136
  describe "back, production" do
141
137
  before do
142
- Spontaneous.init(:root => site_root, :mode => :back, :environment => :production)
138
+ @site = Spontaneous.init(:root => site_root, :mode => :back, :environment => :production)
143
139
  end
144
140
 
145
141
  it "have the right mode setting" do
@@ -156,10 +152,10 @@ describe "Application" do
156
152
  end
157
153
 
158
154
  it "have correct db settings" do
159
- Site.config.db[:adapter].must_equal "postgres"
160
- Site.config.db[:database].must_equal "spontaneous_example_production"
161
- Site.config.db[:user].must_equal "spontaneous_prod"
162
- Site.config.db[:password].must_equal "Passw0rd"
155
+ @site.config.db[:adapter].must_equal "postgres"
156
+ @site.config.db[:database].must_equal "spontaneous_example_production"
157
+ @site.config.db[:user].must_equal "spontaneous_prod"
158
+ @site.config.db[:password].must_equal "Passw0rd"
163
159
  # Site.config.db[:host].must_equal "localhost"
164
160
  end
165
161
 
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+
2
2
 
3
3
  require File.expand_path('../../test_helper', __FILE__)
4
4
 
@@ -72,7 +72,7 @@ describe "Back" do
72
72
  end
73
73
 
74
74
  class ::HomePage < Page
75
- field :introduction, :text
75
+ field :introduction, :richtext
76
76
  box :projects do
77
77
  allow Project
78
78
  end
@@ -126,12 +126,12 @@ describe "Back" do
126
126
  Object.send(:remove_const, klass) rescue nil
127
127
  end
128
128
  Spontaneous::Permissions::User.delete
129
- Content.delete
129
+ Content.delete if defined?(Content)
130
130
  teardown_site(true)
131
131
  end
132
132
 
133
133
  def app
134
- Spontaneous::Rack::Back.application
134
+ @app ||= Spontaneous::Rack::Back.application(site)
135
135
  end
136
136
 
137
137
  let(:home) { Content[home_id] }
@@ -193,14 +193,14 @@ describe "Back" do
193
193
  auth_get '/@spontaneous/map'
194
194
  assert last_response.ok?
195
195
  last_response.content_type.must_equal "application/json;charset=utf-8"
196
- assert_equal S::Site.map.to_json, last_response.body
196
+ assert_equal site.map.to_json, last_response.body
197
197
  end
198
198
 
199
199
  it "return a site map for any page id" do
200
200
  auth_get "/@spontaneous/map/#{home.id}"
201
201
  assert last_response.ok?
202
202
  last_response.content_type.must_equal "application/json;charset=utf-8"
203
- assert_equal S::Site.map(home.id).to_json, last_response.body
203
+ assert_equal site.map(home.id).to_json, last_response.body
204
204
  end
205
205
 
206
206
  it "return a site map for any url" do
@@ -208,7 +208,7 @@ describe "Back" do
208
208
  auth_get "/@spontaneous/map/path#{project1.path}"
209
209
  assert last_response.ok?
210
210
  last_response.content_type.must_equal "application/json;charset=utf-8"
211
- assert_equal S::Site.map(project1.id).to_json, last_response.body
211
+ assert_equal site.map(project1.id).to_json, last_response.body
212
212
  end
213
213
 
214
214
  it "return 404 when asked for map of non-existant page" do
@@ -220,7 +220,7 @@ describe "Back" do
220
220
 
221
221
  it "return the correct Last-Modified header for the site map" do
222
222
  now = Time.at(Time.now.to_i + 10000)
223
- Spontaneous::Site.stubs(:modified_at).returns(now)
223
+ site.stubs(:modified_at).returns(now)
224
224
  auth_get '/@spontaneous/map'
225
225
  Time.httpdate(last_response.headers["Last-Modified"]).must_equal now
226
226
  auth_get "/@spontaneous/map/path#{project1.path}"
@@ -230,7 +230,7 @@ describe "Back" do
230
230
  it "reply with a 304 Not Modified if the site hasn't been updated since last request" do
231
231
  datestring = "Sat, 03 Mar 2012 00:49:44 GMT"
232
232
  now = Time.httpdate(datestring)
233
- Spontaneous::Site.stubs(:modified_at).returns(now)
233
+ site.stubs(:modified_at).returns(now)
234
234
  auth_get "/@spontaneous/map/#{home.id}", {}, {"HTTP_IF_MODIFIED_SINCE" => datestring}
235
235
  last_response.status.must_equal 304
236
236
  auth_get "/@spontaneous/map", {}, {"HTTP_IF_MODIFIED_SINCE" => datestring}
@@ -243,7 +243,7 @@ describe "Back" do
243
243
  datestring1 = "Sat, 03 Mar 2012 00:49:44 GMT"
244
244
  datestring2 = "Sat, 03 Mar 2012 01:49:44 GMT"
245
245
  now = Time.httpdate(datestring2)
246
- Spontaneous::Site.stubs(:modified_at).returns(now)
246
+ site.stubs(:modified_at).returns(now)
247
247
  auth_get "/@spontaneous/map/#{home.id}", {}, {"HTTP_IF_MODIFIED_SINCE" => datestring1}
248
248
  last_response.status.must_equal 200
249
249
  auth_get "/@spontaneous/map/path#{project1.path}", {}, {"HTTP_IF_MODIFIED_SINCE" => datestring1}
@@ -332,14 +332,14 @@ describe "Back" do
332
332
 
333
333
  describe "/site" do
334
334
  before do
335
- @root_class = S::Site.root.class
335
+ @root_class = site.home.class
336
336
  end
337
337
 
338
338
  it "return json for home page" do
339
339
  auth_get '/@spontaneous/site/home'
340
340
  assert last_response.ok?
341
341
  last_response.content_type.must_equal "application/json;charset=utf-8"
342
- assert_equal S::JSON.encode(S::Site.root.export), last_response.body
342
+ assert_equal S::JSON.encode(site.home.export), last_response.body
343
343
  end
344
344
 
345
345
  it "return the typelist as part of the site metadata" do
@@ -347,7 +347,7 @@ describe "Back" do
347
347
  assert last_response.ok?, "Should have recieved a 200 OK but got a #{ last_response.status }"
348
348
  last_response.content_type.must_equal "application/json;charset=utf-8"
349
349
  result = Spot::JSON.parse(last_response.body)
350
- result[:types].stringify_keys.must_equal S::Site.schema.export(user)
350
+ result[:types].stringify_keys.must_equal site.schema.export(user)
351
351
  end
352
352
 
353
353
  it "apply the current user's permissions to the exported schema" do
@@ -387,14 +387,14 @@ describe "Back" do
387
387
  end
388
388
 
389
389
  it "return the configured list of service URLs in the metadata" do
390
- S::Site.config.stubs(:services).returns([
390
+ site.config.stubs(:services).returns([
391
391
  {:title => "Google Analytics", :url => "http://google.com/analytics"},
392
392
  {:title => "Facebook", :url => "http://facebook.com/spontaneous"}
393
393
  ])
394
394
  auth_get "/@spontaneous/site"
395
395
  assert last_response.ok?, "Should have recieved a 200 OK but got a #{ last_response.status }"
396
396
  result = Spot::JSON.parse(last_response.body)
397
- result[:services].must_equal S::Site.config.services
397
+ result[:services].must_equal site.config.services
398
398
  end
399
399
  it "provides a format value for date fields" do
400
400
  field = Job.field :date, :date, :format => "%Y %d %a"
@@ -427,8 +427,8 @@ describe "Back" do
427
427
  it "creates a homepage of the specified type" do
428
428
  auth_post "/@spontaneous/site/home", 'type' => @root_class.schema_id
429
429
  assert last_response.ok?
430
- S::Site.root.must_be_instance_of(@root_class)
431
- S::Site.root.title.value.must_match /Home/
430
+ site.home.must_be_instance_of(@root_class)
431
+ site.home.title.value.must_match /Home/
432
432
  end
433
433
 
434
434
  it "only creates one homepage" do
@@ -600,8 +600,7 @@ describe "Back" do
600
600
 
601
601
  it "replace values of fields immediately when required" do
602
602
  image1.image.processed_value.must_equal ""
603
- auth_put("@spontaneous/file/#{image1.id}",
604
- "file" => @upload, "field" => image1.image.schema_id.to_s )
603
+ auth_put("@spontaneous/file/#{image1.id}", "file" => @upload, "field" => image1.image.schema_id.to_s )
605
604
  assert last_response.ok?
606
605
  last_response.content_type.must_equal "application/json;charset=utf-8"
607
606
  image = Content[image1.id]
@@ -751,7 +750,7 @@ describe "Back" do
751
750
  end
752
751
 
753
752
  it "return json for individual pages" do
754
- page = S::Site.root.children.first
753
+ page = site.home.children.first
755
754
  auth_get "/@spontaneous/page/#{page.id}"
756
755
  assert last_response.ok?
757
756
  last_response.content_type.must_equal "application/json;charset=utf-8"
@@ -838,17 +837,17 @@ describe "Back" do
838
837
  auth_get "/@spontaneous/changes"
839
838
  assert last_response.ok?, "Expected 200 recieved #{last_response.status}"
840
839
  last_response.content_type.must_equal "application/json;charset=utf-8"
841
- last_response.body.must_equal S::Change.serialise_http
840
+ last_response.body.must_equal S::Change.serialise_http(site)
842
841
  end
843
842
 
844
843
  it "be able to start a publish with a set of change sets" do
845
- S::Site.expects(:publish_pages).with([project1.id])
844
+ site.expects(:publish_pages).with([project1.id])
846
845
  auth_post "/@spontaneous/changes", :page_ids => [project1.id]
847
846
  assert last_response.ok?, "Expected 200 recieved #{last_response.status}"
848
847
  end
849
848
 
850
849
  it "not launch publish if list of changes is empty" do
851
- S::Site.expects(:publish_pages).with().never
850
+ site.expects(:publish_pages).with().never
852
851
  auth_post "/@spontaneous/changes", :change_set_ids => ""
853
852
  assert last_response.status == 400, "Expected 400, recieved #{last_response.status}"
854
853
 
@@ -857,7 +856,7 @@ describe "Back" do
857
856
  end
858
857
 
859
858
  it "recognise when the list of changes is complete" do
860
- S::Site.expects(:publish_pages).with([home.id, project1.id])
859
+ site.expects(:publish_pages).with([home.id, project1.id])
861
860
  auth_post "/@spontaneous/changes", :page_ids => [home.id, project1.id]
862
861
  assert last_response.ok?, "Expected 200 recieved #{last_response.status}"
863
862
  end
@@ -1017,7 +1016,7 @@ describe "Back" do
1017
1016
 
1018
1017
  describe "/" do
1019
1018
  before do
1020
- @renderer = Spontaneous::Output.preview_renderer
1019
+ @renderer = Spontaneous::Output.preview_renderer(site)
1021
1020
  end
1022
1021
 
1023
1022
  def get_preview(path, params = {}, env = {})
@@ -1105,8 +1104,8 @@ describe "Back" do
1105
1104
 
1106
1105
  it "accept POST requests" do
1107
1106
  Project.expects(:posted!).with(project1)
1108
- Project.request :post do
1109
- Project.posted!(page)
1107
+ Project.controller do
1108
+ post { Project.posted!(page) }
1110
1109
  end
1111
1110
  post "/project1"
1112
1111
  end