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
@@ -29,7 +29,7 @@ module Spontaneous::Field
|
|
29
29
|
alias_method :on?, :checked?
|
30
30
|
alias_method :enabled?, :checked?
|
31
31
|
|
32
|
-
def preprocess(value)
|
32
|
+
def preprocess(value, site)
|
33
33
|
case value
|
34
34
|
when TrueClass, FalseClass
|
35
35
|
value
|
@@ -44,15 +44,15 @@ module Spontaneous::Field
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def generate_boolean(state)
|
47
|
+
def generate_boolean(state, site)
|
48
48
|
state
|
49
49
|
end
|
50
50
|
|
51
|
-
def generate_html(state)
|
51
|
+
def generate_html(state, site)
|
52
52
|
string_value(state)
|
53
53
|
end
|
54
54
|
|
55
|
-
def generate_string(state)
|
55
|
+
def generate_string(state, site)
|
56
56
|
string_value(state)
|
57
57
|
end
|
58
58
|
|
@@ -26,7 +26,7 @@ module Spontaneous::Field
|
|
26
26
|
[:julian]
|
27
27
|
end
|
28
28
|
|
29
|
-
def preprocess(value)
|
29
|
+
def preprocess(value, site)
|
30
30
|
return value if value.blank?
|
31
31
|
::Date.parse(value)
|
32
32
|
end
|
@@ -35,7 +35,7 @@ module Spontaneous::Field
|
|
35
35
|
%(<time datetime="%Y-%m-%d">#{ format }</time>)
|
36
36
|
end
|
37
37
|
|
38
|
-
def generate_julian(date)
|
38
|
+
def generate_julian(date, site)
|
39
39
|
return date.jd if date.is_a?(::Date)
|
40
40
|
date.to_s
|
41
41
|
end
|
@@ -6,7 +6,10 @@ module Spontaneous::Field
|
|
6
6
|
class File < Base
|
7
7
|
has_editor
|
8
8
|
|
9
|
+
# In the case of clearing the field we will have been given a pending_value of ""
|
10
|
+
# we don't want that to run asynchronously
|
9
11
|
def asynchronous?
|
12
|
+
return false if (pending_value && pending_value[:value].blank?)
|
10
13
|
true
|
11
14
|
end
|
12
15
|
|
@@ -14,15 +17,17 @@ module Spontaneous::Field
|
|
14
17
|
[:html, :path, :filesize, :filename]
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
18
|
-
file = process_upload(value)
|
20
|
+
def set_pending_value(value, site)
|
21
|
+
file = process_upload(value, site)
|
19
22
|
pending = case file
|
23
|
+
when nil
|
24
|
+
""
|
20
25
|
when String
|
21
26
|
{ :tempfile => file }
|
22
27
|
else
|
23
28
|
serialize_pending_file(file)
|
24
29
|
end
|
25
|
-
super(pending)
|
30
|
+
super(pending, site)
|
26
31
|
end
|
27
32
|
|
28
33
|
def page_lock_description
|
@@ -35,30 +40,31 @@ module Spontaneous::Field
|
|
35
40
|
|
36
41
|
def storage_headers(content_type, filename)
|
37
42
|
headers = { content_type: content_type }
|
38
|
-
if prototype.options[:attachment]
|
43
|
+
if prototype && prototype.options[:attachment]
|
39
44
|
headers.update(content_disposition: %(attachment; filename=#{Rack::Utils.escape(filename)}))
|
40
45
|
end
|
41
46
|
headers
|
42
47
|
end
|
43
48
|
|
44
|
-
def
|
49
|
+
def process_upload(value, site)
|
50
|
+
return nil if value.blank?
|
51
|
+
file, filename, mimetype = fileinfo(value)
|
52
|
+
media_file = site.tempfile(self, filename, storage_headers(mimetype, filename))
|
53
|
+
media_file.copy(file)
|
54
|
+
media_file
|
55
|
+
end
|
56
|
+
|
57
|
+
def preprocess(image, site)
|
45
58
|
file, filename, mimetype = fileinfo(image)
|
46
59
|
return "" if file.nil?
|
47
60
|
return file unless ::File.exist?(file)
|
48
61
|
|
49
|
-
media_file =
|
62
|
+
media_file = site.file(owner, filename, storage_headers(mimetype, filename))
|
50
63
|
media_file.copy(file)
|
51
64
|
set_unprocessed_value(media_file.path)
|
52
65
|
media_file
|
53
66
|
end
|
54
67
|
|
55
|
-
def process_upload(value)
|
56
|
-
file, filename, mimetype = fileinfo(value)
|
57
|
-
media_file = Spontaneous::Media::TempFile.new(self, filename, storage_headers(mimetype, filename))
|
58
|
-
media_file.copy(file)
|
59
|
-
media_file
|
60
|
-
end
|
61
|
-
|
62
68
|
def fileinfo(fileinfo)
|
63
69
|
file = filename = mimetype = nil
|
64
70
|
case fileinfo
|
@@ -71,7 +77,7 @@ module Spontaneous::Field
|
|
71
77
|
[file, filename, mimetype]
|
72
78
|
end
|
73
79
|
|
74
|
-
def generate_filesize(input)
|
80
|
+
def generate_filesize(input, site)
|
75
81
|
if input.respond_to?(:filesize)
|
76
82
|
input.filesize
|
77
83
|
else
|
@@ -79,7 +85,7 @@ module Spontaneous::Field
|
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
82
|
-
def generate_filename(input)
|
88
|
+
def generate_filename(input, site)
|
83
89
|
if input.respond_to?(:filename)
|
84
90
|
input.filename
|
85
91
|
else
|
@@ -87,13 +93,13 @@ module Spontaneous::Field
|
|
87
93
|
end
|
88
94
|
end
|
89
95
|
|
90
|
-
def generate_path(input)
|
96
|
+
def generate_path(input, site)
|
91
97
|
return input if input.is_a?(::String)
|
92
98
|
input.url
|
93
99
|
end
|
94
100
|
|
95
|
-
def generate_html(input)
|
96
|
-
generate_path(input)
|
101
|
+
def generate_html(input, site)
|
102
|
+
generate_path(input, site)
|
97
103
|
end
|
98
104
|
|
99
105
|
def export(user = nil)
|
@@ -15,23 +15,10 @@ module Spontaneous::Field
|
|
15
15
|
%w{image/(png|jpeg|gif)}
|
16
16
|
end
|
17
17
|
|
18
|
-
class TemplateParameters < DelegateClass(S::Media::Image::Attributes)
|
19
|
-
attr_reader :image
|
20
|
-
|
21
|
-
def initialize(image, args)
|
22
|
-
super(image)
|
23
|
-
@image, @args = image, args.extract_options!
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_html(attributes = {})
|
27
|
-
@image.to_html(@args.merge(attributes))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
18
|
def self.size(name, options = {}, &process)
|
32
19
|
self.sizes[name.to_sym] = [options, process]
|
33
20
|
unless method_defined?(name)
|
34
|
-
class_eval "def #{name}(*args);
|
21
|
+
class_eval "def #{name}(*args); sizes[:#{name}]; end"
|
35
22
|
end
|
36
23
|
end
|
37
24
|
|
@@ -91,15 +78,15 @@ module Spontaneous::Field
|
|
91
78
|
end
|
92
79
|
|
93
80
|
def width
|
94
|
-
original.width
|
81
|
+
original.width || 0
|
95
82
|
end
|
96
83
|
|
97
84
|
def height
|
98
|
-
original.height
|
85
|
+
original.height || 0
|
99
86
|
end
|
100
87
|
|
101
88
|
def filesize
|
102
|
-
original.filesize
|
89
|
+
original.filesize || 0
|
103
90
|
end
|
104
91
|
|
105
92
|
def src
|
@@ -119,12 +106,12 @@ module Spontaneous::Field
|
|
119
106
|
sizes[:original].src
|
120
107
|
end
|
121
108
|
|
122
|
-
def set_value!(value, process = true)
|
109
|
+
def set_value!(value, process = true, site = nil)
|
123
110
|
@sizes = nil
|
124
111
|
super
|
125
112
|
end
|
126
113
|
|
127
|
-
def generate(name, media_file)
|
114
|
+
def generate(name, media_file, site)
|
128
115
|
return { :src => media_file } if media_file.is_a?(::String)
|
129
116
|
options, process = self.class.size_definitions[name]
|
130
117
|
size = Size.new(media_file, name, options, process)
|
@@ -4,10 +4,10 @@ module Spontaneous::Field
|
|
4
4
|
class LongString < Base
|
5
5
|
has_editor
|
6
6
|
|
7
|
-
def generate_html(value)
|
8
|
-
escape_html(value).gsub(/[\r\n]+/, "<br
|
7
|
+
def generate_html(value, site)
|
8
|
+
escape_html(value).gsub(/[\r\n]+/, "<br />\n")
|
9
9
|
end
|
10
10
|
|
11
|
-
self.register
|
11
|
+
self.register(:long_string, :longstring, :text)
|
12
12
|
end # LongStringField
|
13
13
|
end
|
@@ -10,11 +10,11 @@ module Spontaneous::Field
|
|
10
10
|
[:html]
|
11
11
|
end
|
12
12
|
|
13
|
-
def generate_html(input)
|
13
|
+
def generate_html(input, site)
|
14
14
|
input.to_html
|
15
15
|
end
|
16
16
|
|
17
|
-
def preprocess(input)
|
17
|
+
def preprocess(input, site)
|
18
18
|
# convert lines ending with newlines into a <br/>
|
19
19
|
# as official Markdown syntax isn't suitable for
|
20
20
|
# casual users
|
@@ -31,6 +31,6 @@ module Spontaneous::Field
|
|
31
31
|
Kramdown::Document.new(output)
|
32
32
|
end
|
33
33
|
|
34
|
-
self.register(:markdown, :
|
34
|
+
self.register(:markdown, :markup, :richtext)
|
35
35
|
end
|
36
36
|
end
|
@@ -86,12 +86,12 @@ module Spontaneous::Field
|
|
86
86
|
[:html, :label]
|
87
87
|
end
|
88
88
|
|
89
|
-
def generate(output, value)
|
89
|
+
def generate(output, value, site)
|
90
90
|
return "" if value.blank?
|
91
91
|
value[[:html, :label].index(output)]
|
92
92
|
end
|
93
93
|
|
94
|
-
def preprocess(value)
|
94
|
+
def preprocess(value, site)
|
95
95
|
Spontaneous::JSON.parse(value)
|
96
96
|
end
|
97
97
|
|
@@ -4,11 +4,11 @@ module Spontaneous::Field
|
|
4
4
|
class String < Base
|
5
5
|
has_editor
|
6
6
|
|
7
|
-
def preprocess(value)
|
7
|
+
def preprocess(value, site)
|
8
8
|
Spontaneous::Utils::SmartQuotes.smarten(value.to_s)
|
9
9
|
end
|
10
10
|
|
11
|
-
def generate_html(value)
|
11
|
+
def generate_html(value, site)
|
12
12
|
escape_html(value)
|
13
13
|
end
|
14
14
|
|
@@ -12,13 +12,13 @@ module Spontaneous::Field
|
|
12
12
|
[:html, :tags]
|
13
13
|
end
|
14
14
|
|
15
|
-
def generate_html(value)
|
15
|
+
def generate_html(value, site)
|
16
16
|
value
|
17
17
|
end
|
18
18
|
|
19
19
|
TAG_PARSER_RE = /"([^"]+)"|([^ ]+)/
|
20
20
|
|
21
|
-
def generate_tags(value)
|
21
|
+
def generate_tags(value, site)
|
22
22
|
return [] if value.blank?
|
23
23
|
(value).scan(TAG_PARSER_RE).flatten.compact
|
24
24
|
end
|
@@ -3,27 +3,27 @@
|
|
3
3
|
module Spontaneous::Field
|
4
4
|
|
5
5
|
class Update
|
6
|
-
def self.perform(fields, user, asynchronous = false)
|
7
|
-
self.new(fields, user).run(asynchronous)
|
6
|
+
def self.perform(site, fields, user, asynchronous = false)
|
7
|
+
self.new(site, fields, user).run(asynchronous)
|
8
8
|
end
|
9
9
|
|
10
10
|
|
11
|
-
def self.asynchronous_update_class
|
12
|
-
|
11
|
+
def self.asynchronous_update_class(site)
|
12
|
+
site.resolve_background_mode(self)
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(fields, user)
|
16
|
-
@fields, @user = fields, user
|
15
|
+
def initialize(site, fields, user)
|
16
|
+
@site, @fields, @user = site, fields, user
|
17
17
|
end
|
18
18
|
|
19
19
|
def run(asynchronous = false)
|
20
20
|
fields.each do |field, value|
|
21
|
-
field.
|
21
|
+
field.set_pending_value(value, @site)
|
22
22
|
end
|
23
23
|
|
24
24
|
immediate, asynchronous = partition_fields(asynchronous)
|
25
25
|
|
26
|
-
Immediate.process(immediate)
|
26
|
+
Immediate.process(@site, immediate)
|
27
27
|
|
28
28
|
launch_asynchronous_update(asynchronous)
|
29
29
|
end
|
@@ -58,8 +58,8 @@ module Spontaneous::Field
|
|
58
58
|
fields.each do |field|
|
59
59
|
prepare_asynchronous_update(field)
|
60
60
|
end
|
61
|
-
updater = self.class.asynchronous_update_class
|
62
|
-
updater.process(fields)
|
61
|
+
updater = self.class.asynchronous_update_class(@site)
|
62
|
+
updater.process(@site, fields)
|
63
63
|
end
|
64
64
|
|
65
65
|
def prepare_asynchronous_update(field)
|
@@ -68,17 +68,17 @@ module Spontaneous::Field
|
|
68
68
|
end
|
69
69
|
|
70
70
|
class Immediate
|
71
|
-
def self.process(fields)
|
72
|
-
self.new(fields).run
|
71
|
+
def self.process(site, fields)
|
72
|
+
self.new(site, fields).run
|
73
73
|
end
|
74
74
|
|
75
|
-
def initialize(fields)
|
76
|
-
@fields = Array(fields)
|
75
|
+
def initialize(site, fields)
|
76
|
+
@site, @fields = site, Array(fields)
|
77
77
|
end
|
78
78
|
|
79
79
|
def run
|
80
80
|
@fields.each do |field|
|
81
|
-
field.process_pending_value
|
81
|
+
field.process_pending_value(@site)
|
82
82
|
end
|
83
83
|
save
|
84
84
|
end
|
@@ -114,8 +114,8 @@ module Spontaneous::Field
|
|
114
114
|
# so we can update the fields we have updated without over-writing the db
|
115
115
|
# versions of any other fields.
|
116
116
|
def reload(owner)
|
117
|
-
|
118
|
-
o =
|
117
|
+
owner.model.scope! do
|
118
|
+
o = owner.model.get(owner.content_instance.id)
|
119
119
|
return o.boxes[owner.box_name] if Spontaneous::Box === owner
|
120
120
|
o
|
121
121
|
end
|
@@ -135,8 +135,9 @@ module Spontaneous::Field
|
|
135
135
|
# Load these everytime to ensure they are updated with their
|
136
136
|
# correct lock status
|
137
137
|
def pages
|
138
|
-
|
139
|
-
|
138
|
+
pages = owners.map { |owner| [owner.model, owner.page] }.uniq
|
139
|
+
pages = pages.reject { |model, page| page.nil? }.map { |model, page| [model, page.id] }
|
140
|
+
pages.map { |model, id| model.get(id) }
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
@@ -146,7 +147,7 @@ module Spontaneous::Field
|
|
146
147
|
begin
|
147
148
|
Spontaneous::Simultaneous.fire(:update_fields, params)
|
148
149
|
rescue Spontaneous::Simultaneous::Error
|
149
|
-
Immediate.process(@fields)
|
150
|
+
Immediate.process(@site, @fields)
|
150
151
|
end
|
151
152
|
end
|
152
153
|
end
|
@@ -97,7 +97,7 @@ module Spontaneous::Field
|
|
97
97
|
values[:video_id]
|
98
98
|
end
|
99
99
|
|
100
|
-
def generate_outputs(input)
|
100
|
+
def generate_outputs(input, site)
|
101
101
|
values = {}
|
102
102
|
values[:html] = escape_html(input)
|
103
103
|
|
@@ -109,19 +109,19 @@ module Spontaneous::Field
|
|
109
109
|
values.merge(metadata || {})
|
110
110
|
end
|
111
111
|
|
112
|
-
def render(format=:html, *args)
|
112
|
+
def render(format=:html, locals = {}, *args)
|
113
113
|
case format
|
114
114
|
when :html
|
115
|
-
to_html(
|
115
|
+
to_html(locals)
|
116
116
|
when :json
|
117
|
-
to_json(
|
117
|
+
to_json(locals)
|
118
118
|
else
|
119
119
|
value(format)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
def to_html(
|
124
|
-
provider.to_html(
|
123
|
+
def to_html(locals = {})
|
124
|
+
provider.to_html(locals)
|
125
125
|
end
|
126
126
|
|
127
127
|
def provider_id
|