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
@@ -0,0 +1,69 @@
|
|
1
|
+
module Spontaneous::Publishing::Steps
|
2
|
+
class RenderRevision < BaseStep
|
3
|
+
|
4
|
+
# Wrap any exceptions raised during the render with information
|
5
|
+
# about the page+output that raised the error (preserving the
|
6
|
+
# stack trace)
|
7
|
+
class RenderException < Spontaneous::Error
|
8
|
+
def initialize(output, exception)
|
9
|
+
super("Exception rendering page #{output.url_path.inspect}: #{exception}")
|
10
|
+
set_backtrace(exception.backtrace)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
@progress.stage("rendering")
|
16
|
+
render_pages
|
17
|
+
commit
|
18
|
+
end
|
19
|
+
|
20
|
+
def count
|
21
|
+
renderable_pages.map { |page| page.outputs.length }.inject(0, :+)
|
22
|
+
end
|
23
|
+
|
24
|
+
def rollback
|
25
|
+
render_transaction.rollback if @render_transaction
|
26
|
+
template_revision.delete
|
27
|
+
end
|
28
|
+
|
29
|
+
def render_pages
|
30
|
+
renderable_pages.each do |page|
|
31
|
+
render_page(page)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def commit
|
36
|
+
render_transaction.commit
|
37
|
+
@render_transaction = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_page(page)
|
41
|
+
page.outputs.each do |output|
|
42
|
+
render_output(output)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def render_output(output)
|
47
|
+
output.publish_page(renderer, revision, render_transaction)
|
48
|
+
@progress.step(1, output.url_path.inspect)
|
49
|
+
rescue => e
|
50
|
+
raise RenderException.new(output, e)
|
51
|
+
end
|
52
|
+
|
53
|
+
def renderer
|
54
|
+
@renderer ||= Spontaneous::Output::Template::PublishRenderer.new(@site, true)
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_transaction
|
58
|
+
@render_transaction ||= template_revision.transaction
|
59
|
+
end
|
60
|
+
|
61
|
+
def template_revision
|
62
|
+
@template_revision ||= @site.output_store.revision(@revision)
|
63
|
+
end
|
64
|
+
|
65
|
+
def renderable_pages
|
66
|
+
@site.pages
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Should be called *after* the revision
|
2
|
+
module Spontaneous::Publishing::Steps
|
3
|
+
class WriteRevisionFile < BaseStep
|
4
|
+
|
5
|
+
def call
|
6
|
+
@progress.stage("writing revision file")
|
7
|
+
save_state
|
8
|
+
padded_revision = Spontaneous::Paths.pad_revision_number(revision)
|
9
|
+
write_revision_file(padded_revision)
|
10
|
+
@progress.step(count, "#{path.inspect} => #{padded_revision.inspect}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def count
|
14
|
+
1
|
15
|
+
end
|
16
|
+
|
17
|
+
def rollback
|
18
|
+
if @previous
|
19
|
+
write_revision_file(@previous)
|
20
|
+
else
|
21
|
+
FileUtils.rm(path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def write_revision_file(contents)
|
26
|
+
File.open(path, "w:UTF-8") do |file|
|
27
|
+
file.write(contents)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def path
|
32
|
+
@site.revision_root / "REVISION"
|
33
|
+
end
|
34
|
+
|
35
|
+
def save_state
|
36
|
+
@previous = if File.exist?(path)
|
37
|
+
File.read(path)
|
38
|
+
else
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -49,6 +49,7 @@ module Spontaneous
|
|
49
49
|
def self.editing_app(site)
|
50
50
|
::Rack::Builder.app do
|
51
51
|
use Scope::Edit, site
|
52
|
+
use Transaction, site
|
52
53
|
use ApplicationAssets
|
53
54
|
use UnsupportedBrowser
|
54
55
|
use Authenticate::Init, site
|
@@ -74,6 +75,7 @@ module Spontaneous
|
|
74
75
|
::Rack::Builder.app do
|
75
76
|
use ::Rack::Lint if Spontaneous.development?
|
76
77
|
use Scope::Preview, site
|
78
|
+
use Transaction, site
|
77
79
|
use Authenticate::Init, site
|
78
80
|
# Preview authentication redirects to /@spontaneous rather than
|
79
81
|
# showing a login screen. This way if you go to the root of the site
|
@@ -99,7 +101,7 @@ module Spontaneous
|
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
102
|
-
def self.application(site)
|
104
|
+
def self.application(site = ::Spontaneous.instance)
|
103
105
|
app = ::Rack::Builder.new do
|
104
106
|
site.back_controllers.each do |namespace, controller|
|
105
107
|
map(namespace) do
|
@@ -28,15 +28,16 @@ module Spontaneous::Rack::Back
|
|
28
28
|
type = content_model.schema.to_class(params[:alias_id])
|
29
29
|
position = (params[:position] || 0).to_i
|
30
30
|
if box.writable?(user, type)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:entry
|
38
|
-
|
31
|
+
additions = []
|
32
|
+
Array(params[:target_ids]).each_with_index do |target_id, offset|
|
33
|
+
instance = type.for_target(target_id)
|
34
|
+
if instance
|
35
|
+
box.insert(position+offset, instance)
|
36
|
+
content.save
|
37
|
+
additions << { position: position+offset, entry: instance.entry.export(user) }
|
38
|
+
end
|
39
39
|
end
|
40
|
+
json(additions)
|
40
41
|
else
|
41
42
|
forbidden!
|
42
43
|
end
|
@@ -19,7 +19,7 @@ module Spontaneous
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.application(site)
|
22
|
+
def self.application(site = ::Spontaneous.instance)
|
23
23
|
app = ::Rack::Builder.new do
|
24
24
|
use Spontaneous::Rack::Static, root: Spontaneous.revision_dir / "public", urls: %w[/], try: ['.html', 'index.html', '/index.html']
|
25
25
|
|
@@ -1,6 +1,9 @@
|
|
1
|
+
|
1
2
|
module Spontaneous::Rack::Middleware
|
2
|
-
autoload :Authenticate, "spontaneous/rack/middleware/authenticate"
|
3
|
-
autoload :CSRF, "spontaneous/rack/middleware/csrf"
|
4
|
-
autoload :Reloader, "spontaneous/rack/middleware/reloader"
|
5
|
-
autoload :Scope, "spontaneous/rack/middleware/scope"
|
6
3
|
end
|
4
|
+
|
5
|
+
require "spontaneous/rack/middleware/authenticate"
|
6
|
+
require "spontaneous/rack/middleware/csrf"
|
7
|
+
require "spontaneous/rack/middleware/reloader"
|
8
|
+
require "spontaneous/rack/middleware/scope"
|
9
|
+
require "spontaneous/rack/middleware/transaction"
|
@@ -50,14 +50,14 @@ module Spontaneous::Rack
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# render [instance (Content), output (Symbol), status (Fixnum), locals (Hash)]
|
53
|
-
# render [
|
54
|
-
# render [
|
53
|
+
# render [singleton name (Symbol), status (Fixnum), locals (Hash)] => [instance, output, status, locals]
|
54
|
+
# render [singleton name (Symbol)] => [singleton name, output, 200, {}]
|
55
55
|
# render [instance (Content)] => [instance, output, 200, {}]
|
56
56
|
# render [locals (Hash)] => [page, output, 200, locals]
|
57
57
|
# render [status (Fixnum)] => [page, output, status, {}]
|
58
|
-
# render(:home, :xml, 200, {logged_in: true}) # => :home =>
|
59
|
-
# render(:home, 200, {logged_in: true}) # => :home =>
|
60
|
-
# render(:home, {logged_in: true}) # => :home =>
|
58
|
+
# render(:home, :xml, 200, {logged_in: true}) # => :home => singleton name, :xml => output
|
59
|
+
# render(:home, 200, {logged_in: true}) # => :home => singleton name
|
60
|
+
# render(:home, {logged_in: true}) # => :home => singleton name
|
61
61
|
# render(:xml, 200, {logged_in: true}) # NOT ALLOWED: if you want to specify the output then you must also specify the page
|
62
62
|
# render(403, {logged_in: false})
|
63
63
|
#
|
@@ -140,9 +140,24 @@ module Spontaneous::Rack
|
|
140
140
|
env[Spontaneous::Rack::RENDERER]
|
141
141
|
end
|
142
142
|
|
143
|
-
def fetch_page(
|
144
|
-
|
145
|
-
|
143
|
+
def fetch_page(locator)
|
144
|
+
case locator
|
145
|
+
when Class # (singleton) type classes
|
146
|
+
locator.first
|
147
|
+
when Symbol, String
|
148
|
+
fetch_singleton(locator) || fetch_path(locator)
|
149
|
+
else # probably an instance
|
150
|
+
locator
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def fetch_path(path)
|
155
|
+
@site[path]
|
156
|
+
end
|
157
|
+
|
158
|
+
def fetch_singleton(page)
|
159
|
+
return @site.send(page) if @site.singleton?(page)
|
160
|
+
nil
|
146
161
|
end
|
147
162
|
|
148
163
|
def render_body
|
data/lib/spontaneous/revision.rb
CHANGED
@@ -2,14 +2,15 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Spontaneous
|
4
4
|
class Revision
|
5
|
-
attr_reader :revision
|
5
|
+
attr_reader :revision, :site
|
6
6
|
|
7
|
-
def initialize(revision)
|
7
|
+
def initialize(revision, site)
|
8
8
|
@revision = revision.to_i
|
9
|
+
@site = site
|
9
10
|
end
|
10
11
|
|
11
12
|
def root
|
12
|
-
::File.join(
|
13
|
+
::File.join(site.revision_root, padded_revision)
|
13
14
|
end
|
14
15
|
|
15
16
|
def path(*path)
|
@@ -18,17 +19,11 @@ module Spontaneous
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def padded_revision
|
21
|
-
|
22
|
+
revision.to_s.rjust(5, "0")
|
22
23
|
end
|
23
24
|
|
24
25
|
def to_i
|
25
26
|
@revision
|
26
27
|
end
|
27
|
-
|
28
|
-
module GlobalMethods
|
29
|
-
def revision(revision)
|
30
|
-
Revision.new(revision)
|
31
|
-
end
|
32
|
-
end
|
33
28
|
end
|
34
29
|
end
|
data/lib/spontaneous/schema.rb
CHANGED
@@ -106,6 +106,7 @@ module Spontaneous
|
|
106
106
|
class Schema
|
107
107
|
attr_accessor :schema_loader_class
|
108
108
|
attr_reader :uids
|
109
|
+
attr_reader :site
|
109
110
|
|
110
111
|
def initialize(site, root, schema_loader_class = Spontaneous::Schema::PersistentMap)
|
111
112
|
@site, @root = site, root
|
@@ -413,6 +414,10 @@ module Spontaneous
|
|
413
414
|
members.delete(type)
|
414
415
|
end
|
415
416
|
end
|
417
|
+
|
418
|
+
def inspect
|
419
|
+
%(#<#{self.class} root="#{@root}">)
|
420
|
+
end
|
416
421
|
end
|
417
422
|
end
|
418
423
|
end
|
data/lib/spontaneous/server.rb
CHANGED
@@ -33,7 +33,9 @@ module Spontaneous
|
|
33
33
|
end
|
34
34
|
puts "=> Spontaneous:#{Spontaneous.mode.to_s.ljust(5, " ")} running on port #{host}:#{port} (PID #{$$})"
|
35
35
|
|
36
|
-
handler.run Spontaneous::Rack.application(site).to_app, :
|
36
|
+
handler.run Spontaneous::Rack.application(site).to_app, Host: host, Port: port do |server|
|
37
|
+
# set connection timeout to 0 (infinite) because otherwise we constantly lose our event connection
|
38
|
+
server.timeout = 0 if server.respond_to?(:timeout=)
|
37
39
|
term = Proc.new do
|
38
40
|
server.respond_to?(:stop!) ? server.stop! : server.stop
|
39
41
|
puts "=> Spontaneous:#{Spontaneous.mode.to_s.ljust(5, " ")} exiting..."
|
data/lib/spontaneous/site.rb
CHANGED
@@ -33,6 +33,7 @@ module Spontaneous
|
|
33
33
|
include State
|
34
34
|
include Storage
|
35
35
|
include URL
|
36
|
+
include Spontaneous::Model::Page::Singleton::SiteMethods
|
36
37
|
|
37
38
|
attr_accessor :database
|
38
39
|
attr_reader :environment, :mode, :model
|
@@ -52,7 +53,7 @@ module Spontaneous
|
|
52
53
|
find_plugins!
|
53
54
|
load_facets!
|
54
55
|
init_facets!
|
55
|
-
|
56
|
+
run_initializers!
|
56
57
|
end
|
57
58
|
|
58
59
|
|
@@ -62,9 +63,9 @@ module Spontaneous
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
def
|
66
|
+
def run_initializers!
|
66
67
|
facets.each do |facet|
|
67
|
-
facet.
|
68
|
+
facet.run_initializers
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -91,9 +92,15 @@ module Spontaneous
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def db_settings
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
self.config.db = db_config[environment]
|
96
|
+
end
|
97
|
+
|
98
|
+
def db_config
|
99
|
+
@db_config ||= YAML.load_file(File.join(paths.expanded(:config).first, "database.yml"))
|
100
|
+
end
|
101
|
+
|
102
|
+
def transaction(&block)
|
103
|
+
model.db.transaction(&block)
|
97
104
|
end
|
98
105
|
|
99
106
|
def config
|
@@ -131,10 +138,10 @@ module Spontaneous
|
|
131
138
|
|
132
139
|
def revision_root
|
133
140
|
@revision_dir ||= begin
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
141
|
+
path = Pathname.new(@root / 'cache/revisions')
|
142
|
+
path.mkpath unless path.exist?
|
143
|
+
path.realpath.to_s
|
144
|
+
end
|
138
145
|
end
|
139
146
|
|
140
147
|
def revision_dir(revision=nil, root = revision_root)
|
@@ -24,6 +24,28 @@ class Spontaneous::Site
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def publish(&block)
|
28
|
+
self.publish_steps = Spontaneous::Publishing::Steps.new(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def publish_steps=(steps)
|
32
|
+
@publish_steps = steps
|
33
|
+
end
|
34
|
+
|
35
|
+
def publish_steps
|
36
|
+
@publish_steps || minimal_publish_steps
|
37
|
+
end
|
38
|
+
|
39
|
+
# Provides a fallback publishing pipeline in case none has been defined
|
40
|
+
# used really only in tests
|
41
|
+
def minimal_publish_steps
|
42
|
+
Spontaneous::Publishing::Steps.minimal
|
43
|
+
end
|
44
|
+
|
45
|
+
def rerender_steps
|
46
|
+
Spontaneous::Publishing::Steps.rerender
|
47
|
+
end
|
48
|
+
|
27
49
|
def publishing_method
|
28
50
|
resolve_background_mode(Spontaneous::Publishing)
|
29
51
|
end
|
@@ -38,15 +60,15 @@ class Spontaneous::Site
|
|
38
60
|
end
|
39
61
|
|
40
62
|
def publish_pages(page_list=nil)
|
41
|
-
publishing_method.new(self,
|
63
|
+
publishing_method.new(self, working_revision, publish_steps).publish_pages(page_list)
|
42
64
|
end
|
43
65
|
|
44
66
|
def publish_all
|
45
|
-
publishing_method.new(self,
|
67
|
+
publishing_method.new(self, working_revision, publish_steps).publish_all
|
46
68
|
end
|
47
69
|
|
48
70
|
def rerender
|
49
|
-
publishing_method.new(self,
|
71
|
+
publishing_method.new(self, published_revision, rerender_steps).rerender
|
50
72
|
end
|
51
73
|
|
52
74
|
def publishing_status
|
@@ -4,11 +4,15 @@ class Spontaneous::Site
|
|
4
4
|
module State
|
5
5
|
extend Spontaneous::Concern
|
6
6
|
|
7
|
-
def
|
8
|
-
Spontaneous::
|
7
|
+
def revision(revision)
|
8
|
+
Spontaneous::Revision.new(revision, self)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def state
|
12
|
+
Spontaneous::State.instance
|
13
|
+
end
|
14
|
+
|
15
|
+
def working_revision
|
12
16
|
Spontaneous::State.revision
|
13
17
|
end
|
14
18
|
|