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
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'tempfile'
|
4
|
+
require 'digest/md5'
|
4
5
|
|
5
6
|
module Spontaneous::Field
|
6
7
|
class File < Base
|
@@ -56,15 +57,27 @@ module Spontaneous::Field
|
|
56
57
|
|
57
58
|
def preprocess(image, site)
|
58
59
|
file, filename, mimetype = fileinfo(image)
|
59
|
-
|
60
|
-
|
60
|
+
if file.nil?
|
61
|
+
set_unprocessed_value(["", ""].to_json)
|
62
|
+
return ""
|
63
|
+
end
|
64
|
+
unless ::File.exist?(file)
|
65
|
+
set_unprocessed_value([file, ""].to_json)
|
66
|
+
return file
|
67
|
+
end
|
68
|
+
set_unprocessed_value([filename, file_digest(file)].to_json)
|
61
69
|
|
62
70
|
media_file = site.file(owner, filename, storage_headers(mimetype, filename))
|
63
71
|
media_file.copy(file)
|
64
|
-
set_unprocessed_value(media_file.path)
|
65
72
|
media_file
|
66
73
|
end
|
67
74
|
|
75
|
+
def file_digest(file)
|
76
|
+
Digest::MD5.file(file).hexdigest
|
77
|
+
rescue Errno::ENOENT => e
|
78
|
+
""
|
79
|
+
end
|
80
|
+
|
68
81
|
def fileinfo(fileinfo)
|
69
82
|
file = filename = mimetype = nil
|
70
83
|
case fileinfo
|
@@ -108,6 +121,18 @@ module Spontaneous::Field
|
|
108
121
|
})
|
109
122
|
end
|
110
123
|
|
124
|
+
def original_filename
|
125
|
+
file_info[0]
|
126
|
+
end
|
127
|
+
|
128
|
+
def file_hash
|
129
|
+
file_info[1]
|
130
|
+
end
|
131
|
+
|
132
|
+
def file_info
|
133
|
+
@file_info ||= Spontaneous::JSON.parse(unprocessed_value)
|
134
|
+
end
|
135
|
+
|
111
136
|
def path
|
112
137
|
value(:html)
|
113
138
|
end
|
@@ -33,6 +33,11 @@ module Spontaneous::Field
|
|
33
33
|
metadata = (metadata || [{}]).first || {}
|
34
34
|
end
|
35
35
|
|
36
|
+
# TODO: define what's a sensible fallback response
|
37
|
+
def fallback_response
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
|
36
41
|
def to_html(options = {})
|
37
42
|
params = player_attributes(options)
|
38
43
|
attributes = hash_to_attributes(params[:attr])
|
@@ -104,7 +109,7 @@ module Spontaneous::Field
|
|
104
109
|
"player_id" => o[:player_id] }
|
105
110
|
params.update("color" => o[:color]) if o.key?(:color)
|
106
111
|
params = ::Rack::Utils.build_query(params)
|
107
|
-
"
|
112
|
+
"//player.vimeo.com/video/#{video_id}?#{params}"
|
108
113
|
end
|
109
114
|
end
|
110
115
|
|
@@ -101,7 +101,7 @@ module Spontaneous::Field
|
|
101
101
|
"autohide" => o[:autohide],
|
102
102
|
"rel" => o[:rel],
|
103
103
|
"enablejsapi" => o[:api] })
|
104
|
-
"
|
104
|
+
"//www.youtube.com/embed/#{video_id}?#{params}"
|
105
105
|
end
|
106
106
|
|
107
107
|
def download_metadata
|
@@ -6,9 +6,10 @@ module Spontaneous
|
|
6
6
|
module Generators
|
7
7
|
class Site < Thor::Group
|
8
8
|
def self.available_dbs
|
9
|
-
postgres = { :gem => "sequel_pg", :adapter => "postgres", :user =>
|
10
|
-
{ "
|
11
|
-
"
|
9
|
+
postgres = { :gem => "sequel_pg", :adapter => "postgres", :user => ENV["USER"] }
|
10
|
+
{ "sqlite" => { gem: "sqlite3", adapter: "sqlite3" },
|
11
|
+
"mysql" => { gem: "mysql2", adapter: "mysql2", user: "root" },
|
12
|
+
"pg" => postgres, "postgresql" => postgres, "postgres" => postgres }
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.source_root; File.expand_path(File.dirname(__FILE__) + "/site"); end
|
@@ -19,7 +20,7 @@ module Spontaneous
|
|
19
20
|
argument :domain, :type => :string, :desc => "The domain name of the site to generate"
|
20
21
|
|
21
22
|
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
|
22
|
-
class_option :database, :desc => "The database to use ('
|
23
|
+
class_option :database, :desc => "The database to use ('sqlite' (default), 'postgres' or 'mysql')", :aliases => %w(-d --db), :default => "sqlite", :type => :string
|
23
24
|
class_option :user, :desc => "The database account to use", :aliases => '-u', :type => :string
|
24
25
|
class_option :password, :desc => "The password for the database user", :aliases => %w(-p), :default => "", :type => :string
|
25
26
|
class_option :host, :desc => "The database host", :aliases => %w(-h), :type => :string
|
@@ -59,6 +60,7 @@ module Spontaneous
|
|
59
60
|
template "Gemfile.tt", "Gemfile"
|
60
61
|
template "Capfile.tt", "Capfile"
|
61
62
|
template "Rakefile.tt", "Rakefile"
|
63
|
+
template "db/#{@database[:adapter]}.yml.tt", "config/database.yml"
|
62
64
|
# template "lib/site.rb.tt", "lib/site.rb"
|
63
65
|
# empty_directory "lib/tasks"
|
64
66
|
empty_directory "log"
|
@@ -3,13 +3,13 @@ source "https://rubygems.org"
|
|
3
3
|
# You can either fix the version of Spontaneous that this site uses
|
4
4
|
gem 'spontaneous', '~> <%= Spontaneous::VERSION %>'
|
5
5
|
# Or point it at a git repository to use the cutting edge or your custom version
|
6
|
-
# gem 'spontaneous', :
|
6
|
+
# gem 'spontaneous', git: 'https://github.com/SpontaneousCMS/spontaneous.git'
|
7
7
|
|
8
8
|
gem '<%= @database[:gem].name %>', '<%= @database[:gem].requirement %>'<%
|
9
9
|
if (requires = @database[:gem].autorequire) && (requires.length > 0)
|
10
10
|
requires = requires.first if requires.length == 1 -%>
|
11
11
|
, require: '<%= requires %>'
|
12
|
-
<%- end
|
12
|
+
<%- end %>
|
13
13
|
|
14
14
|
# Your favorite ExecJS compatible engine
|
15
15
|
gem 'therubyracer', '~> 0.11.1'
|
@@ -20,7 +20,7 @@ gem 'capistrano', '~> 2.9'
|
|
20
20
|
# If you want to enable the built in search functionality then you must un-comment
|
21
21
|
# the xapian-ruby dependency below. It is not included by default
|
22
22
|
# because the xapian library takes a very long time to build.
|
23
|
-
#gem 'xapian-ruby',
|
23
|
+
#gem 'xapian-ruby', '~> 1.2.12'
|
24
24
|
|
25
25
|
# group :production do
|
26
26
|
# gem 'thin', '~> 1.3.1'
|
File without changes
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Configure the template filesystem.
|
2
|
+
#
|
3
|
+
# Spontaneous accepts any Moneta[1] compatible key-value store as a
|
4
|
+
# template destination. The arguments to #output_store should be
|
5
|
+
# identical to those you would use to configure a Moneta instance,
|
6
|
+
# e.g.
|
7
|
+
#
|
8
|
+
# Site.output_store(:Memcached, server: 'localhost:11211)
|
9
|
+
#
|
10
|
+
# [1]: https://github.com/minad/moneta
|
11
|
+
|
12
|
+
Site.output_store(:File, dir: Site.revision_root)
|
13
|
+
|
14
|
+
# Configure the site publishing pipeline
|
15
|
+
#
|
16
|
+
# `run` inserts a step in the publishing pipeline.
|
17
|
+
|
18
|
+
# The core steps can be referenced by a symbol that is mapped to
|
19
|
+
# the corresponding step class.
|
20
|
+
#
|
21
|
+
# Custom steps *must* respond to `call` with four parameters:
|
22
|
+
#
|
23
|
+
# site: the current site instance
|
24
|
+
# revision: the revision that is being created
|
25
|
+
# pages: the list of pages that are being published
|
26
|
+
# progress: a progress object
|
27
|
+
#
|
28
|
+
# `call` can optionally return an object that responds to #rollback
|
29
|
+
# which should undo any actions made by the #call method.
|
30
|
+
#
|
31
|
+
# They can also, optionally, respond to:
|
32
|
+
#
|
33
|
+
# #count(site, revision, pages, progress): returns the number of
|
34
|
+
# discrete actions that this step comprises. During the #call
|
35
|
+
# the step *must* call progress#step exactly the number of times
|
36
|
+
# returned by this call
|
37
|
+
#
|
38
|
+
# Examples:
|
39
|
+
#
|
40
|
+
# Run a proc as part of the publishing process:
|
41
|
+
# run proc { |site, revision, pages, progress| puts "Publishing revision #revision}" }
|
42
|
+
#
|
43
|
+
# Run a custom publishing step:
|
44
|
+
#
|
45
|
+
# class NotifyMe
|
46
|
+
# def initialize(options)
|
47
|
+
# @options = options
|
48
|
+
# end
|
49
|
+
# def count(site, revision, pages, progress)
|
50
|
+
# 1
|
51
|
+
# end
|
52
|
+
# def call(site, revision, pages, progress)
|
53
|
+
# # send me a tweet when the site publishes...
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# Site.publish do
|
58
|
+
# run NotifyMe.new(handle: "my_twitter_name")
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
|
62
|
+
# NOTE: Do not remove or re-order the core steps declared below
|
63
|
+
# unless you are really sure of what you're doing
|
64
|
+
Site.publish do
|
65
|
+
# List of notification targets.
|
66
|
+
# If you remove the :browser target then publishing progress will not
|
67
|
+
# be shown in the browser
|
68
|
+
<%- Spontaneous::Publishing::Steps::CORE_PROGRESS.each do |progress| -%>
|
69
|
+
notify <%= progress.inspect %>
|
70
|
+
<%- end -%>
|
71
|
+
# Start core steps
|
72
|
+
<%- Spontaneous::Publishing::Steps::CORE_STEPS.each do |step| -%>
|
73
|
+
run <%= step.inspect %>
|
74
|
+
<%- end -%>
|
75
|
+
# Finish core steps
|
76
|
+
# At this point the site is published & most probably live to the public
|
77
|
+
# This is a good place to run any notification steps
|
78
|
+
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
---
|
2
|
-
:
|
3
|
-
:adapter:
|
4
|
-
:
|
2
|
+
:defaults: &defaults
|
3
|
+
:adapter: mysql2
|
4
|
+
:encoding: UTF-8
|
5
5
|
:user: <%= @database[:user] %>
|
6
6
|
:password: <%= @database[:password] %>
|
7
7
|
<% unless (host = @database[:host]).blank? -%>
|
8
8
|
:host: <%= host %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
+
:development:
|
12
|
+
<<: *defaults
|
13
|
+
:database: <%= @site_name %>
|
14
|
+
|
11
15
|
:test:
|
12
16
|
<<: *defaults
|
13
17
|
:database: <%= @site_name %>_test
|
@@ -18,7 +22,4 @@
|
|
18
22
|
:user: <%= @site_name %>
|
19
23
|
:password: <%= @database[:password] %>
|
20
24
|
|
21
|
-
:rake:
|
22
|
-
<<: *defaults
|
23
|
-
|
24
25
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
:defaults: &defaults
|
3
|
+
:adapter: postgres
|
4
|
+
:encoding: UTF-8
|
5
|
+
:user: <%= @database[:user] %>
|
6
|
+
:password: <%= @database[:password] %>
|
7
|
+
<% unless (host = @database[:host]).blank? -%>
|
8
|
+
:host: <%= host %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
:development:
|
12
|
+
<<: *defaults
|
13
|
+
:database: <%= @site_name %>
|
14
|
+
|
15
|
+
:test:
|
16
|
+
<<: *defaults
|
17
|
+
:database: <%= @site_name %>_test
|
18
|
+
|
19
|
+
:production:
|
20
|
+
<<: *defaults
|
21
|
+
:database: <%= @site_name %>
|
22
|
+
:user: <%= @site_name %>
|
23
|
+
:password: <%= @database[:password] %>
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
:default: &default
|
3
|
+
:adapter: sqlite
|
4
|
+
|
5
|
+
:development:
|
6
|
+
<<: *default
|
7
|
+
:database: db/development.sqlite3
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
:test:
|
13
|
+
<<: *default
|
14
|
+
:database: db/test.sqlite3
|
15
|
+
|
16
|
+
:production:
|
17
|
+
<<: *default
|
18
|
+
:database: db/production.sqlite3
|
@@ -7,15 +7,66 @@
|
|
7
7
|
<head>
|
8
8
|
<meta charset="UTF-8">
|
9
9
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
10
|
+
!{
|
11
|
+
|
12
|
+
A quick guide to spontaneous templating:
|
13
|
+
|
14
|
+
${ ... } inserts a value, e.g. `${ title }` inserts the value of the page's title field
|
15
|
+
|
16
|
+
%{ ... } creates a code block with no output into the template,
|
17
|
+
e.g. `%{ total_entries = boxes.map { |box| box.length }.sum }`
|
18
|
+
|
19
|
+
!{ ... } inserts a comment, e.g. `!{ this is a comment }`
|
20
|
+
|
21
|
+
Adding a '-' before the closing bracket removes whitespace after the tag, e.g. `${ title -}`
|
22
|
+
|
23
|
+
}
|
10
24
|
<title>${ title } <%= @domain %></title>
|
25
|
+
|
26
|
+
!{ inserts a CSS link to assets/css/site.css which is a Sprockets 'manifest' file }
|
27
|
+
|
11
28
|
${ stylesheets 'css/site' }
|
29
|
+
|
12
30
|
</head>
|
13
31
|
<body>
|
14
32
|
%{ block :content }
|
15
33
|
<h2>Welcome to <%= @domain %></h2>
|
34
|
+
|
35
|
+
!{ 'fields' dumps all the page fields into the template with no layout
|
36
|
+
you won't be wanting to do this in your actual templates but its useful
|
37
|
+
for instant feedback in the early stages... }
|
38
|
+
|
16
39
|
${ fields }
|
40
|
+
|
41
|
+
!{ 'boxes' is useful however:
|
42
|
+
|
43
|
+
`${ boxes }` is the same as doing
|
44
|
+
|
45
|
+
%{ boxes.each do |box| }
|
46
|
+
${ box }
|
47
|
+
%{ end }
|
48
|
+
|
49
|
+
Which is different to:
|
50
|
+
|
51
|
+
%{ boxes.each do |box| }
|
52
|
+
%{ box.each do |entry| }
|
53
|
+
${ entry }
|
54
|
+
%{ end }
|
55
|
+
%{ end }
|
56
|
+
|
57
|
+
because it also renders any template that belongs to the box.
|
58
|
+
|
59
|
+
Since the default template for a box is `${ contents }` you will always get a valid output
|
60
|
+
from `${ box }`.
|
61
|
+
}
|
62
|
+
|
17
63
|
${ boxes }
|
64
|
+
|
18
65
|
%{ endblock :content }
|
66
|
+
|
67
|
+
!{ inserts a script tag pointing to assets/js/site.js which is a Sprockets 'manifest' file }
|
68
|
+
|
19
69
|
${ scripts %w(js/site) }
|
70
|
+
|
20
71
|
</body>
|
21
72
|
</html>
|
data/lib/spontaneous/loader.rb
CHANGED
data/lib/spontaneous/logger.rb
CHANGED
@@ -180,7 +180,7 @@ module Spontaneous
|
|
180
180
|
@log.sync = true
|
181
181
|
@mutex = @@mutex[@log] ||= Mutex.new
|
182
182
|
@format_datetime = options[:format_datetime] || "%d/%b/%Y %H:%M:%S"
|
183
|
-
@format_message = options[:format_message] || "%s - [%s]
|
183
|
+
@format_message = options[:format_message] || "%s - [%s] %s"
|
184
184
|
end
|
185
185
|
|
186
186
|
##
|