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.
Files changed (247) hide show
  1. data/Gemfile +10 -4
  2. data/Readme.markdown +1 -1
  3. data/application/css/definitions.css.scss +5 -0
  4. data/application/css/dialogue.css.scss +62 -0
  5. data/application/js/content.js +1 -1
  6. data/application/js/dom.js +1 -1
  7. data/application/js/event_source.js +3 -0
  8. data/application/js/{field_types/date_field.js → field/date.js} +2 -2
  9. data/application/js/{field_types/file_field.js → field/file.js} +2 -2
  10. data/application/js/{field_types/image_field.js → field/image.js} +54 -20
  11. data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
  12. data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
  13. data/application/js/{field_types/select_field.js → field/select.js} +2 -2
  14. data/application/js/{field_types/string_field.js → field/string.js} +21 -7
  15. data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
  16. data/application/js/field.js +2 -2
  17. data/application/js/publish.js +99 -19
  18. data/application/js/spontaneous.js +8 -8
  19. data/application/js/top_bar.js +6 -4
  20. data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
  21. data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
  22. data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
  23. data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
  24. data/lib/spontaneous/box.rb +53 -18
  25. data/lib/spontaneous/box_style.rb +2 -3
  26. data/lib/spontaneous/change.rb +39 -13
  27. data/lib/spontaneous/cli/fields.rb +29 -0
  28. data/lib/spontaneous/cli/init.rb +2 -2
  29. data/lib/spontaneous/cli/migrate.rb +0 -1
  30. data/lib/spontaneous/cli/server.rb +14 -10
  31. data/lib/spontaneous/cli/site.rb +20 -9
  32. data/lib/spontaneous/cli.rb +8 -6
  33. data/lib/spontaneous/collections/box_set.rb +11 -0
  34. data/lib/spontaneous/collections/field_set.rb +24 -1
  35. data/lib/spontaneous/concern.rb +37 -0
  36. data/lib/spontaneous/config.rb +3 -4
  37. data/lib/spontaneous/crypt/version.rb +130 -0
  38. data/lib/spontaneous/crypt.rb +84 -0
  39. data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
  40. data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
  41. data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
  42. data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
  43. data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
  44. data/lib/spontaneous/data_mapper/content_model.rb +343 -0
  45. data/lib/spontaneous/data_mapper/content_table.rb +103 -0
  46. data/lib/spontaneous/data_mapper/dataset.rb +194 -0
  47. data/lib/spontaneous/data_mapper/scope.rb +195 -0
  48. data/lib/spontaneous/data_mapper.rb +161 -0
  49. data/lib/spontaneous/facet.rb +2 -2
  50. data/lib/spontaneous/field/base.rb +418 -0
  51. data/lib/spontaneous/field/date.rb +54 -0
  52. data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
  53. data/lib/spontaneous/field/file.rb +100 -0
  54. data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
  55. data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
  56. data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
  57. data/lib/spontaneous/field/markdown.rb +36 -0
  58. data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
  59. data/lib/spontaneous/field/string.rb +17 -0
  60. data/lib/spontaneous/field/update.rb +156 -0
  61. data/lib/spontaneous/field/webvideo.rb +310 -0
  62. data/lib/spontaneous/field.rb +80 -0
  63. data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
  64. data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
  65. data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
  66. data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
  67. data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
  68. data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
  69. data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
  70. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
  71. data/lib/spontaneous/generators/site.rb +4 -3
  72. data/lib/spontaneous/image_size.rb +8 -1
  73. data/lib/spontaneous/layout.rb +5 -1
  74. data/lib/spontaneous/loader.rb +2 -5
  75. data/lib/spontaneous/media/file.rb +11 -2
  76. data/lib/spontaneous/media/temp_file.rb +23 -0
  77. data/lib/spontaneous/media.rb +20 -39
  78. data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
  79. data/lib/spontaneous/model/box.rb +18 -0
  80. data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
  81. data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
  82. data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
  83. data/lib/spontaneous/model/core/editor_class.rb +4 -0
  84. data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
  85. data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
  86. data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
  87. data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
  88. data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
  89. data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
  90. data/lib/spontaneous/model/core/page_search.rb +36 -0
  91. data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
  92. data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
  93. data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
  94. data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
  95. data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
  96. data/lib/spontaneous/model/core/schema_id.rb +65 -0
  97. data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
  98. data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
  99. data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
  100. data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
  101. data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
  102. data/lib/spontaneous/model/core.rb +143 -0
  103. data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
  104. data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
  105. data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
  106. data/lib/spontaneous/model/page/locks.rb +14 -0
  107. data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
  108. data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
  109. data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
  110. data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
  111. data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
  112. data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
  113. data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
  114. data/lib/spontaneous/model.rb +97 -0
  115. data/lib/spontaneous/output/context.rb +1 -1
  116. data/lib/spontaneous/output/format.rb +4 -0
  117. data/lib/spontaneous/output/template/renderer.rb +2 -2
  118. data/lib/spontaneous/output.rb +2 -2
  119. data/lib/spontaneous/page_lock.rb +62 -0
  120. data/lib/spontaneous/page_piece.rb +1 -1
  121. data/lib/spontaneous/permissions/access_key.rb +9 -4
  122. data/lib/spontaneous/permissions/user.rb +19 -9
  123. data/lib/spontaneous/permissions.rb +2 -5
  124. data/lib/spontaneous/plugins/application/facets.rb +1 -2
  125. data/lib/spontaneous/plugins/application/features.rb +1 -1
  126. data/lib/spontaneous/plugins/application/paths.rb +1 -1
  127. data/lib/spontaneous/plugins/application/render.rb +1 -1
  128. data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
  129. data/lib/spontaneous/plugins/application/state.rb +30 -1
  130. data/lib/spontaneous/plugins/application/system.rb +12 -12
  131. data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
  132. data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
  133. data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
  134. data/lib/spontaneous/publishing/immediate.rb +77 -49
  135. data/lib/spontaneous/publishing/revision.rb +355 -0
  136. data/lib/spontaneous/publishing/simultaneous.rb +10 -49
  137. data/lib/spontaneous/publishing.rb +1 -0
  138. data/lib/spontaneous/rack/around_back.rb +1 -1
  139. data/lib/spontaneous/rack/around_front.rb +2 -4
  140. data/lib/spontaneous/rack/around_preview.rb +1 -1
  141. data/lib/spontaneous/rack/back.rb +80 -63
  142. data/lib/spontaneous/rack/cacheable_file.rb +2 -2
  143. data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
  144. data/lib/spontaneous/rack/front.rb +1 -1
  145. data/lib/spontaneous/rack/helpers.rb +8 -9
  146. data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
  147. data/lib/spontaneous/rack/public.rb +3 -3
  148. data/lib/spontaneous/rack.rb +15 -15
  149. data/lib/spontaneous/schema/uid.rb +4 -1
  150. data/lib/spontaneous/schema.rb +57 -24
  151. data/lib/spontaneous/search/database.rb +12 -1
  152. data/lib/spontaneous/search/index.rb +34 -6
  153. data/lib/spontaneous/search/results.rb +1 -1
  154. data/lib/spontaneous/server.rb +3 -3
  155. data/lib/spontaneous/simultaneous.rb +53 -0
  156. data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
  157. data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
  158. data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
  159. data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
  160. data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
  161. data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
  162. data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
  163. data/lib/spontaneous/site/publishing.rb +89 -0
  164. data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
  165. data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
  166. data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
  167. data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
  168. data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
  169. data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
  170. data/lib/spontaneous/site.rb +31 -14
  171. data/lib/spontaneous/state.rb +5 -6
  172. data/lib/spontaneous/style.rb +3 -2
  173. data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
  174. data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
  175. data/lib/spontaneous/version.rb +1 -1
  176. data/lib/spontaneous.rb +34 -89
  177. data/spontaneous.gemspec +112 -114
  178. data/test/experimental/test_crypt.rb +158 -0
  179. data/test/experimental/test_features.rb +3 -3
  180. data/test/fixtures/example_application/config/environments/development.rb +1 -1
  181. data/test/fixtures/example_application/lib/content.rb +5 -0
  182. data/test/fixtures/example_application/schema/page.rb +2 -1
  183. data/test/fixtures/example_application/schema/piece.rb +3 -2
  184. data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
  185. data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
  186. data/test/functional/test_application.rb +12 -1
  187. data/test/functional/test_back.rb +80 -48
  188. data/test/functional/test_front.rb +39 -46
  189. data/test/functional/test_user_manager.rb +3 -9
  190. data/test/javascript/test_markdown.rb +2 -2
  191. data/test/test_helper.rb +78 -23
  192. data/test/unit/test_alias.rb +21 -15
  193. data/test/unit/test_asset_bundler.rb +3 -3
  194. data/test/unit/test_assets.rb +2 -2
  195. data/test/unit/test_async.rb +7 -6
  196. data/test/unit/test_authentication.rb +43 -37
  197. data/test/unit/test_boxes.rb +46 -21
  198. data/test/unit/test_changesets.rb +65 -20
  199. data/test/unit/test_config.rb +9 -9
  200. data/test/unit/test_content.rb +50 -51
  201. data/test/unit/test_content_inheritance.rb +6 -20
  202. data/test/unit/test_datamapper.rb +1330 -0
  203. data/test/unit/test_datamapper_content.rb +214 -0
  204. data/test/unit/test_fields.rb +543 -54
  205. data/test/unit/test_formats.rb +2 -3
  206. data/test/unit/test_generators.rb +6 -6
  207. data/test/unit/test_helpers.rb +1 -1
  208. data/test/unit/test_image_size.rb +10 -5
  209. data/test/unit/test_images.rb +17 -18
  210. data/test/unit/test_layouts.rb +18 -3
  211. data/test/unit/test_media.rb +74 -49
  212. data/test/unit/test_modifications.rb +43 -43
  213. data/test/unit/test_page.rb +7 -10
  214. data/test/unit/test_permissions.rb +3 -10
  215. data/test/unit/test_piece.rb +5 -6
  216. data/test/unit/test_plugins.rb +7 -14
  217. data/test/unit/test_prototypes.rb +3 -3
  218. data/test/unit/test_publishing.rb +49 -27
  219. data/test/unit/test_render.rb +46 -15
  220. data/test/unit/test_revisions.rb +124 -127
  221. data/test/unit/test_schema.rb +53 -58
  222. data/test/unit/test_search.rb +64 -16
  223. data/test/unit/test_serialisation.rb +4 -11
  224. data/test/unit/test_site.rb +11 -12
  225. data/test/unit/test_structure.rb +2 -5
  226. data/test/unit/test_styles.rb +22 -24
  227. data/test/unit/test_type_hierarchy.rb +7 -5
  228. data/test/unit/test_visibility.rb +79 -55
  229. metadata +128 -102
  230. data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
  231. data/lib/sequel/plugins/scoped_table_name.rb +0 -54
  232. data/lib/spontaneous/content.rb +0 -129
  233. data/lib/spontaneous/field_types/date_field.rb +0 -56
  234. data/lib/spontaneous/field_types/field.rb +0 -302
  235. data/lib/spontaneous/field_types/file_field.rb +0 -68
  236. data/lib/spontaneous/field_types/markdown_field.rb +0 -38
  237. data/lib/spontaneous/field_types/string_field.rb +0 -19
  238. data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
  239. data/lib/spontaneous/field_types.rb +0 -38
  240. data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
  241. data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
  242. data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
  243. data/lib/spontaneous/plugins/page_search.rb +0 -63
  244. data/lib/spontaneous/plugins/schema_id.rb +0 -68
  245. data/lib/spontaneous/plugins/site/publishing.rb +0 -75
  246. data/lib/spontaneous/rack/fiber_pool.rb +0 -26
  247. 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
- values[prototype.index_id(self)] << field.indexable_value if prototype.in_index?(self)
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)
@@ -28,7 +28,7 @@ module Spontaneous::Search
28
28
  end
29
29
 
30
30
  def pages
31
- @page_list ||= @results.map { |doc| Spontaneous::Content.first(:id => doc.id) }
31
+ @page_list ||= Spontaneous::Content.get(@results.map { |doc| doc.id })
32
32
  end
33
33
  end # Results
34
34
  end
@@ -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,9 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
 
4
- module Spontaneous::Plugins::Site
4
+ class Spontaneous::Site
5
5
  module Features
6
- extend ActiveSupport::Concern
6
+ extend Spontaneous::Concern
7
7
 
8
8
  # InstanceMethods
9
9
  def back_controllers
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
-
4
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
5
4
  module Helpers
6
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
7
6
 
8
7
  module ClassMethods
9
8
  def helper(*formats, &block)
@@ -1,7 +1,7 @@
1
1
 
2
- module Spontaneous::Plugins::Site
2
+ class Spontaneous::Site
3
3
  module Hooks
4
- extend ActiveSupport::Concern
4
+ extend Spontaneous::Concern
5
5
 
6
6
  HOOKS = [:after_publish]
7
7
 
@@ -1,20 +1,18 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Instance
5
- extend ActiveSupport::Concern
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
- @@instance = Spontaneous::Site.new(root, env, mode)
11
+ Thread.current[:spontaneous_site_instance] = Spontaneous::Site.new(root, env, mode)
14
12
  end
15
13
 
16
14
  def instance
17
- @@instance
15
+ Thread.current[:spontaneous_site_instance]
18
16
  end
19
17
 
20
18
  def_delegators :instance, :config, :database, :database=
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Level
5
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
6
6
 
7
7
  module ClassMethods
8
8
  def at_depth(level)
@@ -1,16 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Map
5
- extend ActiveSupport::Concern
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
- Spontaneous::Page.root
11
+ content_model::Page.root
12
12
  else
13
- Spontaneous::Content.first :id => root_id
13
+ content_model.get root_id
14
14
  end
15
15
  return nil unless page
16
16
  page.map_entry
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Paths
5
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
6
6
 
7
7
  module ClassMethods
8
8
  def paths(group)
@@ -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
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Schema
5
- extend ActiveSupport::Concern
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.schema_id(obj)
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,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Search
5
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
6
6
 
7
7
  module ClassMethods
8
8
  def index(name, &definition)
@@ -1,12 +1,20 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module Selectors
5
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
6
6
 
7
7
  module ClassMethods
8
- def root
9
- Spontaneous::Page.root
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::Page[id]
34
+ Spontaneous::Content[id]
27
35
  end
28
36
 
29
37
  def by_path(path)
30
- Spontaneous::Page.path(path)
38
+ Spontaneous::Content.path(path)
31
39
  end
32
40
 
33
41
  def by_uid(uid)
34
- Spontaneous::Page.uid(uid)
42
+ Spontaneous::Content.uid(uid)
35
43
  end
36
44
 
37
45
  def method_missing(method, *args)
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- module Spontaneous::Plugins::Site
3
+ class Spontaneous::Site
4
4
  module State
5
- extend ActiveSupport::Concern
5
+ extend Spontaneous::Concern
6
6
 
7
7
  module ClassMethods
8
8
  def working_revision
@@ -16,9 +16,9 @@
16
16
  # })
17
17
  # end
18
18
 
19
- module Spontaneous::Plugins::Site
19
+ class Spontaneous::Site
20
20
  module Storage
21
- extend ActiveSupport::Concern
21
+ extend Spontaneous::Concern
22
22
 
23
23
  module ClassMethods
24
24
  def storage(mimetype = nil)
@@ -1,6 +1,6 @@
1
- module Spontaneous::Plugins::Site
1
+ class Spontaneous::Site
2
2
  module URL
3
- extend ActiveSupport::Concern
3
+ extend Spontaneous::Concern
4
4
 
5
5
  module ClassMethods
6
6
  def public_url(path = "/")
@@ -1,21 +1,38 @@
1
1
  # encoding: UTF-8
2
2
 
3
+
3
4
  module Spontaneous
5
+
4
6
  class Site < Spontaneous::Facet
5
- include Plugins::Site::Instance
6
- include Plugins::Site::Publishing
7
- include Plugins::Site::State
8
- include Plugins::Site::Selectors
9
- include Plugins::Site::Map
10
- include Plugins::Site::Search
11
- include Plugins::Site::Features
12
- include Plugins::Site::Schema
13
- include Plugins::Site::Level
14
- include Plugins::Site::Storage
15
- include Plugins::Site::URL
16
- include Plugins::Site::Hooks
17
- include Plugins::Site::Paths
18
- include Plugins::Site::Helpers
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
@@ -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
- return @@instance if @@instance
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 @@instance
25
- # @@instance = self.instance
23
+ # yield if Thread.current[:spontaneous_state_instance]
24
+ # Thread.current[:spontaneous_state_instance] = self.instance
26
25
  # yield
27
26
  # ensure
28
- # @@instance = nil
27
+ # Thread.current[:spontaneous_state_instance] = nil
29
28
  # end
30
29
 
31
30
  def working_revision
@@ -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 < Spontaneous::Page or klass < Spontaneous::Piece })
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
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Spontaneous
4
- VERSION = "0.2.0.alpha7"
4
+ VERSION = "0.2.0.beta1"
5
5
  GEM = false
6
6
  end