spontaneous 0.2.0.beta5 → 0.2.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +39 -0
- data/Gemfile +2 -0
- data/Readme.markdown +4 -4
- data/application/css/core.css.scss +144 -43
- data/application/css/definitions.css.scss +50 -16
- data/application/css/dialogue.css.scss +5 -2
- data/application/css/editing.css.scss +7 -7
- data/application/css/font.css.scss +1 -1
- data/application/css/meta.css.scss +6 -6
- data/application/css/popover.css.scss +6 -6
- data/application/css/top.css.scss +8 -1
- data/application/js/add_alias_dialogue.js +137 -36
- data/application/js/add_home_dialogue.js +10 -10
- data/application/js/ajax.js +26 -26
- data/application/js/authentication.js +2 -2
- data/application/js/box.js +21 -10
- data/application/js/box_container.js +13 -7
- data/application/js/compatibility.js +19 -17
- data/application/js/conflicted_field_dialogue.js +5 -5
- data/application/js/content.js +22 -16
- data/application/js/content_area.js +62 -33
- data/application/js/dialogue.js +16 -16
- data/application/js/dom.js +9 -10
- data/application/js/edit_panel.js +25 -20
- data/application/js/editing.js +21 -8
- data/application/js/entry.js +1 -1
- data/application/js/extensions.js +11 -11
- data/application/js/field/boolean.js +6 -6
- data/application/js/field/date.js +1 -1
- data/application/js/field/file.js +17 -17
- data/application/js/field/image.js +27 -27
- data/application/js/field/markdown.js +72 -71
- data/application/js/field/select.js +9 -9
- data/application/js/field/string.js +3 -3
- data/application/js/field/webvideo.js +2 -2
- data/application/js/field_preview.js +3 -0
- data/application/js/init.js +3 -2
- data/application/js/jquery-selection-position.js +13 -13
- data/application/js/location.js +17 -12
- data/application/js/login.js +2 -2
- data/application/js/meta_view/user_admin.js +101 -101
- data/application/js/metadata.js +1 -1
- data/application/js/page.js +2 -2
- data/application/js/page_browser.js +13 -13
- data/application/js/page_entry.js +1 -1
- data/application/js/panel/root_menu.js +10 -10
- data/application/js/popover.js +6 -5
- data/application/js/popover_view.js +5 -5
- data/application/js/preview.js +10 -4
- data/application/js/progress.js +6 -6
- data/application/js/properties.js +35 -6
- data/application/js/publish.js +43 -43
- data/application/js/require.js +14 -14
- data/application/js/services.js +3 -3
- data/application/js/sharded_upload.js +9 -8
- data/application/js/side_bar.js +5 -5
- data/application/js/state.js +2 -2
- data/application/js/status_bar.js +6 -6
- data/application/js/top_bar.js +97 -65
- data/application/js/types.js +9 -6
- data/application/js/upload.js +4 -4
- data/application/js/upload_manager.js +21 -21
- data/application/js/user.js +1 -1
- data/application/js/vendor/jquery.velocity.min.js +7 -0
- data/application/js/views.js +32 -8
- data/application/js/views/box_view.js +51 -31
- data/application/js/views/page_piece_view.js +17 -15
- data/application/js/views/page_view.js +54 -43
- data/application/js/views/piece_view.js +44 -37
- data/application/static/font/fontawesome-webfont-4f0022f25672c7f501c339cbf98d9117.ttf +0 -0
- data/application/views/index.erb +1 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +2 -1
- data/db/migrations/20130813111009_increase_path_length.rb +11 -2
- data/db/migrations/20140506171823_add_index_to_target_id.rb +11 -0
- data/db/migrations/20140514090204_add_content_hash.rb +59 -0
- data/db/migrations/20140519150253_add_content_hash_timestamp.rb +20 -0
- data/lib/spontaneous.rb +0 -1
- data/lib/spontaneous/asset/environment.rb +77 -15
- data/lib/spontaneous/box.rb +21 -0
- data/lib/spontaneous/capistrano/deploy.rb +1 -1
- data/lib/spontaneous/capistrano/sync.rb +8 -7
- data/lib/spontaneous/change.rb +4 -2
- data/lib/spontaneous/cli/fields.rb +7 -3
- data/lib/spontaneous/cli/generate.rb +2 -0
- data/lib/spontaneous/cli/init.rb +24 -93
- data/lib/spontaneous/cli/init/db.rb +94 -0
- data/lib/spontaneous/cli/init/mysql.rb +17 -0
- data/lib/spontaneous/cli/init/postgresql.rb +33 -0
- data/lib/spontaneous/cli/init/sqlite.rb +14 -0
- data/lib/spontaneous/cli/site.rb +45 -20
- data/lib/spontaneous/collections/box_set.rb +3 -0
- data/lib/spontaneous/collections/entry_set.rb +43 -4
- data/lib/spontaneous/collections/field_set.rb +14 -2
- data/lib/spontaneous/data_mapper.rb +40 -7
- data/lib/spontaneous/data_mapper/content_model.rb +1 -1
- data/lib/spontaneous/data_mapper/content_model/associations.rb +63 -12
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +9 -14
- data/lib/spontaneous/data_mapper/content_table.rb +4 -2
- data/lib/spontaneous/data_mapper/dataset.rb +31 -2
- data/lib/spontaneous/data_mapper/scope.rb +37 -20
- data/lib/spontaneous/errors.rb +6 -0
- data/lib/spontaneous/facet.rb +20 -10
- data/lib/spontaneous/field/base.rb +8 -1
- data/lib/spontaneous/field/file.rb +28 -3
- data/lib/spontaneous/field/image.rb +2 -0
- data/lib/spontaneous/field/update.rb +6 -0
- data/lib/spontaneous/field/webvideo/vimeo.rb +6 -1
- data/lib/spontaneous/field/webvideo/vine.rb +1 -1
- data/lib/spontaneous/field/webvideo/youtube.rb +1 -1
- data/lib/spontaneous/generators/site.rb +6 -4
- data/lib/spontaneous/generators/site/.gitignore +1 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +3 -3
- data/lib/spontaneous/generators/site/config/{indexes.rb.tt → initializers/indexes.rb.tt} +0 -0
- data/lib/spontaneous/generators/site/config/initializers/publishing.rb.tt +78 -0
- data/lib/spontaneous/generators/site/{config/database.yml.tt → db/mysql2.yml.tt} +7 -6
- data/lib/spontaneous/generators/site/db/postgres.yml.tt +25 -0
- data/lib/spontaneous/generators/site/db/sqlite3.yml.tt +18 -0
- data/lib/spontaneous/generators/site/public/humans.txt.tt +14 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +51 -0
- data/lib/spontaneous/loader.rb +1 -1
- data/lib/spontaneous/logger.rb +1 -1
- data/lib/spontaneous/media/image/optimizer.rb +1 -1
- data/lib/spontaneous/media/image/processor.rb +11 -2
- data/lib/spontaneous/media/image/renderable.rb +2 -0
- data/lib/spontaneous/model.rb +3 -0
- data/lib/spontaneous/model/box/allowed_types.rb +17 -4
- data/lib/spontaneous/model/core.rb +36 -3
- data/lib/spontaneous/model/core/aliases.rb +5 -2
- data/lib/spontaneous/model/core/boxes.rb +6 -0
- data/lib/spontaneous/model/core/cascading_change.rb +38 -0
- data/lib/spontaneous/model/core/content_hash.rb +171 -0
- data/lib/spontaneous/model/core/entries.rb +0 -19
- data/lib/spontaneous/model/core/fields.rb +11 -0
- data/lib/spontaneous/model/core/modifications.rb +22 -21
- data/lib/spontaneous/model/core/render.rb +3 -0
- data/lib/spontaneous/model/core/serialisation.rb +18 -17
- data/lib/spontaneous/model/page.rb +35 -8
- data/lib/spontaneous/model/page/page_tree.rb +20 -8
- data/lib/spontaneous/model/page/paths.rb +79 -50
- data/lib/spontaneous/model/page/singleton.rb +71 -0
- data/lib/spontaneous/model/page/site_map.rb +2 -1
- data/lib/spontaneous/model/page/site_timestamps.rb +2 -2
- data/lib/spontaneous/model/piece.rb +10 -0
- data/lib/spontaneous/output/context.rb +13 -6
- data/lib/spontaneous/output/format.rb +30 -5
- data/lib/spontaneous/output/helpers/script_helper.rb +8 -0
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +7 -0
- data/lib/spontaneous/output/renderable.rb +16 -0
- data/lib/spontaneous/output/store.rb +1 -1
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/page_piece.rb +25 -1
- data/lib/spontaneous/prototypes/box_prototype.rb +13 -0
- data/lib/spontaneous/prototypes/field_prototype.rb +7 -4
- data/lib/spontaneous/publishing.rb +10 -5
- data/lib/spontaneous/publishing/immediate.rb +32 -349
- data/lib/spontaneous/publishing/pipeline.rb +43 -0
- data/lib/spontaneous/publishing/progress.rb +186 -0
- data/lib/spontaneous/publishing/publish.rb +107 -0
- data/lib/spontaneous/publishing/rerender.rb +17 -0
- data/lib/spontaneous/publishing/revision.rb +53 -18
- data/lib/spontaneous/publishing/simultaneous.rb +1 -1
- data/lib/spontaneous/publishing/steps.rb +154 -0
- data/lib/spontaneous/publishing/steps/activate_revision.rb +45 -0
- data/lib/spontaneous/publishing/steps/archive_old_revisions.rb +22 -0
- data/lib/spontaneous/publishing/steps/base_step.rb +49 -0
- data/lib/spontaneous/publishing/steps/copy_static_files.rb +74 -0
- data/lib/spontaneous/publishing/steps/create_revision_directory.rb +24 -0
- data/lib/spontaneous/publishing/steps/generate_rackup_file.rb +51 -0
- data/lib/spontaneous/publishing/steps/generate_search_indexes.rb +24 -0
- data/lib/spontaneous/publishing/steps/render_revision.rb +69 -0
- data/lib/spontaneous/publishing/steps/write_revision_file.rb +43 -0
- data/lib/spontaneous/rack/back.rb +3 -1
- data/lib/spontaneous/rack/back/alias.rb +9 -8
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/middleware.rb +7 -4
- data/lib/spontaneous/rack/middleware/transaction.rb +14 -0
- data/lib/spontaneous/rack/page_controller.rb +23 -8
- data/lib/spontaneous/revision.rb +5 -10
- data/lib/spontaneous/schema.rb +5 -0
- data/lib/spontaneous/server.rb +3 -1
- data/lib/spontaneous/site.rb +17 -10
- data/lib/spontaneous/site/publishing.rb +25 -3
- data/lib/spontaneous/site/state.rb +7 -3
- data/lib/spontaneous/tasks/database.rake +5 -10
- data/lib/spontaneous/utils/database/mysql_dumper.rb +5 -1
- data/lib/spontaneous/version.rb +1 -1
- data/spontaneous.gemspec +4 -3
- data/test/fixtures/example_application/config/initializers/initializer1.rb +1 -0
- data/test/fixtures/example_application/config/initializers/initializer2.rb +1 -0
- data/test/fixtures/example_application/config/initializers/publishing.rb +13 -0
- data/test/fixtures/search/config/{indexes.rb → initializers/indexes.rb} +0 -0
- data/test/fixtures/serialisation/root_hash.yaml.erb +10 -4
- data/test/functional/test_application.rb +10 -0
- data/test/functional/test_back.rb +23 -5
- data/test/functional/test_cli.rb +98 -34
- data/test/functional/test_front.rb +7 -3
- data/test/test_helper.rb +35 -28
- data/test/unit/test_alias.rb +20 -3
- data/test/unit/test_assets.rb +58 -30
- data/test/unit/test_changesets.rb +20 -12
- data/test/unit/test_content_hash.rb +496 -0
- data/test/unit/test_context.rb +28 -1
- data/test/unit/test_controllers.rb +96 -61
- data/test/unit/test_crypt.rb +1 -8
- data/test/unit/test_datamapper.rb +95 -19
- data/test/unit/test_features.rb +1 -4
- data/test/unit/test_fields.rb +61 -12
- data/test/unit/test_generators.rb +39 -2
- data/test/unit/test_images.rb +3 -1
- data/test/unit/test_modifications.rb +224 -219
- data/test/unit/test_output_store.rb +10 -0
- data/test/unit/{test_formats.rb → test_outputs.rb} +75 -6
- data/test/unit/test_page.rb +61 -15
- data/test/unit/test_plugins.rb +2 -42
- data/test/unit/test_publishing_pipeline.rb +1050 -0
- data/test/unit/test_render.rb +30 -0
- data/test/unit/test_revisions.rb +110 -2
- data/test/unit/test_schema.rb +4 -0
- data/test/unit/test_search.rb +1 -1
- data/test/unit/test_serialisation.rb +6 -1
- data/test/unit/test_singletons.rb +159 -0
- data/test/unit/test_site.rb +71 -44
- metadata +140 -86
- data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
- data/test/unit/test_publishing.rb +0 -330
@@ -58,15 +58,41 @@ module Spontaneous
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
# Using prepared statements for associations within sqlite causes
|
62
|
+
# problems with multiprocess access as preparing the ps within a
|
63
|
+
# transaction locks the content table and prevents the field update &
|
64
|
+
# publishing processes from updating it
|
65
|
+
def associations_use_prepared_statements?
|
66
|
+
mapper.db.database_type != :sqlite
|
67
|
+
end
|
68
|
+
|
61
69
|
def has_many_content(name, opts = {})
|
62
70
|
opts[:association] = :one_to_many
|
63
71
|
opts[:dataset_method] = "#{name}_dataset"
|
72
|
+
opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
|
73
|
+
opts[:ps_method] = "#{name}_prepared_statement".to_sym
|
74
|
+
opts[:ps_name] = "#{name}_#{opts[:association]}_association".to_sym
|
64
75
|
opts[:add_method] = "add_#{name.to_s.singularize}"
|
76
|
+
opts[:load_method] = "load_#{opts[:association]}_association".to_sym
|
77
|
+
opts[:dataset] = Proc.new do |var|
|
78
|
+
mapper.where!([[mapper.qualify_column(opts[:key]), var]])
|
79
|
+
end
|
65
80
|
mod = opts[:module] ||= association_method_module
|
66
|
-
|
81
|
+
if associations_use_prepared_statements?
|
82
|
+
define_association_method(mod, opts[:load_ps_method]) {
|
83
|
+
ps = self.send(opts[:ps_method])
|
84
|
+
ps.call(id: id)
|
85
|
+
}
|
86
|
+
else
|
87
|
+
define_association_method(mod, opts[:load_ps_method]) {
|
88
|
+
opts[:dataset].call(id).all
|
89
|
+
}
|
90
|
+
end
|
91
|
+
define_association_method(mod, opts[:ps_method]) {
|
92
|
+
mapper.prepare(:select, opts[:ps_name]) { opts[:dataset].call(:$id) }
|
93
|
+
}
|
67
94
|
define_association_method(mod, opts[:dataset_method]) {
|
68
|
-
|
69
|
-
m.where!([[m.qualify_column(opts[:key]), id]])
|
95
|
+
opts[:dataset].call(id)
|
70
96
|
}
|
71
97
|
define_association_method(mod, name) { |options = {}|
|
72
98
|
load_cached_association(name, options)
|
@@ -83,11 +109,35 @@ module Spontaneous
|
|
83
109
|
opts[:association] = :many_to_one
|
84
110
|
opts[:dataset_method] = "#{name}_dataset"
|
85
111
|
opts[:add_method] = "#{name}="
|
112
|
+
opts[:load_method] = "load_#{opts[:association]}_association".to_sym
|
113
|
+
opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
|
114
|
+
opts[:ps_method] = "#{name}_prepared_statement".to_sym
|
115
|
+
opts[:ps_name] = "load_#{name}_#{opts[:association]}_association".to_sym
|
116
|
+
opts[:dataset] = Proc.new do |var|
|
117
|
+
m = mapper
|
118
|
+
m.where!([[m.qualify_column(:id), var]])
|
119
|
+
end
|
86
120
|
mod = opts[:module] ||= association_method_module
|
87
121
|
|
122
|
+
if associations_use_prepared_statements?
|
123
|
+
define_association_method(mod, opts[:load_ps_method]) {
|
124
|
+
id = send(opts[:key])
|
125
|
+
return nil if id.nil?
|
126
|
+
ps = self.send(opts[:ps_method])
|
127
|
+
ps.call(id: id)
|
128
|
+
}
|
129
|
+
else
|
130
|
+
define_association_method(mod, opts[:load_ps_method]) {
|
131
|
+
id = send(opts[:key])
|
132
|
+
return nil if id.nil?
|
133
|
+
opts[:dataset].call(id).first
|
134
|
+
}
|
135
|
+
end
|
136
|
+
define_association_method(mod, opts[:ps_method]) {
|
137
|
+
mapper.prepare(:first, opts[:ps_name]) { opts[:dataset].call(:$id) }
|
138
|
+
}
|
88
139
|
define_association_method(mod, opts[:dataset_method]) {
|
89
|
-
|
90
|
-
m.where!([[m.qualify_column(:id), send(opts[:key])]])
|
140
|
+
opts[:dataset].call(send(opts[:key]))
|
91
141
|
}
|
92
142
|
define_association_method(mod, name) { |options = {}|
|
93
143
|
load_cached_association(name, options)
|
@@ -201,13 +251,11 @@ module Spontaneous
|
|
201
251
|
end
|
202
252
|
|
203
253
|
def load_many_to_one_association(assoc)
|
204
|
-
|
205
|
-
return nil if id.nil?
|
206
|
-
mapper[id]
|
254
|
+
self.send(assoc[:load_ps_method])
|
207
255
|
end
|
208
256
|
|
209
257
|
def load_one_to_many_association(assoc)
|
210
|
-
members = self.send(assoc[:
|
258
|
+
members = self.send(assoc[:load_ps_method])#.all.compact
|
211
259
|
if (reciprocal = assoc[:reciprocal])
|
212
260
|
members.each do |member|
|
213
261
|
member.send :set_association_cache, reciprocal, self
|
@@ -221,8 +269,7 @@ module Spontaneous
|
|
221
269
|
clear_association_cache(name) if options[:reload]
|
222
270
|
ac = associations_cache
|
223
271
|
unless ac.key?(name)
|
224
|
-
|
225
|
-
ac[name] = send(load_method, assoc)
|
272
|
+
ac[name] = send(assoc[:load_method], assoc)
|
226
273
|
end
|
227
274
|
ac[name]
|
228
275
|
end
|
@@ -239,8 +286,12 @@ module Spontaneous
|
|
239
286
|
associations_cache.delete(name)
|
240
287
|
end
|
241
288
|
|
242
|
-
def
|
289
|
+
def clear_association_cache!
|
243
290
|
associations_cache.clear
|
291
|
+
end
|
292
|
+
|
293
|
+
def refresh
|
294
|
+
clear_association_cache!
|
244
295
|
@association_proxy_instance = nil
|
245
296
|
super
|
246
297
|
end
|
@@ -12,27 +12,22 @@ module Spontaneous
|
|
12
12
|
super
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
# def before_update
|
21
|
-
# # set_update_timestamp
|
22
|
-
# super
|
23
|
-
# end
|
15
|
+
def before_update
|
16
|
+
set_update_timestamp
|
17
|
+
super
|
18
|
+
end
|
24
19
|
|
25
20
|
def set_create_timestamp(time=nil)
|
26
21
|
return unless self.respond_to?(:created_at)
|
27
22
|
time ||= Spontaneous::DataMapper.timestamp
|
28
23
|
self.send(:"created_at=", time) if send(:created_at).nil?
|
29
|
-
|
24
|
+
set_update_timestamp(time)
|
30
25
|
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
def set_update_timestamp(time=nil)
|
28
|
+
return unless self.respond_to?(:modified_at)
|
29
|
+
self.send(:modified_at=, time || Spontaneous::DataMapper.timestamp)
|
30
|
+
end
|
36
31
|
end
|
37
32
|
end
|
38
33
|
end
|
@@ -45,8 +45,10 @@ module Spontaneous
|
|
45
45
|
:id
|
46
46
|
end
|
47
47
|
|
48
|
-
def dataset(revision = nil)
|
49
|
-
@database[revision_table(revision)]
|
48
|
+
def dataset(revision = nil, visible_only = false)
|
49
|
+
ds = @database[revision_table(revision)]
|
50
|
+
ds.filter!(hidden: false) if visible_only
|
51
|
+
ds
|
50
52
|
end
|
51
53
|
|
52
54
|
def logger
|
@@ -143,6 +143,33 @@ module Spontaneous
|
|
143
143
|
self
|
144
144
|
end
|
145
145
|
|
146
|
+
class PreparedStatement
|
147
|
+
def initialize(name, ds, ps)
|
148
|
+
@name = name
|
149
|
+
@ds = ds
|
150
|
+
@ps = ps
|
151
|
+
end
|
152
|
+
|
153
|
+
def call(vars = {})
|
154
|
+
results = @ps.call(vars)
|
155
|
+
case results
|
156
|
+
when Array
|
157
|
+
@ds.load_instances(results)
|
158
|
+
else
|
159
|
+
@ds.load_instance(results)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def prepare(type, name, *values)
|
165
|
+
ps = @dataset.prepare(type, name, *values)
|
166
|
+
PreparedStatement.new(name, self, ps)
|
167
|
+
end
|
168
|
+
|
169
|
+
def db
|
170
|
+
@dataset.db
|
171
|
+
end
|
172
|
+
|
146
173
|
def qualify_to_first_source
|
147
174
|
@dataset = @dataset.qualify_to_first_source
|
148
175
|
self
|
@@ -156,9 +183,11 @@ module Spontaneous
|
|
156
183
|
@dataset.sql
|
157
184
|
end
|
158
185
|
|
159
|
-
|
186
|
+
def unfiltered
|
187
|
+
@dataset.unfiltered
|
188
|
+
end
|
160
189
|
|
161
|
-
|
190
|
+
alias_method :sql, :to_sql
|
162
191
|
|
163
192
|
def get_raw(id)
|
164
193
|
@dataset.first(id: id)
|
@@ -2,11 +2,11 @@ module Spontaneous
|
|
2
2
|
module DataMapper
|
3
3
|
class Scope
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@identity_map
|
9
|
-
@schema_types
|
5
|
+
def initialize(dataset, schema)
|
6
|
+
@dataset = dataset
|
7
|
+
@schema = schema
|
8
|
+
@identity_map = {}
|
9
|
+
@schema_types = @schema.types
|
10
10
|
end
|
11
11
|
|
12
12
|
def count(types = nil)
|
@@ -125,16 +125,27 @@ module Spontaneous
|
|
125
125
|
dataset(types).select(*columns, &block)
|
126
126
|
end
|
127
127
|
|
128
|
+
def prepare(type, name, *values, &block)
|
129
|
+
prepared_statements[name] ||= begin
|
130
|
+
ds = block.call
|
131
|
+
ds.prepare(type, name, *values)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def prepared_statements
|
136
|
+
@prepared_statements ||= {}
|
137
|
+
end
|
138
|
+
|
128
139
|
def schema_uid(id_string)
|
129
140
|
@schema.uids[id_string]
|
130
141
|
end
|
131
142
|
|
132
143
|
def columns
|
133
|
-
@
|
144
|
+
@dataset.columns
|
134
145
|
end
|
135
146
|
|
136
147
|
def qualify_column(col)
|
137
|
-
|
148
|
+
Sequel::SQL::QualifiedIdentifier.new(@dataset.first_source, col)
|
138
149
|
end
|
139
150
|
|
140
151
|
def each(&block)
|
@@ -150,29 +161,25 @@ module Spontaneous
|
|
150
161
|
end
|
151
162
|
|
152
163
|
def pk
|
153
|
-
@
|
164
|
+
@dataset.db.primary_key(@dataset.first_source).to_sym
|
154
165
|
end
|
155
166
|
|
156
167
|
def table_name
|
157
|
-
naked_dataset.
|
168
|
+
naked_dataset.first_source_table
|
158
169
|
end
|
159
170
|
|
160
171
|
def logger
|
161
|
-
@
|
172
|
+
@dataset.logger
|
162
173
|
end
|
163
174
|
|
164
175
|
def logger=(logger)
|
165
|
-
@
|
176
|
+
@dataset.db.logger = logger
|
166
177
|
end
|
167
178
|
|
168
179
|
def revision
|
169
180
|
self
|
170
181
|
end
|
171
182
|
|
172
|
-
def visible_only?
|
173
|
-
@visible || false
|
174
|
-
end
|
175
|
-
|
176
183
|
def dataset(types = nil, fallback_type_condition = all_types_condition)
|
177
184
|
Dataset.new(table_dataset(types, fallback_type_condition), @schema, @identity_map)
|
178
185
|
end
|
@@ -184,17 +191,27 @@ module Spontaneous
|
|
184
191
|
private
|
185
192
|
|
186
193
|
def table_dataset(types, fallback_type_condition)
|
187
|
-
|
194
|
+
conditions = conditions(types, fallback_type_condition)
|
195
|
+
return naked_dataset.filter(conditions)
|
196
|
+
ds = nil
|
197
|
+
unless (ds = cached_datasets[conditions])
|
198
|
+
p [:new_dataset, conditions]
|
199
|
+
cached_datasets[conditions] = ds = naked_dataset.filter(conditions)
|
200
|
+
end
|
201
|
+
p [:ds, ds]
|
202
|
+
ds
|
203
|
+
end
|
204
|
+
|
205
|
+
def cached_datasets
|
206
|
+
@cached_datasets ||= {}
|
188
207
|
end
|
189
208
|
|
190
209
|
def naked_dataset
|
191
|
-
@
|
210
|
+
@dataset.dup
|
192
211
|
end
|
193
212
|
|
194
213
|
def conditions(types, fallback_type_condition)
|
195
|
-
|
196
|
-
cond[:hidden] = false if @visible
|
197
|
-
cond
|
214
|
+
type_conditions(types, fallback_type_condition)
|
198
215
|
end
|
199
216
|
|
200
217
|
def type_conditions(types, fallback_type_condition)
|
data/lib/spontaneous/errors.rb
CHANGED
data/lib/spontaneous/facet.rb
CHANGED
@@ -23,6 +23,16 @@ module Spontaneous
|
|
23
23
|
File.join(@root, path)
|
24
24
|
end
|
25
25
|
|
26
|
+
def path(*args)
|
27
|
+
Pathname.new(@root).join(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def path!(*args)
|
31
|
+
self.path(*args).tap do |path|
|
32
|
+
path.mkpath
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
def name
|
27
37
|
File.basename(root)
|
28
38
|
end
|
@@ -51,10 +61,12 @@ module Spontaneous
|
|
51
61
|
end
|
52
62
|
end
|
53
63
|
|
54
|
-
|
64
|
+
# use Rails' alphabetical load order for initializers
|
65
|
+
def run_initializers
|
55
66
|
paths.expanded(:config).each do |config_path|
|
56
|
-
|
57
|
-
|
67
|
+
Dir["#{config_path / "initializers"}/*.rb"].sort.each do |initializer|
|
68
|
+
require initializer
|
69
|
+
end
|
58
70
|
end
|
59
71
|
end
|
60
72
|
|
@@ -81,13 +93,11 @@ module Spontaneous
|
|
81
93
|
|
82
94
|
def loaders
|
83
95
|
@loaders ||= \
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
end
|
96
|
+
begin
|
97
|
+
use_reloader = config.reload_classes
|
98
|
+
{:schema => Spontaneous::SchemaLoader.new(schema_load_paths, use_reloader),
|
99
|
+
:lib => Spontaneous::Loader.new(load_paths, use_reloader) }
|
100
|
+
end
|
91
101
|
end
|
92
102
|
|
93
103
|
def load_paths
|
@@ -56,12 +56,14 @@ module Spontaneous
|
|
56
56
|
end
|
57
57
|
|
58
58
|
extend ClassMethods
|
59
|
+
include Spontaneous::Model::Core::ContentHash::FieldMethods
|
59
60
|
|
60
61
|
attr_accessor :owner, :name, :unprocessed_value, :template_params, :version
|
61
62
|
attr_accessor :prototype
|
62
63
|
|
63
64
|
|
64
65
|
def initialize(params={}, default_values=true)
|
66
|
+
@default_values = default_values
|
65
67
|
@processed_values = {}
|
66
68
|
deserialize(params, default_values)
|
67
69
|
@values = nil
|
@@ -331,10 +333,14 @@ module Spontaneous
|
|
331
333
|
value(format)
|
332
334
|
end
|
333
335
|
|
336
|
+
alias_method :render_inline, :render
|
337
|
+
|
334
338
|
def render_using(renderer, format = :html, locals = {}, *args)
|
335
339
|
render(format, locals)
|
336
340
|
end
|
337
341
|
|
342
|
+
alias_method :render_inline_using, :render_using
|
343
|
+
|
338
344
|
def to_html(locals = {})
|
339
345
|
value(:html)
|
340
346
|
end
|
@@ -358,7 +364,7 @@ module Spontaneous
|
|
358
364
|
end
|
359
365
|
|
360
366
|
def modified?
|
361
|
-
@modified
|
367
|
+
@modified || false
|
362
368
|
end
|
363
369
|
|
364
370
|
def schema_id
|
@@ -437,6 +443,7 @@ module Spontaneous
|
|
437
443
|
:version => version,
|
438
444
|
:value => @initial_value,
|
439
445
|
:user => owner.current_editor)
|
446
|
+
mark_unmodified
|
440
447
|
end
|
441
448
|
|
442
449
|
def <=>(o)
|