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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/Gemfile +11 -6
- data/Readme.markdown +136 -69
- data/application/css/core.css.scss +27 -7
- data/application/css/editing.css.scss +4 -26
- data/application/css/schema_error.css.scss +22 -0
- data/application/js/content.js +11 -3
- data/application/js/edit_panel.js +1 -4
- data/application/js/field/file.js +17 -0
- data/application/js/field/image.js +30 -21
- data/application/js/field/string.js +4 -1
- data/application/js/field_preview.js +21 -16
- data/application/js/publish.js +6 -6
- data/application/js/types.js +5 -13
- data/application/js/views.js +2 -2
- data/application/js/views/box_view.js +3 -2
- data/application/js/views/page_piece_view.js +1 -1
- data/application/js/views/piece_view.js +1 -1
- data/application/views/schema_modification_error.html.erb +13 -3
- data/db/migrations/20131104101935_site_must_publish_all.rb +14 -0
- data/lib/spontaneous.rb +0 -1
- data/lib/spontaneous/box_style.rb +15 -9
- data/lib/spontaneous/capistrano/deploy.rb +13 -1
- data/lib/spontaneous/change.rb +11 -13
- data/lib/spontaneous/cli.rb +5 -2
- data/lib/spontaneous/cli/assets.rb +7 -1
- data/lib/spontaneous/cli/console.rb +7 -1
- data/lib/spontaneous/cli/content.rb +35 -0
- data/lib/spontaneous/cli/fields.rb +3 -2
- data/lib/spontaneous/cli/generate.rb +5 -2
- data/lib/spontaneous/cli/server.rb +12 -8
- data/lib/spontaneous/cli/site.rb +12 -12
- data/lib/spontaneous/cli/user.rb +28 -14
- data/lib/spontaneous/collections/box_set.rb +4 -4
- data/lib/spontaneous/collections/field_set.rb +4 -4
- data/lib/spontaneous/collections/prototype_set.rb +12 -4
- data/lib/spontaneous/data_mapper.rb +11 -7
- data/lib/spontaneous/data_mapper/content_model.rb +8 -0
- data/lib/spontaneous/data_mapper/content_model/associations.rb +1 -1
- data/lib/spontaneous/data_mapper/dataset.rb +14 -2
- data/lib/spontaneous/data_mapper/scope.rb +33 -13
- data/lib/spontaneous/facet.rb +4 -0
- data/lib/spontaneous/field.rb +12 -12
- data/lib/spontaneous/field/base.rb +27 -22
- data/lib/spontaneous/field/boolean.rb +4 -4
- data/lib/spontaneous/field/date.rb +2 -2
- data/lib/spontaneous/field/file.rb +24 -18
- data/lib/spontaneous/field/html.rb +1 -1
- data/lib/spontaneous/field/image.rb +6 -19
- data/lib/spontaneous/field/location.rb +1 -1
- data/lib/spontaneous/field/long_string.rb +3 -3
- data/lib/spontaneous/field/markdown.rb +3 -3
- data/lib/spontaneous/field/select.rb +2 -2
- data/lib/spontaneous/field/string.rb +2 -2
- data/lib/spontaneous/field/tags.rb +2 -2
- data/lib/spontaneous/field/update.rb +21 -20
- data/lib/spontaneous/field/webvideo.rb +6 -6
- data/lib/spontaneous/field/webvideo/fallback.rb +2 -2
- data/lib/spontaneous/field/webvideo/vimeo.rb +7 -7
- data/lib/spontaneous/generators/site.rb +2 -2
- data/lib/spontaneous/generators/site/Gemfile.tt +5 -1
- data/lib/spontaneous/layout.rb +2 -2
- data/lib/spontaneous/media.rb +1 -0
- data/lib/spontaneous/media/file.rb +6 -5
- data/lib/spontaneous/media/image/attributes.rb +4 -0
- data/lib/spontaneous/media/image/renderable.rb +4 -4
- data/lib/spontaneous/media/store.rb +22 -0
- data/lib/spontaneous/{storage → media/store}/backend.rb +1 -1
- data/lib/spontaneous/{storage → media/store}/cloud.rb +1 -1
- data/lib/spontaneous/{storage → media/store}/local.rb +1 -1
- data/lib/spontaneous/media/temp_file.rb +1 -1
- data/lib/spontaneous/model.rb +10 -7
- data/lib/spontaneous/model/action.rb +7 -0
- data/lib/spontaneous/model/action/clean.rb +87 -0
- data/lib/spontaneous/model/box/allowed_types.rb +15 -1
- data/lib/spontaneous/model/core.rb +10 -0
- data/lib/spontaneous/model/core/aliases.rb +1 -1
- data/lib/spontaneous/model/core/content_groups.rb +1 -1
- data/lib/spontaneous/model/core/fields.rb +1 -1
- data/lib/spontaneous/model/core/modifications.rb +2 -2
- data/lib/spontaneous/model/core/page_search.rb +4 -0
- data/lib/spontaneous/model/core/publishing.rb +4 -17
- data/lib/spontaneous/model/core/render.rb +4 -4
- data/lib/spontaneous/model/core/styles.rb +2 -2
- data/lib/spontaneous/model/core/visibility.rb +6 -2
- data/lib/spontaneous/model/page.rb +6 -2
- data/lib/spontaneous/model/page/controllers.rb +55 -17
- data/lib/spontaneous/model/page/formats.rb +12 -7
- data/lib/spontaneous/model/page/layouts.rb +2 -2
- data/lib/spontaneous/model/page/locks.rb +4 -1
- data/lib/spontaneous/model/page/page_tree.rb +40 -6
- data/lib/spontaneous/output.rb +14 -52
- data/lib/spontaneous/output/context.rb +11 -39
- data/lib/spontaneous/output/context/navigation.rb +31 -0
- data/lib/spontaneous/output/format.rb +15 -19
- data/lib/spontaneous/output/renderable.rb +99 -0
- data/lib/spontaneous/output/store.rb +24 -0
- data/lib/spontaneous/output/store/backend.rb +52 -0
- data/lib/spontaneous/output/store/file.rb +77 -0
- data/lib/spontaneous/output/store/moneta.rb +117 -0
- data/lib/spontaneous/output/store/revision.rb +34 -0
- data/lib/spontaneous/output/store/store.rb +15 -0
- data/lib/spontaneous/output/store/transaction.rb +44 -0
- data/lib/spontaneous/output/template/engine.rb +17 -7
- data/lib/spontaneous/output/template/renderer.rb +66 -40
- data/lib/spontaneous/page_lock.rb +5 -7
- data/lib/spontaneous/page_piece.rb +2 -2
- data/lib/spontaneous/permissions/user.rb +14 -7
- data/lib/spontaneous/plugins/application/features.rb +8 -4
- data/lib/spontaneous/plugins/application/state.rb +12 -6
- data/lib/spontaneous/prototypes/box_prototype.rb +9 -10
- data/lib/spontaneous/prototypes/field_prototype.rb +66 -15
- data/lib/spontaneous/publishing/immediate.rb +30 -26
- data/lib/spontaneous/rack.rb +12 -7
- data/lib/spontaneous/rack/back.rb +43 -37
- data/lib/spontaneous/rack/back/base.rb +4 -4
- data/lib/spontaneous/rack/back/changes.rb +2 -2
- data/lib/spontaneous/rack/back/file.rb +16 -24
- data/lib/spontaneous/rack/back/map.rb +5 -5
- data/lib/spontaneous/rack/back/preview.rb +3 -4
- data/lib/spontaneous/rack/back/schema.rb +1 -1
- data/lib/spontaneous/rack/back/site.rb +6 -7
- data/lib/spontaneous/rack/front.rb +19 -16
- data/lib/spontaneous/rack/middleware/authenticate.rb +3 -3
- data/lib/spontaneous/rack/middleware/reloader.rb +3 -2
- data/lib/spontaneous/rack/middleware/scope.rb +25 -19
- data/lib/spontaneous/rack/page_controller.rb +164 -13
- data/lib/spontaneous/rack/public.rb +23 -62
- data/lib/spontaneous/rack/static.rb +2 -3
- data/lib/spontaneous/schema.rb +27 -8
- data/lib/spontaneous/schema/schema_modification.rb +9 -1
- data/lib/spontaneous/schema/uid.rb +2 -2
- data/lib/spontaneous/schema/uid_map.rb +3 -2
- data/lib/spontaneous/search/database.rb +2 -2
- data/lib/spontaneous/search/field.rb +5 -3
- data/lib/spontaneous/search/index.rb +12 -7
- data/lib/spontaneous/search/results.rb +5 -3
- data/lib/spontaneous/server.rb +2 -2
- data/lib/spontaneous/site.rb +10 -3
- data/lib/spontaneous/site/features.rb +26 -6
- data/lib/spontaneous/site/helpers.rb +9 -12
- data/lib/spontaneous/site/level.rb +7 -9
- data/lib/spontaneous/site/map.rb +9 -11
- data/lib/spontaneous/site/paths.rb +5 -5
- data/lib/spontaneous/site/publishing.rb +83 -80
- data/lib/spontaneous/site/schema.rb +1 -7
- data/lib/spontaneous/site/search.rb +8 -18
- data/lib/spontaneous/site/selectors.rb +60 -54
- data/lib/spontaneous/site/state.rb +36 -30
- data/lib/spontaneous/site/storage.rb +10 -16
- data/lib/spontaneous/state.rb +8 -0
- data/lib/spontaneous/style.rb +32 -33
- data/lib/spontaneous/version.rb +1 -1
- data/spontaneous.gemspec +22 -21
- data/test/fixtures/public/templates/layouts/default.html.cut +1 -1
- data/test/fixtures/public/templates/layouts/default.pdf.cut +1 -1
- data/test/fixtures/public/templates/layouts/default.rss.cut +1 -1
- data/test/fixtures/search/config/indexes.rb +1 -1
- data/test/fixtures/serialisation/class_hash.yaml.erb +13 -1
- data/test/fixtures/serialisation/root_hash.yaml.erb +10 -0
- data/test/functional/test_application.rb +20 -24
- data/test/functional/test_back.rb +26 -27
- data/test/functional/test_cli.rb +146 -0
- data/test/functional/test_front.rb +287 -216
- data/test/functional/test_user_manager.rb +1 -1
- data/test/test_helper.rb +15 -11
- data/test/unit/test_alias.rb +32 -25
- data/test/unit/test_asset_bundler.rb +1 -1
- data/test/unit/test_assets.rb +34 -33
- data/test/unit/test_authentication.rb +1 -1
- data/test/unit/test_boxes.rb +16 -2
- data/test/unit/test_changesets.rb +23 -11
- data/test/unit/test_content.rb +15 -0
- data/test/unit/test_context.rb +139 -0
- data/test/unit/test_controllers.rb +374 -0
- data/test/{experimental → unit}/test_crypt.rb +0 -0
- data/test/unit/test_datamapper.rb +260 -237
- data/test/unit/test_datamapper_content.rb +42 -12
- data/test/{experimental → unit}/test_features.rb +85 -3
- data/test/unit/test_fields.rb +117 -42
- data/test/unit/test_formats.rb +11 -1
- data/test/unit/test_generators.rb +2 -2
- data/test/unit/test_helpers.rb +7 -8
- data/test/unit/test_images.rb +39 -2
- data/test/unit/test_layouts.rb +14 -12
- data/test/unit/test_media.rb +32 -23
- data/test/unit/test_output_store.rb +342 -0
- data/test/unit/test_page.rb +8 -1
- data/test/unit/test_permissions.rb +11 -7
- data/test/unit/test_plugins.rb +3 -3
- data/test/unit/test_prototype_set.rb +8 -1
- data/test/unit/test_publishing.rb +67 -54
- data/test/unit/test_render.rb +91 -38
- data/test/unit/test_revisions.rb +4 -4
- data/test/unit/test_schema.rb +109 -84
- data/test/unit/test_search.rb +42 -42
- data/test/unit/test_serialisation.rb +3 -2
- data/test/unit/test_site.rb +39 -27
- data/test/unit/test_storage.rb +9 -6
- data/test/unit/test_styles.rb +25 -32
- data/test/unit/test_templates.rb +8 -4
- metadata +89 -54
- data/lib/spontaneous/model/page/request.rb +0 -105
- data/lib/spontaneous/storage.rb +0 -22
data/test/test_helper.rb
CHANGED
@@ -21,6 +21,10 @@ require 'logger'
|
|
21
21
|
|
22
22
|
Sequel.extension :migration
|
23
23
|
|
24
|
+
# http://sequel.jeremyevans.net/rdoc-plugins/index.html
|
25
|
+
# The scissors plugin adds class methods for update, delete, and destroy
|
26
|
+
Sequel::Model.plugin :scissors
|
27
|
+
|
24
28
|
# for future integration with travis
|
25
29
|
ENV["SPOT_ADAPTER"] ||= "postgres"
|
26
30
|
|
@@ -95,13 +99,13 @@ class MiniTest::Spec
|
|
95
99
|
|
96
100
|
def self.setup_site(root = nil, define_models = true)
|
97
101
|
root ||= Dir.mktmpdir
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
site = Spontaneous::Site.instantiate(root, :test, :back)
|
103
|
+
site.schema_loader_class = Spontaneous::Schema::TransientMap
|
104
|
+
site.logger.silent!
|
105
|
+
site.database = DB
|
106
|
+
site.background_mode = :immediate
|
103
107
|
unless Object.const_defined?(:Content)
|
104
|
-
content_class = Class.new(Spontaneous::Model(:content, DB,
|
108
|
+
content_class = Class.new(Spontaneous::Model!(:content, DB, site.schema))
|
105
109
|
Object.const_set :Content, content_class
|
106
110
|
if define_models
|
107
111
|
Object.const_set :Page, Class.new(::Content::Page)
|
@@ -109,10 +113,10 @@ class MiniTest::Spec
|
|
109
113
|
Object.const_set :Box, Class.new(::Content::Box)
|
110
114
|
end
|
111
115
|
end
|
112
|
-
|
116
|
+
site.model = ::Content
|
113
117
|
# Use the fast version of the password hashing algorithm
|
114
118
|
Spontaneous::Crypt.force_version(0)
|
115
|
-
|
119
|
+
site
|
116
120
|
end
|
117
121
|
|
118
122
|
def self.teardown_site(clear_disk = true, clear_const = true)
|
@@ -120,7 +124,7 @@ class MiniTest::Spec
|
|
120
124
|
FileUtils.rm_r(Spontaneous.instance.root) rescue nil
|
121
125
|
end
|
122
126
|
return unless clear_const
|
123
|
-
%w(Piece Page Box Content
|
127
|
+
%w(Piece Page Box Content).each do |klass|
|
124
128
|
Object.send :remove_const, klass if Object.const_defined?(klass)
|
125
129
|
end
|
126
130
|
Spontaneous.send :remove_const, :Content rescue nil
|
@@ -174,8 +178,8 @@ class MiniTest::Spec
|
|
174
178
|
self.class.teardown_site(clear_disk, clear_const)
|
175
179
|
end
|
176
180
|
|
177
|
-
def assert_correct_template(content, expected_path, format = :html)
|
178
|
-
assert_equal(expected_path, content.template(format))
|
181
|
+
def assert_correct_template(content, expected_path, renderer, format = :html)
|
182
|
+
assert_equal(expected_path, content.template(format, renderer))
|
179
183
|
end
|
180
184
|
|
181
185
|
def assert_file_exists(*path)
|
data/test/unit/test_alias.rb
CHANGED
@@ -9,8 +9,9 @@ describe "Alias" do
|
|
9
9
|
template_root = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures/templates/aliases"))
|
10
10
|
let(:template_root) { template_root }
|
11
11
|
site.paths.add(:templates, template_root)
|
12
|
-
renderer = S::Output::Template::Renderer.new(false)
|
13
|
-
|
12
|
+
renderer = S::Output::Template::Renderer.new(site, false)
|
13
|
+
let(:renderer) { renderer }
|
14
|
+
let(:site) { site }
|
14
15
|
|
15
16
|
Content.delete
|
16
17
|
|
@@ -125,6 +126,7 @@ describe "Alias" do
|
|
125
126
|
end
|
126
127
|
|
127
128
|
before do
|
129
|
+
@site = site
|
128
130
|
end
|
129
131
|
|
130
132
|
after do
|
@@ -183,11 +185,12 @@ describe "Alias" do
|
|
183
185
|
end
|
184
186
|
|
185
187
|
it "allow for selecting only content from within one box" do
|
186
|
-
|
187
|
-
|
188
|
+
container_proc = Proc.new { site['$thepage'].box1 }
|
189
|
+
::X = Class.new(::Piece) do
|
190
|
+
alias_of :A, :container => container_proc
|
188
191
|
end
|
189
|
-
|
190
|
-
alias_of :AA, :container =>
|
192
|
+
::XX = Class.new(::Piece) do
|
193
|
+
alias_of :AA, :container => container_proc
|
191
194
|
end
|
192
195
|
targets = lambda { |a, target|
|
193
196
|
[(a.targets), @page.box1.select { |p| target === p }].map { |a| Set.new(a) }
|
@@ -199,22 +202,24 @@ describe "Alias" do
|
|
199
202
|
end
|
200
203
|
|
201
204
|
it "allow for selecting only content from a range of boxes" do
|
202
|
-
|
203
|
-
|
205
|
+
container_proc = Proc.new { [site['$thepage'].box1, site['$thepage'].box2] }
|
206
|
+
::X = Class.new(::Piece) do
|
207
|
+
alias_of :A, :container => container_proc
|
204
208
|
end
|
205
|
-
|
206
|
-
alias_of :AA, :container =>
|
209
|
+
::XX = Class.new(::Piece) do
|
210
|
+
alias_of :AA, :container => container_proc
|
207
211
|
end
|
208
212
|
assert_same_content X.targets, @page.box1.select { |p| A === p } + @page.box2.select { |p| A === p }
|
209
213
|
assert_same_content XX.targets, @page.box1.select { |p| AA === p } + @page.box2.select { |p| AA === p }
|
210
214
|
end
|
211
215
|
|
212
216
|
it "allow for selecting only content from within one page" do
|
213
|
-
|
214
|
-
|
217
|
+
container_proc = Proc.new { site['$thepage'] }
|
218
|
+
::X = Class.new(::Piece) do
|
219
|
+
alias_of :A, :container => container_proc
|
215
220
|
end
|
216
|
-
|
217
|
-
alias_of :AA, :container =>
|
221
|
+
::XX = Class.new(::Piece) do
|
222
|
+
alias_of :AA, :container => container_proc
|
218
223
|
end
|
219
224
|
assert_same_content X.targets, @page.content.select { |p| A === p }
|
220
225
|
assert_same_content XX.targets, @page.content.select { |p| AA === p }
|
@@ -229,11 +234,13 @@ describe "Alias" do
|
|
229
234
|
page2.box2 << AA.new
|
230
235
|
}
|
231
236
|
page2.save.reload
|
232
|
-
|
233
|
-
|
237
|
+
container_proc = Proc.new { [site['$thepage'].box1, site['$thepage2']] }
|
238
|
+
::X = Class.new(::Piece) do
|
239
|
+
alias_of :A, :AA, :container => container_proc
|
234
240
|
end
|
235
|
-
|
236
|
-
|
241
|
+
container_proc = Proc.new { [site['$thepage'], site['$thepage2'].box2] }
|
242
|
+
::XX = Class.new(::Piece) do
|
243
|
+
alias_of :AA, :container => container_proc
|
237
244
|
end
|
238
245
|
assert_same_content X.targets(@page, @page.box1), @page.box1.contents + page2.content
|
239
246
|
assert_same_content XX.targets, @page.content.select { |p| AA === p } + page2.box2.select { |p| AA === p }
|
@@ -327,21 +334,21 @@ describe "Alias" do
|
|
327
334
|
end
|
328
335
|
|
329
336
|
it "have their own styles" do
|
330
|
-
assert_correct_template(@a_alias, template_root / 'a_alias/a_alias_style')
|
337
|
+
assert_correct_template(@a_alias, template_root / 'a_alias/a_alias_style', renderer)
|
331
338
|
end
|
332
339
|
|
333
340
|
it "present their target's styles as their own" do
|
334
341
|
@a_alias.style = :a_style
|
335
342
|
|
336
|
-
assert_correct_template(@a_alias, template_root / 'a/a_style')
|
343
|
+
assert_correct_template(@a_alias, template_root / 'a/a_style', renderer)
|
337
344
|
end
|
338
345
|
|
339
346
|
it "should use templates belonging to the alias class if they exist" do
|
340
|
-
assert_correct_template(@aa_alias, template_root / 'aa_alias')
|
347
|
+
assert_correct_template(@aa_alias, template_root / 'aa_alias', renderer)
|
341
348
|
end
|
342
349
|
|
343
350
|
it "should fallback to the targets default style if no alias template is present" do
|
344
|
-
assert_correct_template(@aaa_alias, aaa1.template)
|
351
|
+
assert_correct_template(@aaa_alias, aaa1.template, renderer)
|
345
352
|
end
|
346
353
|
|
347
354
|
# should "have an independent style setting"
|
@@ -410,7 +417,7 @@ describe "Alias" do
|
|
410
417
|
a = BBAlias.create(:target => bb)
|
411
418
|
aliases.box1 << a
|
412
419
|
aliases.save
|
413
|
-
|
420
|
+
site["/aliases/bb"].must_be_nil
|
414
421
|
end
|
415
422
|
|
416
423
|
it "have their target's path attribute if they alias to a page type" do
|
@@ -447,8 +454,8 @@ describe "Alias" do
|
|
447
454
|
a.save
|
448
455
|
a.reload
|
449
456
|
a.path.must_equal "/aliases/b"
|
450
|
-
|
451
|
-
|
457
|
+
site["/aliases/balias"].must_be_nil
|
458
|
+
site["/aliases/b"].must_equal a
|
452
459
|
end
|
453
460
|
|
454
461
|
it "update their path if their target's slug changes" do
|
data/test/unit/test_assets.rb
CHANGED
@@ -7,7 +7,7 @@ describe "Assets" do
|
|
7
7
|
include RackTestMethods
|
8
8
|
|
9
9
|
def app
|
10
|
-
Spontaneous::Rack::Back.application
|
10
|
+
Spontaneous::Rack::Back.application(site)
|
11
11
|
end
|
12
12
|
|
13
13
|
module LiveSimulation
|
@@ -24,12 +24,12 @@ describe "Assets" do
|
|
24
24
|
|
25
25
|
def new_context(live, content = @page, format = :html, params = {})
|
26
26
|
renderer = if live
|
27
|
-
Spontaneous::Output::Template::PublishRenderer.new
|
27
|
+
Spontaneous::Output::Template::PublishRenderer.new(site)
|
28
28
|
else
|
29
|
-
Spontaneous::Output::Template::PreviewRenderer.new
|
29
|
+
Spontaneous::Output::Template::PreviewRenderer.new(site)
|
30
30
|
end
|
31
31
|
output = content.output(format)
|
32
|
-
context = renderer.context(output, params)
|
32
|
+
context = renderer.context(output, params, nil)
|
33
33
|
context.extend LiveSimulation if live
|
34
34
|
context.class_eval do
|
35
35
|
# Force us into production environment
|
@@ -67,6 +67,7 @@ describe "Assets" do
|
|
67
67
|
site.config.tap do |c|
|
68
68
|
c.auto_login = 'root'
|
69
69
|
end
|
70
|
+
site.output_store(:Memory)
|
70
71
|
Spontaneous::Permissions::User.delete
|
71
72
|
user = Spontaneous::Permissions::User.create(:email => "root@example.com", :login => "root", :name => "root name", :password => "rootpass")
|
72
73
|
user.update(:level => Spontaneous::Permissions[:editor])
|
@@ -177,7 +178,7 @@ describe "Assets" do
|
|
177
178
|
end
|
178
179
|
|
179
180
|
describe "preview" do
|
180
|
-
let(:app) { Spontaneous::Rack::Back.application }
|
181
|
+
let(:app) { Spontaneous::Rack::Back.application(site) }
|
181
182
|
let(:context) { preview_context }
|
182
183
|
|
183
184
|
describe "javascript" do
|
@@ -308,19 +309,19 @@ describe "Assets" do
|
|
308
309
|
get "/assets/css/data.css"
|
309
310
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
310
311
|
result = last_response.body
|
311
|
-
result.must_match
|
312
|
+
result.must_match %r{background-image: url\(data:image\/png;base64,}
|
312
313
|
end
|
313
314
|
|
314
315
|
it "can include other assets" do
|
315
316
|
get "/assets/css/import.css"
|
316
317
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
317
318
|
result = last_response.body
|
318
|
-
result.must_match
|
319
|
+
result.must_match %r{width: 8px;}
|
319
320
|
end
|
320
321
|
end
|
321
322
|
|
322
323
|
describe "templates" do
|
323
|
-
let(:renderer) { Spontaneous::Output::Template::PreviewRenderer.new }
|
324
|
+
let(:renderer) { Spontaneous::Output::Template::PreviewRenderer.new(site) }
|
324
325
|
|
325
326
|
it "should allow for embedding asset images into templates" do
|
326
327
|
result = renderer.render_string("${ asset_path 'i/y.png' }", @page.output(:html))
|
@@ -334,7 +335,7 @@ describe "Assets" do
|
|
334
335
|
end
|
335
336
|
|
336
337
|
describe "publishing" do
|
337
|
-
let(:app) { Spontaneous::Rack::Front.application }
|
338
|
+
let(:app) { Spontaneous::Rack::Front.application(site) }
|
338
339
|
let(:context) { live_context }
|
339
340
|
let(:revision) { S::Revision.new(context.revision) }
|
340
341
|
|
@@ -352,22 +353,22 @@ describe "Assets" do
|
|
352
353
|
it "bundles & fingerprints local scripts" do
|
353
354
|
result = context.scripts('js/all', 'js/m.js', 'js/c.js', 'x')
|
354
355
|
result.must_equal [
|
355
|
-
'<script type="text/javascript" src="/assets/js/all-
|
356
|
-
'<script type="text/javascript" src="/assets/js/m-
|
357
|
-
'<script type="text/javascript" src="/assets/js/c-
|
358
|
-
'<script type="text/javascript" src="/assets/x-
|
356
|
+
'<script type="text/javascript" src="/assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js"></script>',
|
357
|
+
'<script type="text/javascript" src="/assets/js/m-262ca357844c1eeaee7688fe5bafa4ca.js"></script>',
|
358
|
+
'<script type="text/javascript" src="/assets/js/c-e405b6a6ea9a29a46905bd10627a53a8.js"></script>',
|
359
|
+
'<script type="text/javascript" src="/assets/x-e613ff07e2bd683e0c9f519c94abcb00.js"></script>'
|
359
360
|
].join("\n")
|
360
361
|
end
|
361
362
|
|
362
363
|
it "writes bundled assets to the revision directory" do
|
363
364
|
result = context.scripts('js/all')
|
364
|
-
asset_path = revision.path("assets/js/all-
|
365
|
+
asset_path = revision.path("assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js")
|
365
366
|
assert asset_path.exist?
|
366
367
|
end
|
367
368
|
|
368
369
|
it "compresses local scripts" do
|
369
370
|
result = context.scripts('js/all')
|
370
|
-
asset_path = revision.path("assets/js/all-
|
371
|
+
asset_path = revision.path("assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js")
|
371
372
|
js = asset_path.read
|
372
373
|
js.index("\n").must_be_nil
|
373
374
|
end
|
@@ -375,23 +376,23 @@ describe "Assets" do
|
|
375
376
|
it "bundles locals scripts and includes remote ones" do
|
376
377
|
result = context.scripts('js/all', '//use.typekit.com/abcde', 'http://cdn.google.com/jquery.js', 'x')
|
377
378
|
result.must_equal [
|
378
|
-
'<script type="text/javascript" src="/assets/js/all-
|
379
|
+
'<script type="text/javascript" src="/assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js"></script>',
|
379
380
|
'<script type="text/javascript" src="//use.typekit.com/abcde"></script>',
|
380
381
|
'<script type="text/javascript" src="http://cdn.google.com/jquery.js"></script>',
|
381
|
-
'<script type="text/javascript" src="/assets/x-
|
382
|
+
'<script type="text/javascript" src="/assets/x-e613ff07e2bd683e0c9f519c94abcb00.js"></script>'
|
382
383
|
].join("\n")
|
383
384
|
end
|
384
385
|
|
385
386
|
it "makes bundled scripts available under /assets" do
|
386
387
|
context.scripts('js/all')
|
387
|
-
get "/assets/js/all-
|
388
|
-
asset_path = revision.path("assets/js/all-
|
388
|
+
get "/assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js"
|
389
|
+
asset_path = revision.path("assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js")
|
389
390
|
last_response.body.must_equal asset_path.read
|
390
391
|
end
|
391
392
|
|
392
393
|
it "only bundles & compresses once" do
|
393
394
|
context.scripts('js/all')
|
394
|
-
asset_path = revision.path("assets/js/all-
|
395
|
+
asset_path = revision.path("assets/js/all-ceb12af81123a85bc4d15f23c2cf1069.js")
|
395
396
|
assert asset_path.exist?
|
396
397
|
asset_path.open("w") do |file|
|
397
398
|
file.write("var cached = true;")
|
@@ -405,16 +406,16 @@ describe "Assets" do
|
|
405
406
|
it "bundles & fingerprints local stylesheets" do
|
406
407
|
result = context.stylesheets('css/all', 'css/a.css', 'x')
|
407
408
|
result.must_equal [
|
408
|
-
'<link rel="stylesheet" href="/assets/css/all-
|
409
|
-
'<link rel="stylesheet" href="/assets/css/a-
|
410
|
-
'<link rel="stylesheet" href="/assets/x-
|
409
|
+
'<link rel="stylesheet" href="/assets/css/all-c80e50bd55af79647f771d421c0e732a.css" />',
|
410
|
+
'<link rel="stylesheet" href="/assets/css/a-2709bcba844511c3afc19fa1805e5834.css" />',
|
411
|
+
'<link rel="stylesheet" href="/assets/x-6c1e7ede5bbe3a4ff80314f43fd6ef57.css" />'
|
411
412
|
].join("\n")
|
412
413
|
end
|
413
414
|
|
414
415
|
it "ignores missing stylesheets" do
|
415
416
|
result = context.stylesheets('css/all', '/css/notfound', 'css/notfound')
|
416
417
|
result.must_equal [
|
417
|
-
'<link rel="stylesheet" href="/assets/css/all-
|
418
|
+
'<link rel="stylesheet" href="/assets/css/all-c80e50bd55af79647f771d421c0e732a.css" />',
|
418
419
|
'<link rel="stylesheet" href="/css/notfound" />',
|
419
420
|
'<link rel="stylesheet" href="css/notfound" />'
|
420
421
|
].join("\n")
|
@@ -423,10 +424,10 @@ describe "Assets" do
|
|
423
424
|
it "bundles locals scripts and includes remote ones" do
|
424
425
|
result = context.stylesheets('css/all.css', '//stylesheet.com/responsive', 'http://cdn.google.com/normalize.css', 'x')
|
425
426
|
result.must_equal [
|
426
|
-
'<link rel="stylesheet" href="/assets/css/all-
|
427
|
+
'<link rel="stylesheet" href="/assets/css/all-c80e50bd55af79647f771d421c0e732a.css" />',
|
427
428
|
'<link rel="stylesheet" href="//stylesheet.com/responsive" />',
|
428
429
|
'<link rel="stylesheet" href="http://cdn.google.com/normalize.css" />',
|
429
|
-
'<link rel="stylesheet" href="/assets/x-
|
430
|
+
'<link rel="stylesheet" href="/assets/x-6c1e7ede5bbe3a4ff80314f43fd6ef57.css" />'
|
430
431
|
].join("\n")
|
431
432
|
end
|
432
433
|
|
@@ -478,9 +479,9 @@ describe "Assets" do
|
|
478
479
|
get path
|
479
480
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
480
481
|
result = last_response.body
|
481
|
-
result.must_match %r{background:url\(/assets/i/y-
|
482
|
+
result.must_match %r{background:url\(/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace\.png\)}
|
482
483
|
|
483
|
-
asset_path = revision.path("/assets/i/y-
|
484
|
+
asset_path = revision.path("/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace.png")
|
484
485
|
assert asset_path.exist?
|
485
486
|
end
|
486
487
|
|
@@ -497,22 +498,22 @@ describe "Assets" do
|
|
497
498
|
get path
|
498
499
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
499
500
|
result = last_response.body
|
500
|
-
result.must_match %r{background:url\(/assets/i/y-
|
501
|
-
asset_path = revision.path("/assets/i/y-
|
501
|
+
result.must_match %r{background:url\(/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace\.png\?query=true#hash\)}
|
502
|
+
asset_path = revision.path("/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace.png")
|
502
503
|
assert asset_path.exist?
|
503
504
|
end
|
504
505
|
end
|
505
506
|
|
506
507
|
describe "templates" do
|
507
|
-
let(:renderer) { Spontaneous::Output::Template::PublishRenderer.new }
|
508
|
+
let(:renderer) { Spontaneous::Output::Template::PublishRenderer.new(site) }
|
508
509
|
|
509
510
|
it "should allow for embedding asset images into templates" do
|
510
511
|
result = renderer.render_string("${ asset_path 'i/y.png' }", @page.output(:html))
|
511
|
-
result.must_equal "/assets/i/y-
|
512
|
+
result.must_equal "/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace.png"
|
512
513
|
end
|
513
514
|
it "should allow for embedding asset urls into templates" do
|
514
515
|
result = renderer.render_string("${ asset_url 'i/y.png' }", @page.output(:html))
|
515
|
-
result.must_equal "url(/assets/i/y-
|
516
|
+
result.must_equal "url(/assets/i/y-e75e0b52344f0e16c0564a3a7b0b8ace.png)"
|
516
517
|
end
|
517
518
|
end
|
518
519
|
end
|
data/test/unit/test_boxes.rb
CHANGED
@@ -410,11 +410,13 @@ describe "Boxes" do
|
|
410
410
|
allow_subclasses :Allowed1
|
411
411
|
end
|
412
412
|
|
413
|
-
|
413
|
+
class ::AllowedAs < Box
|
414
|
+
allow :Allowed1, as: "Something Else"
|
415
|
+
end
|
414
416
|
end
|
415
417
|
|
416
418
|
after do
|
417
|
-
[:Parent, :Allowed1, :Allowed11, :Allowed111, :Allowed2, :Allowed3, :Allowed4, :ChildClass, :Allowable, :Mixed].each { |k| Object.send(:remove_const, k) } rescue nil
|
419
|
+
[:Parent, :Allowed1, :Allowed11, :Allowed111, :Allowed2, :Allowed3, :Allowed4, :ChildClass, :Allowable, :Mixed, :AllowedAs].each { |k| Object.send(:remove_const, k) } rescue nil
|
418
420
|
end
|
419
421
|
|
420
422
|
it "have a list of allowed types" do
|
@@ -523,6 +525,18 @@ describe "Boxes" do
|
|
523
525
|
end
|
524
526
|
assert @site.schema.classes.map(&:to_s).include?("ChildClass::InlineType"), "#{@site.schema.classes} does not include ChildClass::InlineType"
|
525
527
|
end
|
528
|
+
|
529
|
+
it "lets you define the name of the allowed type in the interface using 'as'" do
|
530
|
+
Page.box :as, class: :AllowedAs
|
531
|
+
page_schema = @site.schema.export['Page']
|
532
|
+
box_schema = page_schema[:boxes].first
|
533
|
+
allowed = box_schema[:allowed_types]
|
534
|
+
allowed.length.must_equal 1
|
535
|
+
defn = allowed.first
|
536
|
+
defn.must_be_instance_of Hash
|
537
|
+
defn[:type].must_equal "Allowed1"
|
538
|
+
defn[:as].must_equal "Something Else"
|
539
|
+
end
|
526
540
|
end
|
527
541
|
|
528
542
|
describe "Box groups" do
|