spontaneous 0.2.0.alpha7 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -4
- data/Readme.markdown +1 -1
- data/application/css/definitions.css.scss +5 -0
- data/application/css/dialogue.css.scss +62 -0
- data/application/js/content.js +1 -1
- data/application/js/dom.js +1 -1
- data/application/js/event_source.js +3 -0
- data/application/js/{field_types/date_field.js → field/date.js} +2 -2
- data/application/js/{field_types/file_field.js → field/file.js} +2 -2
- data/application/js/{field_types/image_field.js → field/image.js} +54 -20
- data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
- data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
- data/application/js/{field_types/select_field.js → field/select.js} +2 -2
- data/application/js/{field_types/string_field.js → field/string.js} +21 -7
- data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
- data/application/js/field.js +2 -2
- data/application/js/publish.js +99 -19
- data/application/js/spontaneous.js +8 -8
- data/application/js/top_bar.js +6 -4
- data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
- data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
- data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
- data/lib/spontaneous/box.rb +53 -18
- data/lib/spontaneous/box_style.rb +2 -3
- data/lib/spontaneous/change.rb +39 -13
- data/lib/spontaneous/cli/fields.rb +29 -0
- data/lib/spontaneous/cli/init.rb +2 -2
- data/lib/spontaneous/cli/migrate.rb +0 -1
- data/lib/spontaneous/cli/server.rb +14 -10
- data/lib/spontaneous/cli/site.rb +20 -9
- data/lib/spontaneous/cli.rb +8 -6
- data/lib/spontaneous/collections/box_set.rb +11 -0
- data/lib/spontaneous/collections/field_set.rb +24 -1
- data/lib/spontaneous/concern.rb +37 -0
- data/lib/spontaneous/config.rb +3 -4
- data/lib/spontaneous/crypt/version.rb +130 -0
- data/lib/spontaneous/crypt.rb +84 -0
- data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
- data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
- data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
- data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
- data/lib/spontaneous/data_mapper/content_model.rb +343 -0
- data/lib/spontaneous/data_mapper/content_table.rb +103 -0
- data/lib/spontaneous/data_mapper/dataset.rb +194 -0
- data/lib/spontaneous/data_mapper/scope.rb +195 -0
- data/lib/spontaneous/data_mapper.rb +161 -0
- data/lib/spontaneous/facet.rb +2 -2
- data/lib/spontaneous/field/base.rb +418 -0
- data/lib/spontaneous/field/date.rb +54 -0
- data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
- data/lib/spontaneous/field/file.rb +100 -0
- data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
- data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
- data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
- data/lib/spontaneous/field/markdown.rb +36 -0
- data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
- data/lib/spontaneous/field/string.rb +17 -0
- data/lib/spontaneous/field/update.rb +156 -0
- data/lib/spontaneous/field/webvideo.rb +310 -0
- data/lib/spontaneous/field.rb +80 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
- data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
- data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
- data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
- data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
- data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
- data/lib/spontaneous/generators/site.rb +4 -3
- data/lib/spontaneous/image_size.rb +8 -1
- data/lib/spontaneous/layout.rb +5 -1
- data/lib/spontaneous/loader.rb +2 -5
- data/lib/spontaneous/media/file.rb +11 -2
- data/lib/spontaneous/media/temp_file.rb +23 -0
- data/lib/spontaneous/media.rb +20 -39
- data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
- data/lib/spontaneous/model/box.rb +18 -0
- data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
- data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
- data/lib/spontaneous/model/core/editor_class.rb +4 -0
- data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
- data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
- data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
- data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
- data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
- data/lib/spontaneous/model/core/page_search.rb +36 -0
- data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
- data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
- data/lib/spontaneous/model/core/schema_id.rb +65 -0
- data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
- data/lib/spontaneous/model/core.rb +143 -0
- data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
- data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
- data/lib/spontaneous/model/page/locks.rb +14 -0
- data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
- data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
- data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
- data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
- data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
- data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
- data/lib/spontaneous/model.rb +97 -0
- data/lib/spontaneous/output/context.rb +1 -1
- data/lib/spontaneous/output/format.rb +4 -0
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/output.rb +2 -2
- data/lib/spontaneous/page_lock.rb +62 -0
- data/lib/spontaneous/page_piece.rb +1 -1
- data/lib/spontaneous/permissions/access_key.rb +9 -4
- data/lib/spontaneous/permissions/user.rb +19 -9
- data/lib/spontaneous/permissions.rb +2 -5
- data/lib/spontaneous/plugins/application/facets.rb +1 -2
- data/lib/spontaneous/plugins/application/features.rb +1 -1
- data/lib/spontaneous/plugins/application/paths.rb +1 -1
- data/lib/spontaneous/plugins/application/render.rb +1 -1
- data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
- data/lib/spontaneous/plugins/application/state.rb +30 -1
- data/lib/spontaneous/plugins/application/system.rb +12 -12
- data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
- data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
- data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
- data/lib/spontaneous/publishing/immediate.rb +77 -49
- data/lib/spontaneous/publishing/revision.rb +355 -0
- data/lib/spontaneous/publishing/simultaneous.rb +10 -49
- data/lib/spontaneous/publishing.rb +1 -0
- data/lib/spontaneous/rack/around_back.rb +1 -1
- data/lib/spontaneous/rack/around_front.rb +2 -4
- data/lib/spontaneous/rack/around_preview.rb +1 -1
- data/lib/spontaneous/rack/back.rb +80 -63
- data/lib/spontaneous/rack/cacheable_file.rb +2 -2
- data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/helpers.rb +8 -9
- data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
- data/lib/spontaneous/rack/public.rb +3 -3
- data/lib/spontaneous/rack.rb +15 -15
- data/lib/spontaneous/schema/uid.rb +4 -1
- data/lib/spontaneous/schema.rb +57 -24
- data/lib/spontaneous/search/database.rb +12 -1
- data/lib/spontaneous/search/index.rb +34 -6
- data/lib/spontaneous/search/results.rb +1 -1
- data/lib/spontaneous/server.rb +3 -3
- data/lib/spontaneous/simultaneous.rb +53 -0
- data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
- data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
- data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
- data/lib/spontaneous/site/publishing.rb +89 -0
- data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
- data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
- data/lib/spontaneous/site.rb +31 -14
- data/lib/spontaneous/state.rb +5 -6
- data/lib/spontaneous/style.rb +3 -2
- data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
- data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +34 -89
- data/spontaneous.gemspec +112 -114
- data/test/experimental/test_crypt.rb +158 -0
- data/test/experimental/test_features.rb +3 -3
- data/test/fixtures/example_application/config/environments/development.rb +1 -1
- data/test/fixtures/example_application/lib/content.rb +5 -0
- data/test/fixtures/example_application/schema/page.rb +2 -1
- data/test/fixtures/example_application/schema/piece.rb +3 -2
- data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
- data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
- data/test/functional/test_application.rb +12 -1
- data/test/functional/test_back.rb +80 -48
- data/test/functional/test_front.rb +39 -46
- data/test/functional/test_user_manager.rb +3 -9
- data/test/javascript/test_markdown.rb +2 -2
- data/test/test_helper.rb +78 -23
- data/test/unit/test_alias.rb +21 -15
- data/test/unit/test_asset_bundler.rb +3 -3
- data/test/unit/test_assets.rb +2 -2
- data/test/unit/test_async.rb +7 -6
- data/test/unit/test_authentication.rb +43 -37
- data/test/unit/test_boxes.rb +46 -21
- data/test/unit/test_changesets.rb +65 -20
- data/test/unit/test_config.rb +9 -9
- data/test/unit/test_content.rb +50 -51
- data/test/unit/test_content_inheritance.rb +6 -20
- data/test/unit/test_datamapper.rb +1330 -0
- data/test/unit/test_datamapper_content.rb +214 -0
- data/test/unit/test_fields.rb +543 -54
- data/test/unit/test_formats.rb +2 -3
- data/test/unit/test_generators.rb +6 -6
- data/test/unit/test_helpers.rb +1 -1
- data/test/unit/test_image_size.rb +10 -5
- data/test/unit/test_images.rb +17 -18
- data/test/unit/test_layouts.rb +18 -3
- data/test/unit/test_media.rb +74 -49
- data/test/unit/test_modifications.rb +43 -43
- data/test/unit/test_page.rb +7 -10
- data/test/unit/test_permissions.rb +3 -10
- data/test/unit/test_piece.rb +5 -6
- data/test/unit/test_plugins.rb +7 -14
- data/test/unit/test_prototypes.rb +3 -3
- data/test/unit/test_publishing.rb +49 -27
- data/test/unit/test_render.rb +46 -15
- data/test/unit/test_revisions.rb +124 -127
- data/test/unit/test_schema.rb +53 -58
- data/test/unit/test_search.rb +64 -16
- data/test/unit/test_serialisation.rb +4 -11
- data/test/unit/test_site.rb +11 -12
- data/test/unit/test_structure.rb +2 -5
- data/test/unit/test_styles.rb +22 -24
- data/test/unit/test_type_hierarchy.rb +7 -5
- data/test/unit/test_visibility.rb +79 -55
- metadata +128 -102
- data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
- data/lib/sequel/plugins/scoped_table_name.rb +0 -54
- data/lib/spontaneous/content.rb +0 -129
- data/lib/spontaneous/field_types/date_field.rb +0 -56
- data/lib/spontaneous/field_types/field.rb +0 -302
- data/lib/spontaneous/field_types/file_field.rb +0 -68
- data/lib/spontaneous/field_types/markdown_field.rb +0 -38
- data/lib/spontaneous/field_types/string_field.rb +0 -19
- data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
- data/lib/spontaneous/field_types.rb +0 -38
- data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
- data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
- data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
- data/lib/spontaneous/plugins/page_search.rb +0 -63
- data/lib/spontaneous/plugins/schema_id.rb +0 -68
- data/lib/spontaneous/plugins/site/publishing.rb +0 -75
- data/lib/spontaneous/rack/fiber_pool.rb +0 -26
- data/test/unit/test_table_scoping.rb +0 -80
@@ -32,6 +32,7 @@ module Spontaneous::Search
|
|
32
32
|
def exclude_types(*types)
|
33
33
|
@search_types -= resolve_type_list(types)
|
34
34
|
end
|
35
|
+
|
35
36
|
# end Index DSL methods
|
36
37
|
|
37
38
|
def create_db(revision)
|
@@ -61,25 +62,52 @@ module Spontaneous::Search
|
|
61
62
|
@stopper
|
62
63
|
end
|
63
64
|
|
65
|
+
def weights(page)
|
66
|
+
weights = {}
|
67
|
+
each_field(page) do |field, prototype, id|
|
68
|
+
weights[id] = prototype.options_for_index(self)[:weight]
|
69
|
+
end
|
70
|
+
weights
|
71
|
+
end
|
72
|
+
|
64
73
|
# Extract all indexable content from a page. Values are grouped across fields
|
65
74
|
# or across field index groups
|
66
75
|
def indexable_content(page)
|
67
76
|
values = Hash.new { |h, k| h[k] = [] }
|
77
|
+
each_indexable(page) do |content|
|
78
|
+
content.fields.each do |field|
|
79
|
+
prototype = field.prototype
|
80
|
+
if prototype.in_index?(self)
|
81
|
+
values[prototype.index_id(self)] << field.indexable_value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
insert_additional_indexable_values(content, values)
|
85
|
+
end
|
86
|
+
result = Hash[ values.map { |id, values| [id, values.join("\n")] } ]
|
87
|
+
result[:id] = page.id
|
88
|
+
result
|
89
|
+
end
|
90
|
+
|
91
|
+
def each_indexable(page)
|
92
|
+
indexable = [page]
|
68
93
|
# not sure that I need the include? test here as page.content only returns Pieces
|
69
94
|
# and I'm not sure that there is a particular need to exclude Pieces from indexes
|
70
|
-
indexable = [page]
|
71
95
|
indexable.concat(page.pieces.select { |content| include?(content) })
|
72
96
|
indexable += page.boxes.select { |box| include?(box) }
|
73
97
|
indexable.each do |content|
|
98
|
+
yield content
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def each_field(page)
|
103
|
+
each_indexable(page) do |content|
|
74
104
|
content.fields.each do |field|
|
75
105
|
prototype = field.prototype
|
76
|
-
|
106
|
+
if prototype.in_index?(self)
|
107
|
+
yield field, prototype, prototype.index_id(self)
|
108
|
+
end
|
77
109
|
end
|
78
|
-
insert_additional_indexable_values(content, values)
|
79
110
|
end
|
80
|
-
result = Hash[ values.map { |id, values| [id, values.join("\n")] } ]
|
81
|
-
result[:id] = page.id
|
82
|
-
result
|
83
111
|
end
|
84
112
|
|
85
113
|
def insert_additional_indexable_values(content, values)
|
data/lib/spontaneous/server.rb
CHANGED
@@ -13,9 +13,9 @@ module Spontaneous
|
|
13
13
|
|
14
14
|
|
15
15
|
def self.run!(options={})
|
16
|
-
host = options["host"] || Site.config.host || "0.0.0.0"
|
17
|
-
port = options["port"] || Site.config.port || 2012
|
18
|
-
adapter = options["adapter"] || Site.config.adapter
|
16
|
+
host = options["host"] || Spontaneous::Site.config.host || "0.0.0.0"
|
17
|
+
port = options["port"] || Spontaneous::Site.config.port || 2012
|
18
|
+
adapter = options["adapter"] || Spontaneous::Site.config.adapter
|
19
19
|
|
20
20
|
handler = nil
|
21
21
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'simultaneous'
|
2
|
+
|
3
|
+
module Spontaneous
|
4
|
+
module Simultaneous
|
5
|
+
|
6
|
+
class Error < Spontaneous::Error; end
|
7
|
+
|
8
|
+
module ModuleMethods
|
9
|
+
def simultaneous_setup
|
10
|
+
::Simultaneous.client_mode = :async
|
11
|
+
::Simultaneous.connection = ::Spontaneous.config.simultaneous_connection
|
12
|
+
::Simultaneous.domain = ::Spontaneous.config.site_domain
|
13
|
+
end
|
14
|
+
|
15
|
+
def register(task_name, task, options = {}, params = {}, env = {})
|
16
|
+
options.update({
|
17
|
+
:pwd => root
|
18
|
+
})
|
19
|
+
params.update({
|
20
|
+
"site" => root,
|
21
|
+
"environment" => Spontaneous.env
|
22
|
+
})
|
23
|
+
::Simultaneous.add_task(task_name, binary(task), options, params, env)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fire(task_name, params = {})
|
27
|
+
::Simultaneous.fire(task_name, params)
|
28
|
+
rescue Exception => e
|
29
|
+
raise Error, e
|
30
|
+
end
|
31
|
+
|
32
|
+
def spot_binary
|
33
|
+
::Spontaneous.config.spontaneous_binary || default_spot_binary
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_spot_binary
|
37
|
+
(Pathname.new(Spontaneous.gem_dir) + "bin/spot").expand_path.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def binary(task)
|
41
|
+
[spot_binary, task].join(" ")
|
42
|
+
end
|
43
|
+
|
44
|
+
def root
|
45
|
+
Pathname.new(Spontaneous.root).expand_path.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
extend ModuleMethods
|
50
|
+
|
51
|
+
simultaneous_setup
|
52
|
+
end
|
53
|
+
end
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
class Spontaneous::Site
|
4
4
|
module Instance
|
5
|
-
extend
|
5
|
+
extend Spontaneous::Concern
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
@@instance = nil
|
11
|
-
|
12
10
|
def instantiate(root, env, mode)
|
13
|
-
|
11
|
+
Thread.current[:spontaneous_site_instance] = Spontaneous::Site.new(root, env, mode)
|
14
12
|
end
|
15
13
|
|
16
14
|
def instance
|
17
|
-
|
15
|
+
Thread.current[:spontaneous_site_instance]
|
18
16
|
end
|
19
17
|
|
20
18
|
def_delegators :instance, :config, :database, :database=
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
class Spontaneous::Site
|
4
4
|
module Map
|
5
|
-
extend
|
5
|
+
extend Spontaneous::Concern
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
def map(root_id=nil)
|
9
9
|
page = \
|
10
10
|
if root_id.nil?
|
11
|
-
|
11
|
+
content_model::Page.root
|
12
12
|
else
|
13
|
-
|
13
|
+
content_model.get root_id
|
14
14
|
end
|
15
15
|
return nil unless page
|
16
16
|
page.map_entry
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class Spontaneous::Site
|
4
|
+
module Publishing
|
5
|
+
extend Spontaneous::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def content_model
|
9
|
+
Spontaneous::Content
|
10
|
+
end
|
11
|
+
|
12
|
+
def background_mode
|
13
|
+
@background_mode ||= (Spontaneous::Site.config.background_mode || :immediate)
|
14
|
+
end
|
15
|
+
|
16
|
+
def background_mode=(method)
|
17
|
+
@background_mode = method
|
18
|
+
end
|
19
|
+
|
20
|
+
def resolve_background_mode(mod)
|
21
|
+
klass_name = background_mode.to_s.camelize
|
22
|
+
begin
|
23
|
+
mod.const_get(klass_name)
|
24
|
+
rescue NameError => e
|
25
|
+
puts "Unknown method #{method} (#{mod}::#{klass_name})"
|
26
|
+
mod::Immediate
|
27
|
+
rescue NameError => e
|
28
|
+
raise "Illegal background mode #{mod}::Immediate"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def publishing_method
|
33
|
+
resolve_background_mode(Spontaneous::Publishing)
|
34
|
+
end
|
35
|
+
|
36
|
+
def publish_pages(page_list=nil)
|
37
|
+
publishing_method.new(self.revision, content_model).publish_pages(page_list)
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish_all
|
41
|
+
publishing_method.new(self.revision, content_model).publish_all
|
42
|
+
end
|
43
|
+
|
44
|
+
def rerender
|
45
|
+
publishing_method.new(self.published_revision, content_model).rerender_revision
|
46
|
+
end
|
47
|
+
|
48
|
+
def publishing_status
|
49
|
+
status = rest = nil
|
50
|
+
# if r = S::Site.pending_revision
|
51
|
+
status, *rest = publishing_method.status.split(':')
|
52
|
+
rest = rest.join(':')
|
53
|
+
# end
|
54
|
+
Hash[[:status, :progress].zip([status, rest])] rescue ""
|
55
|
+
end
|
56
|
+
|
57
|
+
def publishing_status=(status)
|
58
|
+
publishing_method.status = status
|
59
|
+
end
|
60
|
+
|
61
|
+
def with_published(&block)
|
62
|
+
Spontaneous::Content.scope(published_revision, true, &block)
|
63
|
+
end
|
64
|
+
|
65
|
+
def with_editable(&block)
|
66
|
+
Spontaneous::Content.scope(nil, false, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
def with_preview(&block)
|
70
|
+
Spontaneous::Content.scope(nil, true, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
def set_published_revision(revision)
|
76
|
+
instance = S::State.instance
|
77
|
+
instance.published_revision = revision
|
78
|
+
instance.revision = revision + 1
|
79
|
+
instance.save
|
80
|
+
end
|
81
|
+
|
82
|
+
def pending_revision=(revision)
|
83
|
+
instance = S::State.instance
|
84
|
+
instance.pending_revision = revision
|
85
|
+
instance.save
|
86
|
+
end
|
87
|
+
end # ClassMethods
|
88
|
+
end # Publishing
|
89
|
+
end # Spontaneous::Plugins::Site
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
class Spontaneous::Site
|
4
4
|
module Schema
|
5
|
-
extend
|
5
|
+
extend Spontaneous::Concern
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
def schema
|
@@ -15,7 +15,7 @@ module Spontaneous::Plugins::Site
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def schema_id(obj)
|
18
|
-
schema.
|
18
|
+
schema.to_id(obj)
|
19
19
|
end
|
20
20
|
|
21
21
|
def schema
|
@@ -27,7 +27,7 @@ module Spontaneous::Plugins::Site
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def schema_loader_class=(loader_class)
|
30
|
-
@schema_loader_class = loader_class
|
30
|
+
schema.schema_loader_class = (@schema_loader_class = loader_class)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -1,12 +1,20 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
class Spontaneous::Site
|
4
4
|
module Selectors
|
5
|
-
extend
|
5
|
+
extend Spontaneous::Concern
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
def root
|
9
|
-
|
8
|
+
def root(content_model = Spontaneous::Content)
|
9
|
+
content_model.root
|
10
|
+
end
|
11
|
+
|
12
|
+
def pages(content_model = Spontaneous::Content)
|
13
|
+
pages_dataset(content_model).all
|
14
|
+
end
|
15
|
+
|
16
|
+
def pages_dataset(content_model = Spontaneous::Content)
|
17
|
+
content_model::Page.order(:depth)
|
10
18
|
end
|
11
19
|
|
12
20
|
def [](path_or_uid)
|
@@ -23,15 +31,15 @@ module Spontaneous::Plugins::Site
|
|
23
31
|
end
|
24
32
|
|
25
33
|
def by_id(id)
|
26
|
-
Spontaneous::
|
34
|
+
Spontaneous::Content[id]
|
27
35
|
end
|
28
36
|
|
29
37
|
def by_path(path)
|
30
|
-
Spontaneous::
|
38
|
+
Spontaneous::Content.path(path)
|
31
39
|
end
|
32
40
|
|
33
41
|
def by_uid(uid)
|
34
|
-
Spontaneous::
|
42
|
+
Spontaneous::Content.uid(uid)
|
35
43
|
end
|
36
44
|
|
37
45
|
def method_missing(method, *args)
|
data/lib/spontaneous/site.rb
CHANGED
@@ -1,21 +1,38 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
|
3
4
|
module Spontaneous
|
5
|
+
|
4
6
|
class Site < Spontaneous::Facet
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
require "spontaneous/site/features"
|
8
|
+
require "spontaneous/site/helpers"
|
9
|
+
require "spontaneous/site/hooks"
|
10
|
+
require "spontaneous/site/instance"
|
11
|
+
require "spontaneous/site/level"
|
12
|
+
require "spontaneous/site/map"
|
13
|
+
require "spontaneous/site/paths"
|
14
|
+
require "spontaneous/site/publishing"
|
15
|
+
require "spontaneous/site/schema"
|
16
|
+
require "spontaneous/site/search"
|
17
|
+
require "spontaneous/site/selectors"
|
18
|
+
require "spontaneous/site/state"
|
19
|
+
require "spontaneous/site/storage"
|
20
|
+
require "spontaneous/site/url"
|
21
|
+
|
22
|
+
include Features
|
23
|
+
include Helpers
|
24
|
+
include Hooks
|
25
|
+
include Instance
|
26
|
+
include Level
|
27
|
+
include Map
|
28
|
+
include Paths
|
29
|
+
include Publishing
|
30
|
+
include Schema
|
31
|
+
include Search
|
32
|
+
include Selectors
|
33
|
+
include State
|
34
|
+
include Storage
|
35
|
+
include URL
|
19
36
|
|
20
37
|
attr_accessor :database
|
21
38
|
attr_reader :environment, :mode
|
data/lib/spontaneous/state.rb
CHANGED
@@ -8,12 +8,11 @@ module Spontaneous
|
|
8
8
|
end
|
9
9
|
|
10
10
|
|
11
|
-
@@instance = nil
|
12
|
-
|
13
11
|
class << self
|
14
12
|
|
15
13
|
def instance
|
16
|
-
|
14
|
+
current = Thread.current[:spontaneous_state_instance]
|
15
|
+
return current if current
|
17
16
|
unless instance = self.first
|
18
17
|
instance = State.create(:revision => 1, :published_revision => 0)
|
19
18
|
end
|
@@ -21,11 +20,11 @@ module Spontaneous
|
|
21
20
|
end
|
22
21
|
|
23
22
|
# def with_cache(&block)
|
24
|
-
# yield if
|
25
|
-
#
|
23
|
+
# yield if Thread.current[:spontaneous_state_instance]
|
24
|
+
# Thread.current[:spontaneous_state_instance] = self.instance
|
26
25
|
# yield
|
27
26
|
# ensure
|
28
|
-
#
|
27
|
+
# Thread.current[:spontaneous_state_instance] = nil
|
29
28
|
# end
|
30
29
|
|
31
30
|
def working_revision
|
data/lib/spontaneous/style.rb
CHANGED
@@ -40,7 +40,7 @@ module Spontaneous
|
|
40
40
|
|
41
41
|
def local_template(format)
|
42
42
|
template_path = nil
|
43
|
-
Site.paths(:templates).each do |template_root|
|
43
|
+
Spontaneous::Site.paths(:templates).each do |template_root|
|
44
44
|
template_path = try_template_paths.detect do |path|
|
45
45
|
Spontaneous::Output.template_exists?(template_root, path, format)
|
46
46
|
end
|
@@ -83,6 +83,7 @@ module Spontaneous
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def name
|
86
|
+
return "<default>" if prototype.nil?
|
86
87
|
prototype.name
|
87
88
|
end
|
88
89
|
|
@@ -96,7 +97,7 @@ module Spontaneous
|
|
96
97
|
end
|
97
98
|
|
98
99
|
def owner_directory_names
|
99
|
-
classes = [owner].concat(owner.ancestors.take_while { |klass| klass <
|
100
|
+
classes = [owner].concat(owner.ancestors.take_while { |klass| klass < owner.content_model::Page or klass < owner.content_model::Piece })
|
100
101
|
classes.map { |klass| self.class.to_directory_name(klass) }
|
101
102
|
end
|
102
103
|
|
@@ -3,6 +3,7 @@ module Spontaneous
|
|
3
3
|
module Utils
|
4
4
|
module Database
|
5
5
|
class MySQLDumper
|
6
|
+
|
6
7
|
def initialize(database)
|
7
8
|
@database = database
|
8
9
|
end
|
@@ -39,6 +40,7 @@ module Spontaneous
|
|
39
40
|
option(:password),
|
40
41
|
option(:user),
|
41
42
|
option(:default_character_set),
|
43
|
+
option(:ignore_table),
|
42
44
|
database_name
|
43
45
|
]
|
44
46
|
unless tables.nil?
|
@@ -49,6 +51,7 @@ module Spontaneous
|
|
49
51
|
|
50
52
|
command = %(mysqldump #{options.join(" ")} > #{path} )
|
51
53
|
end
|
54
|
+
|
52
55
|
def database_name
|
53
56
|
@database.opts[:database]
|
54
57
|
end
|
@@ -65,6 +68,16 @@ module Spontaneous
|
|
65
68
|
"UTF8"
|
66
69
|
end
|
67
70
|
|
71
|
+
def ignore_table
|
72
|
+
[database_name, revision_archive_table].join(".")
|
73
|
+
end
|
74
|
+
|
75
|
+
# The whole point of this table's existance is to reduce the
|
76
|
+
# size of the db dump for syncing
|
77
|
+
def revision_archive_table
|
78
|
+
Spontaneous::Content.revision_archive_dataset.first_source.to_s
|
79
|
+
end
|
80
|
+
|
68
81
|
def option(option, add_if_nil=false)
|
69
82
|
value = self.send(option)
|
70
83
|
if !value.nil? or add_if_nil
|
@@ -45,6 +45,7 @@ module Spontaneous
|
|
45
45
|
option(:password),
|
46
46
|
option(:username),
|
47
47
|
option(:encoding),
|
48
|
+
option(:exclude_table),
|
48
49
|
database_name
|
49
50
|
]
|
50
51
|
unless tables.nil?
|
@@ -71,6 +72,10 @@ module Spontaneous
|
|
71
72
|
def encoding
|
72
73
|
"UTF8"
|
73
74
|
end
|
75
|
+
|
76
|
+
def exclude_table
|
77
|
+
revision_archive_table
|
78
|
+
end
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|