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
@@ -4,15 +4,13 @@ class Spontaneous::Site
|
|
4
4
|
module Level
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Spontaneous::Site.root.at_depth(1)
|
14
|
-
end
|
7
|
+
def at_depth(level)
|
8
|
+
case level
|
9
|
+
when 0, :root, :home
|
10
|
+
home
|
11
|
+
when 1, :section
|
12
|
+
home.at_depth(1)
|
15
13
|
end
|
16
|
-
end
|
14
|
+
end
|
17
15
|
end # Level
|
18
16
|
end
|
data/lib/spontaneous/site/map.rb
CHANGED
@@ -4,17 +4,15 @@ class Spontaneous::Site
|
|
4
4
|
module Map
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
content_model.get root_id
|
14
|
-
end
|
15
|
-
return nil unless page
|
16
|
-
page.map_entry
|
7
|
+
def map(root_id=nil)
|
8
|
+
page = \
|
9
|
+
if root_id.nil?
|
10
|
+
model::Page.root
|
11
|
+
else
|
12
|
+
model.get root_id
|
17
13
|
end
|
18
|
-
|
14
|
+
return nil unless page
|
15
|
+
page.map_entry
|
16
|
+
end
|
19
17
|
end # Map
|
20
18
|
end
|
@@ -4,10 +4,10 @@ class Spontaneous::Site
|
|
4
4
|
module Paths
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
def paths(*args)
|
8
|
+
return _paths if args.empty?
|
9
|
+
group = args.first
|
10
|
+
facets.flat_map { |facet| facet._paths.expanded(group) }
|
11
|
+
end
|
12
12
|
end # Paths
|
13
13
|
end
|
@@ -4,86 +4,89 @@ class Spontaneous::Site
|
|
4
4
|
module Publishing
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def background_mode
|
8
|
+
@background_mode ||= (config.background_mode || :immediate)
|
9
|
+
end
|
10
|
+
|
11
|
+
def background_mode=(method)
|
12
|
+
@background_mode = method
|
13
|
+
end
|
14
|
+
|
15
|
+
def resolve_background_mode(mod)
|
16
|
+
klass_name = background_mode.to_s.camelize
|
17
|
+
begin
|
18
|
+
mod.const_get(klass_name)
|
19
|
+
rescue NameError => e
|
20
|
+
puts "Unknown method #{method} (#{mod}::#{klass_name})"
|
21
|
+
mod::Immediate
|
22
|
+
rescue NameError => e
|
23
|
+
raise "Illegal background mode #{mod}::Immediate"
|
10
24
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
25
|
+
end
|
26
|
+
|
27
|
+
def publishing_method
|
28
|
+
resolve_background_mode(Spontaneous::Publishing)
|
29
|
+
end
|
30
|
+
|
31
|
+
def output_store(*args)
|
32
|
+
return current_output_store if args.empty?
|
33
|
+
@output_store = Spontaneous::Output::Store.new(*args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def current_output_store
|
37
|
+
@output_store ||= Spontaneous::Output::Store.new(:File, root: revision_root)
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish_pages(page_list=nil)
|
41
|
+
publishing_method.new(self, self.revision).publish_pages(page_list)
|
42
|
+
end
|
43
|
+
|
44
|
+
def publish_all
|
45
|
+
publishing_method.new(self, self.revision).publish_all
|
46
|
+
end
|
47
|
+
|
48
|
+
def rerender
|
49
|
+
publishing_method.new(self, self.published_revision).rerender_revision
|
50
|
+
end
|
51
|
+
|
52
|
+
def publishing_status
|
53
|
+
status = rest = nil
|
54
|
+
# if r = S::Site.pending_revision
|
55
|
+
status, *rest = publishing_method.status.split(':')
|
56
|
+
rest = rest.join(':')
|
57
|
+
# end
|
58
|
+
Hash[[:status, :progress].zip([status, rest])] rescue ""
|
59
|
+
end
|
60
|
+
|
61
|
+
def publishing_status=(status)
|
62
|
+
publishing_method.status = status
|
63
|
+
end
|
64
|
+
|
65
|
+
def with_published(&block)
|
66
|
+
Spontaneous::Content.scope(published_revision, true, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
def with_editable(&block)
|
70
|
+
Spontaneous::Content.scope(nil, false, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
def with_preview(&block)
|
74
|
+
Spontaneous::Content.scope(nil, true, &block)
|
75
|
+
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
def set_published_revision(revision)
|
80
|
+
instance = S::State.instance
|
81
|
+
instance.published_revision = revision
|
82
|
+
instance.revision = revision + 1
|
83
|
+
instance.save
|
84
|
+
end
|
85
|
+
|
86
|
+
def pending_revision=(revision)
|
87
|
+
instance = S::State.instance
|
88
|
+
instance.pending_revision = revision
|
89
|
+
instance.save
|
90
|
+
end
|
88
91
|
end # Publishing
|
89
92
|
end # Spontaneous::Plugins::Site
|
@@ -4,12 +4,6 @@ class Spontaneous::Site
|
|
4
4
|
module Schema
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
module ClassMethods
|
8
|
-
def schema
|
9
|
-
instance.schema
|
10
|
-
end
|
11
|
-
end # ClassMethods
|
12
|
-
|
13
7
|
def uid
|
14
8
|
schema.uids
|
15
9
|
end
|
@@ -19,7 +13,7 @@ class Spontaneous::Site
|
|
19
13
|
end
|
20
14
|
|
21
15
|
def schema
|
22
|
-
@schema ||= Spontaneous::Schema::Schema.new(root, schema_loader_class)
|
16
|
+
@schema ||= Spontaneous::Schema::Schema.new(self, root, schema_loader_class)
|
23
17
|
end
|
24
18
|
|
25
19
|
def schema_loader_class
|
@@ -4,24 +4,14 @@ class Spontaneous::Site
|
|
4
4
|
module Search
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def indexer(revision)
|
8
|
+
indexer = S::Search::CompoundIndexer.new(revision, indexes.values)
|
9
|
+
begin
|
10
|
+
yield(indexer)
|
11
|
+
ensure
|
12
|
+
indexer.close
|
10
13
|
end
|
11
|
-
|
12
|
-
def indexes
|
13
|
-
instance.indexes
|
14
|
-
end
|
15
|
-
|
16
|
-
def indexer(revision)
|
17
|
-
indexer = S::Search::CompoundIndexer.new(revision, indexes.values)
|
18
|
-
begin
|
19
|
-
yield(indexer)
|
20
|
-
ensure
|
21
|
-
indexer.close
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end # ClassMethods
|
14
|
+
end
|
25
15
|
|
26
16
|
def indexes
|
27
17
|
@indexes ||= {}
|
@@ -36,7 +26,7 @@ class Spontaneous::Site
|
|
36
26
|
end
|
37
27
|
|
38
28
|
def index(name, &definition)
|
39
|
-
index = S::Search::Index.new(name, &definition)
|
29
|
+
index = S::Search::Index.new(self, name, &definition)
|
40
30
|
self[name] = index
|
41
31
|
end
|
42
32
|
end
|
@@ -4,70 +4,76 @@ class Spontaneous::Site
|
|
4
4
|
module Selectors
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
def home
|
8
|
+
model.root
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
# roots returns the list of top-level pages
|
12
|
+
# Only one of these is publicly visible and this is mapped to the
|
13
|
+
# configured site domain.
|
14
|
+
#
|
15
|
+
# The rest are "hidden" roots.
|
16
|
+
def roots(user = nil)
|
17
|
+
domain = config.site_domain
|
18
|
+
roots = pages_dataset.where(depth: 0).all
|
19
|
+
pub, hidden = roots.partition { |p| p.root? }
|
20
|
+
map = {}
|
21
|
+
map[domain] = pub.first.id unless pub.empty?
|
22
|
+
hidden.each { |p| map[p.path] = p.id }
|
23
|
+
{ "public" => domain, "roots" => map }
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def pages
|
27
|
+
pages_dataset.all
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def pages_dataset
|
31
|
+
model::Page.order(:depth)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
ID_SELECTOR = /\A\d+\z/o
|
35
|
+
PATH_SELECTOR = /\A[\/#]/o
|
36
|
+
UID_SELECTOR = /\A\$/o
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
by_id(path_or_uid)
|
43
|
-
when PATH_PATH
|
44
|
-
by_path(path_or_uid)
|
45
|
-
when UID_PATH
|
46
|
-
by_uid(path_or_uid[1..-1])
|
47
|
-
else
|
48
|
-
by_uid(path_or_uid)
|
49
|
-
end
|
50
|
-
end
|
38
|
+
def [](selector)
|
39
|
+
fetch(selector)
|
40
|
+
end
|
51
41
|
|
52
|
-
|
53
|
-
|
42
|
+
def fetch(selector)
|
43
|
+
case selector
|
44
|
+
when Symbol
|
45
|
+
by_uid(selector.to_s)
|
46
|
+
when Fixnum
|
47
|
+
by_id(selector)
|
48
|
+
when ID_SELECTOR
|
49
|
+
by_id(selector)
|
50
|
+
when PATH_SELECTOR
|
51
|
+
by_path(selector)
|
52
|
+
when UID_SELECTOR
|
53
|
+
by_uid(selector[1..-1])
|
54
|
+
else
|
55
|
+
by_uid(selector)
|
54
56
|
end
|
57
|
+
end
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
def by_id(id)
|
60
|
+
model.id(id)
|
61
|
+
end
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
def by_path(path)
|
64
|
+
model.path(path)
|
65
|
+
end
|
66
|
+
|
67
|
+
def by_uid(uid)
|
68
|
+
model.uid(uid)
|
69
|
+
end
|
63
70
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
71
|
+
def method_missing(method, *args)
|
72
|
+
if (page = fetch(method))
|
73
|
+
page
|
74
|
+
else
|
75
|
+
super
|
70
76
|
end
|
71
|
-
end
|
77
|
+
end
|
72
78
|
end
|
73
79
|
end
|
@@ -4,34 +4,40 @@ class Spontaneous::Site
|
|
4
4
|
module State
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
7
|
+
def working_revision
|
8
|
+
Spontaneous::State.revision
|
9
|
+
end
|
10
|
+
|
11
|
+
def revision
|
12
|
+
Spontaneous::State.revision
|
13
|
+
end
|
14
|
+
|
15
|
+
def published_revision
|
16
|
+
Spontaneous::State.published_revision
|
17
|
+
end
|
18
|
+
|
19
|
+
def pending_revision
|
20
|
+
Spontaneous::State.pending_revision
|
21
|
+
end
|
22
|
+
|
23
|
+
def modified_at
|
24
|
+
Spontaneous::State.modified_at
|
25
|
+
end
|
26
|
+
|
27
|
+
def must_publish_all?
|
28
|
+
Spontaneous::State.must_publish_all?
|
29
|
+
end
|
30
|
+
|
31
|
+
def must_publish_all!(state = true)
|
32
|
+
Spontaneous::State.must_publish_all!(state)
|
33
|
+
end
|
34
|
+
|
35
|
+
def revision_root(*path)
|
36
|
+
instance.revision_root(*path)
|
37
|
+
end
|
38
|
+
|
39
|
+
def revision_dir(revision=nil, root = nil)
|
40
|
+
instance.revision_dir(revision, root)
|
41
|
+
end
|
42
|
+
end
|
37
43
|
end
|