locomotive_cms 0.0.4 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/Gemfile +15 -13
  2. data/README.textile +5 -4
  3. data/app/controllers/admin/api_contents_controller.rb +10 -1
  4. data/app/controllers/admin/base_controller.rb +2 -2
  5. data/app/controllers/admin/cross_domain_sessions_controller.rb +7 -4
  6. data/app/controllers/admin/current_sites_controller.rb +2 -0
  7. data/app/controllers/admin/imports_controller.rb +13 -19
  8. data/app/controllers/admin/installation_controller.rb +79 -0
  9. data/app/controllers/admin/pages_controller.rb +1 -1
  10. data/app/controllers/admin/passwords_controller.rb +2 -2
  11. data/app/controllers/admin/sessions_controller.rb +2 -2
  12. data/app/controllers/admin/sites_controller.rb +2 -0
  13. data/app/controllers/admin/theme_assets_controller.rb +1 -1
  14. data/app/controllers/application_controller.rb +1 -1
  15. data/app/helpers/admin/assets_helper.rb +0 -6
  16. data/app/helpers/admin/{login_helper.rb → box_helper.rb} +7 -3
  17. data/app/helpers/admin/custom_fields_helper.rb +2 -2
  18. data/app/models/asset_collection.rb +15 -3
  19. data/app/models/content_instance.rb +19 -0
  20. data/app/models/content_type.rb +21 -3
  21. data/app/models/extensions/page/tree.rb +63 -7
  22. data/app/models/page.rb +2 -0
  23. data/app/models/site.rb +15 -3
  24. data/app/uploaders/asset_uploader.rb +1 -1
  25. data/app/uploaders/theme_asset_uploader.rb +12 -1
  26. data/app/uploaders/theme_uploader.rb +19 -0
  27. data/app/views/admin/asset_collections/edit.html.haml +2 -2
  28. data/app/views/admin/asset_collections/new.html.haml +1 -1
  29. data/app/views/admin/assets/_form.html.haml +2 -2
  30. data/app/views/admin/content_types/_form.html.haml +2 -2
  31. data/app/views/admin/content_types/new.html.haml +1 -1
  32. data/app/views/admin/contents/_form.html.haml +2 -2
  33. data/app/views/admin/contents/index.html.haml +1 -1
  34. data/app/views/admin/cross_domain_sessions/new.html.haml +1 -1
  35. data/app/views/admin/current_sites/_form.html.haml +3 -3
  36. data/app/views/admin/current_sites/edit.html.haml +1 -1
  37. data/app/views/admin/errors/no_page.html.haml +1 -0
  38. data/app/views/admin/errors/no_site.html.haml +1 -0
  39. data/app/views/admin/imports/new.html.haml +11 -0
  40. data/app/views/admin/imports/show.html.haml +1 -1
  41. data/app/views/admin/installation/step_1.html.haml +24 -0
  42. data/app/views/admin/installation/step_2.html.haml +26 -0
  43. data/app/views/admin/installation/step_3.html.haml +23 -0
  44. data/app/views/{layouts/admin → admin/layouts}/application.html.haml +0 -0
  45. data/app/views/admin/layouts/box.html.haml +21 -0
  46. data/app/views/admin/layouts/error.html.haml +1 -0
  47. data/app/views/admin/my_accounts/edit.html.haml +1 -1
  48. data/app/views/admin/pages/_form.html.haml +2 -3
  49. data/app/views/admin/pages/_page.html.haml +4 -2
  50. data/app/views/admin/pages/index.html.haml +1 -1
  51. data/app/views/admin/passwords/edit.html.haml +2 -2
  52. data/app/views/admin/passwords/new.html.haml +2 -2
  53. data/app/views/admin/sessions/new.html.haml +2 -2
  54. data/app/views/admin/shared/_head.html.haml +4 -5
  55. data/app/views/admin/shared/menu/_contents.html.haml +1 -1
  56. data/app/views/admin/sites/_form.html.haml +3 -3
  57. data/app/views/admin/snippets/_form.html.haml +2 -2
  58. data/app/views/admin/theme_assets/_form.html.haml +2 -2
  59. data/app/views/admin/theme_assets/index.html.haml +1 -1
  60. data/config/application.rb +1 -3
  61. data/config/assets.yml +96 -0
  62. data/config/environments/development.rb +1 -6
  63. data/config/environments/production.rb +1 -1
  64. data/config/environments/test.rb +1 -5
  65. data/config/initializers/carrierwave.rb +17 -0
  66. data/config/initializers/locomotive.rb +14 -0
  67. data/config/locales/admin_ui_en.yml +33 -1
  68. data/config/locales/admin_ui_fr.yml +34 -1
  69. data/config/locales/default_en.yml +1 -0
  70. data/config/locales/default_fr.yml +1 -0
  71. data/config/locales/flash.en.yml +1 -0
  72. data/config/locales/flash.fr.yml +1 -0
  73. data/config/mongoid.yml +13 -5
  74. data/config/routes.rb +6 -1
  75. data/lib/generators/locomotive/install/install_generator.rb +18 -10
  76. data/lib/generators/locomotive/install/templates/README +23 -13
  77. data/lib/generators/locomotive/install/templates/locomotive.rb +15 -1
  78. data/lib/locomotive/carrierwave.rb +1 -0
  79. data/lib/locomotive/configuration.rb +3 -1
  80. data/lib/locomotive/custom_fields.rb +0 -1
  81. data/lib/locomotive/delayed_job.rb +1 -2
  82. data/lib/locomotive/engine.rb +24 -7
  83. data/lib/locomotive/heroku.rb +1 -0
  84. data/lib/locomotive/httparty/webservice.rb +12 -1
  85. data/lib/locomotive/import.rb +2 -0
  86. data/lib/locomotive/import/asset_collections.rb +40 -8
  87. data/lib/locomotive/import/assets.rb +20 -12
  88. data/lib/locomotive/import/base.rb +46 -0
  89. data/lib/locomotive/import/content_types.rb +51 -15
  90. data/lib/locomotive/import/job.rb +106 -11
  91. data/lib/locomotive/import/logger.rb +13 -0
  92. data/lib/locomotive/import/pages.rb +79 -26
  93. data/lib/locomotive/import/site.rb +3 -5
  94. data/lib/locomotive/import/snippets.rb +6 -8
  95. data/lib/locomotive/inherited_resources.rb +1 -0
  96. data/lib/locomotive/liquid/drops/asset_collections.rb +4 -4
  97. data/lib/locomotive/liquid/drops/contents.rb +21 -16
  98. data/lib/locomotive/liquid/drops/page.rb +4 -0
  99. data/lib/locomotive/liquid/filters/html.rb +15 -29
  100. data/lib/locomotive/liquid/tags/consume.rb +1 -1
  101. data/lib/locomotive/liquid/tags/nav.rb +48 -17
  102. data/lib/locomotive/liquid/tags/paginate.rb +3 -3
  103. data/lib/locomotive/middlewares/fonts.rb +3 -11
  104. data/lib/locomotive/misc_form_builder.rb +2 -7
  105. data/lib/locomotive/railties/tasks.rake +16 -0
  106. data/lib/locomotive/regexps.rb +1 -1
  107. data/lib/locomotive/render.rb +9 -3
  108. data/lib/locomotive/routing/site_dispatcher.rb +10 -6
  109. data/lib/locomotive/version.rb +1 -1
  110. data/public/images/admin/box/buttons/right_bg.png +0 -0
  111. data/public/javascripts/admin/aloha/VERSION.txt +1 -1
  112. data/public/javascripts/admin/aloha/aloha-nodeps.js +140 -101
  113. data/public/javascripts/admin/aloha/aloha.js +193 -105
  114. data/public/javascripts/admin/aloha/css/aloha.css +65 -4
  115. data/public/javascripts/admin/aloha/deps/prettyPhoto/resources/css/prettyPhoto.css +2 -2
  116. data/public/javascripts/admin/aloha/i18n/de.dict +2 -0
  117. data/public/javascripts/admin/aloha/i18n/en.dict +2 -0
  118. data/public/javascripts/admin/aloha/i18n/pl.dict +5 -0
  119. data/public/javascripts/admin/aloha/images/base.png +0 -0
  120. data/public/javascripts/admin/aloha/images/base_big.png +0 -0
  121. data/public/javascripts/admin/aloha/images/base_multi.png +0 -0
  122. data/public/javascripts/admin/aloha/images/fade_in.png +0 -0
  123. data/public/javascripts/admin/aloha/images/fade_out.png +0 -0
  124. data/public/javascripts/admin/aloha/images/gentics_logo.png +0 -0
  125. data/public/javascripts/admin/aloha/images/grabhandle.png +0 -0
  126. data/public/javascripts/admin/aloha/images/maximize.png +0 -0
  127. data/public/javascripts/admin/aloha/images/pin.png +0 -0
  128. data/public/javascripts/admin/aloha/images/removeformat.png +0 -0
  129. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.css +86 -0
  130. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.html +44 -0
  131. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/de.dict +4 -0
  132. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/en.dict +4 -0
  133. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/fr.dict +4 -0
  134. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/plugin.js +1 -0
  135. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/product.js +1 -0
  136. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/2xu-wetsuit.jpg +0 -0
  137. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/asics-noosa.jpg +0 -0
  138. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/fivefingers-kso.jpg +0 -0
  139. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/kuota-kueen-k.jpg +0 -0
  140. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/mizuno-wave-musha2.jpg +0 -0
  141. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product.css +69 -0
  142. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product_button.gif +0 -0
  143. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/simplon-mrt.jpg +0 -0
  144. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trek-fuel-ex.jpg +0 -0
  145. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trisports.jpg +0 -0
  146. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/zoggs-predator.jpg +0 -0
  147. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/de.dict +0 -0
  148. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/en.dict +0 -0
  149. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fi.dict +0 -0
  150. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fr.dict +0 -0
  151. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/it.dict +0 -0
  152. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/plugin.js +0 -0
  153. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.css +48 -0
  154. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.html +69 -0
  155. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/de.dict +4 -0
  156. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/en.dict +4 -0
  157. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/plugin.js +7 -0
  158. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/i18n/pl.dict +30 -0
  159. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js +1 -1
  160. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.HighlightEditables/plugin.js +1 -1
  161. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/LinkList.js +7 -0
  162. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/delicious.js +7 -0
  163. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/i18n/pl.dict +4 -0
  164. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/plugin.js +1 -1
  165. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/css/LinkChecker.css +14 -0
  166. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.css +49 -0
  167. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.html +82 -0
  168. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/i18n/en.dict +27 -0
  169. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/plugin.js +7 -0
  170. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/proxy.php +235 -0
  171. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js +1 -1
  172. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/plugin.js +7 -0
  173. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/wordpastehandler.js +7 -0
  174. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/de.dict +1 -0
  175. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/en.dict +1 -0
  176. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/plugin.js +1 -1
  177. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/de.dict +2 -0
  178. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/en.dict +2 -0
  179. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/pl.dict +12 -0
  180. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js +1 -1
  181. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/table.css +28 -110
  182. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_green.png +0 -0
  183. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_red.png +0 -0
  184. data/public/javascripts/admin/asset_collections.js +11 -7
  185. data/public/javascripts/admin/contents.js +3 -1
  186. data/public/javascripts/admin/site.js +9 -3
  187. data/public/javascripts/admin/snippets.js +1 -1
  188. data/public/javascripts/admin/utils.js +5 -3
  189. data/public/stylesheets/admin/application.css +1 -1
  190. data/public/stylesheets/admin/box.css +5 -5
  191. data/public/stylesheets/admin/buttons.css +0 -5
  192. data/public/stylesheets/admin/formtastic_changes.css +5 -12
  193. data/public/stylesheets/admin/inline_editor.css +22 -5
  194. data/public/stylesheets/admin/installation.css +50 -0
  195. data/public/stylesheets/admin/layout.css +9 -4
  196. data/public/stylesheets/admin/safari.css +15 -0
  197. metadata +188 -131
  198. data/app/controllers/home_controller.rb +0 -7
  199. data/app/views/admin/snippets/index.html.haml +0 -15
  200. data/app/views/home/show.html.haml +0 -4
  201. data/app/views/layouts/admin/box.html.haml +0 -19
  202. data/app/views/layouts/application.html.haml +0 -7
  203. data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +0 -14
  204. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/de.dict +0 -2
  205. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/en.dict +0 -2
  206. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/eo.dict +0 -2
  207. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fi.dict +0 -2
  208. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fr.dict +0 -2
  209. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/it.dict +0 -2
  210. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/plugin.js +0 -7
  211. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/de.dict +0 -20
  212. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/en.dict +0 -20
  213. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/eo.dict +0 -16
  214. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fi.dict +0 -20
  215. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fr.dict +0 -16
  216. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/it.dict +0 -20
  217. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/plugin.js +0 -7
  218. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/css/jquery.autocomplete.css +0 -48
  219. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/deps/jquery.autocomplete.js +0 -1
  220. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressource.js +0 -7
  221. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourcedummy.js +0 -7
  222. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourceregistry.js +0 -7
  223. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Loader/plugin.js +0 -1
  224. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/en.dict +0 -2
  225. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fi.dict +0 -2
  226. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fr.dict +0 -2
  227. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/person.css +0 -3
  228. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/plugin.js +0 -1
  229. data/public/javascripts/admin/aloha/plugins/simpletable/plugin.js.deactivated +0 -2330
@@ -28,6 +28,7 @@ class ContentInstance
28
28
  ## methods ##
29
29
 
30
30
  alias :visible? :_visible?
31
+ alias :_permalink :_slug
31
32
 
32
33
  def site_id # needed by the uploader of custom fields
33
34
  self.content_type.site_id
@@ -37,6 +38,24 @@ class ContentInstance
37
38
  self._visible || self._visible.nil?
38
39
  end
39
40
 
41
+ def aliased_attributes # TODO: move it to the custom_fields gem
42
+ hash = { :created_at => self.created_at, :updated_at => self.updated_at }
43
+
44
+ self.custom_fields.each do |field|
45
+ case field.kind
46
+ when 'file' then hash[field._alias] = self.send(field._name.to_sym).url
47
+ else
48
+ hash[field._alias] = self.send(field._name.to_sym)
49
+ end
50
+ end
51
+
52
+ hash
53
+ end
54
+
55
+ def errors_to_hash
56
+ Hash.new.replace(self.errors)
57
+ end
58
+
40
59
  def to_liquid
41
60
  Locomotive::Liquid::Drops::Content.new(self)
42
61
  end
@@ -25,6 +25,7 @@ class ContentType
25
25
  ## callbacks ##
26
26
  before_validation :normalize_slug
27
27
  before_save :set_default_values
28
+ after_destroy :remove_uploaded_files
28
29
 
29
30
  ## validations ##
30
31
  validates_presence_of :site, :name, :slug
@@ -62,13 +63,22 @@ class ContentType
62
63
  (if conditions.nil? || conditions.empty?
63
64
  self.contents
64
65
  else
65
- self.contents.where(conditions)
66
+ conditions_with_names = {}
67
+
68
+ conditions.each do |key, value|
69
+ # convert alias (key) to name
70
+ field = self.content_custom_fields.detect { |f| f._alias == key }
71
+
72
+ conditions_with_names[field._name.to_sym] = value
73
+ end
74
+
75
+ self.contents.where(conditions_with_names)
66
76
  end).sort { |a, b| (a.send(column) || 0) <=> (b.send(column) || 0) }
67
77
  end
68
78
 
69
79
  def sort_contents!(order)
70
80
  order.split(',').each_with_index do |id, position|
71
- self.contents.find(id)._position_in_list = position
81
+ self.contents.find(BSON::ObjectId(id))._position_in_list = position
72
82
  end
73
83
  self.save
74
84
  end
@@ -84,7 +94,7 @@ class ContentType
84
94
  protected
85
95
 
86
96
  def set_default_values
87
- self.order_by ||= 'updated_at'
97
+ self.order_by ||= 'created_at'
88
98
  self.highlighted_field_name ||= self.content_custom_fields.first._name
89
99
  end
90
100
 
@@ -93,4 +103,12 @@ class ContentType
93
103
  self.slug.slugify! if self.slug.present?
94
104
  end
95
105
 
106
+ def remove_uploaded_files # callbacks are not called on each content so we do it manually
107
+ self.contents.each do |content|
108
+ self.content_custom_fields.each do |field|
109
+ content.send(:"remove_#{field._name}!") if field.kind == 'file'
110
+ end
111
+ end
112
+ end
113
+
96
114
  end
@@ -27,11 +27,65 @@ module Models
27
27
  alias :descendants :hacked_descendants
28
28
  end
29
29
 
30
+ module ClassMethods
31
+
32
+ # Warning: used only in read-only
33
+ def quick_tree(site)
34
+ pages = site.pages.minimal_attributes.order_by([[:depth, :asc], [:position, :asc]]).to_a
35
+
36
+ tmp = []
37
+
38
+ while !pages.empty?
39
+ tmp << _quick_tree(pages.delete_at(0), pages)
40
+ end
41
+
42
+ tmp
43
+ end
44
+
45
+ def _quick_tree(current_page, pages)
46
+ i, children = 0, []
47
+
48
+ while !pages.empty?
49
+ page = pages[i]
50
+
51
+ break if page.nil?
52
+
53
+ if page.parent_id == current_page.id
54
+ page = pages.delete_at(i)
55
+
56
+ children << _quick_tree(page, pages)
57
+ else
58
+ i += 1
59
+ end
60
+ end
61
+
62
+ current_page.instance_eval do
63
+ def children=(list); @children = list; end
64
+ def children; @children || []; end
65
+ end
66
+
67
+ current_page.children = children
68
+
69
+ current_page
70
+ end
71
+
72
+ end
73
+
30
74
  module InstanceMethods
31
75
 
76
+ def children?
77
+ self.class.where(self.parent_id_field => self.id).count
78
+ end
79
+
80
+ def children_with_minimal_attributes
81
+ self.class.where(self.parent_id_field => self.id).
82
+ order_by(self.tree_order).
83
+ minimal_attributes
84
+ end
85
+
32
86
  def sort_children!(ids)
33
87
  ids.each_with_index do |id, position|
34
- child = self.children.detect { |p| p._id == id }
88
+ child = self.children.detect { |p| p._id == BSON::ObjectId(id) }
35
89
  child.position = position
36
90
  child.save
37
91
  end
@@ -44,10 +98,7 @@ module Models
44
98
  end
45
99
 
46
100
  def hacked_descendants
47
- # workorund for mongoid unexpected behavior
48
- _new_record_var = self.instance_variable_get(:@new_record)
49
- _new_record = _new_record_var != false
50
- return [] if _new_record
101
+ return [] if new_record?
51
102
  self.class.all_in(path_field => [self._id]).order_by tree_order
52
103
  end
53
104
 
@@ -56,7 +107,12 @@ module Models
56
107
  def change_parent
57
108
  if self.parent_id_changed?
58
109
  self.fix_position(false)
59
- self.add_to_list_bottom
110
+
111
+ unless self.parent_id_was.nil?
112
+ self.position = nil # make it move to bottom
113
+ self.add_to_list_bottom
114
+ end
115
+
60
116
  self.instance_variable_set :@_will_move, true
61
117
  end
62
118
  end
@@ -81,7 +137,7 @@ module Models
81
137
  end
82
138
 
83
139
  def add_to_list_bottom
84
- self.position = (::Page.where(:_id.ne => self._id).and(:parent_id => self.parent_id).max(:position) || 0) + 1
140
+ self.position ||= (::Page.where(:_id.ne => self._id).and(:parent_id => self.parent_id).max(:position) || 0) + 1
85
141
  end
86
142
 
87
143
  def remove_from_list
@@ -40,6 +40,8 @@ class Page
40
40
  scope :index, :where => { :slug => 'index', :depth => 0 }
41
41
  scope :not_found, :where => { :slug => '404', :depth => 0 }
42
42
  scope :published, :where => { :published => true }
43
+ scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } }
44
+ scope :minimal_attributes, :only => %w(title slug fullpath position depth published templatized parent_id created_at updated_at)
43
45
 
44
46
  ## methods ##
45
47
 
@@ -40,6 +40,14 @@ class Site
40
40
 
41
41
  ## methods ##
42
42
 
43
+ def all_pages_in_once
44
+ Page.quick_tree(self)
45
+ end
46
+
47
+ def domains=(array)
48
+ array = [] if array.blank?; super(array)
49
+ end
50
+
43
51
  def accounts
44
52
  Account.criteria.in(:_id => self.memberships.collect(&:account_id))
45
53
  end
@@ -50,15 +58,19 @@ class Site
50
58
 
51
59
  def add_subdomain_to_domains
52
60
  self.domains ||= []
53
- (self.domains << "#{self.subdomain}.#{Locomotive.config.default_domain}").uniq!
61
+ (self.domains << self.full_subdomain).uniq!
54
62
  end
55
63
 
56
64
  def domains_without_subdomain
57
- (self.domains || []) - ["#{self.subdomain}.#{Locomotive.config.default_domain}"]
65
+ (self.domains || []) - [self.full_subdomain]
58
66
  end
59
67
 
60
68
  def domains_with_subdomain
61
- ((self.domains || []) + ["#{self.subdomain}.#{Locomotive.config.default_domain}"]).uniq
69
+ ((self.domains || []) + [self.full_subdomain]).uniq
70
+ end
71
+
72
+ def full_subdomain
73
+ "#{self.subdomain}.#{Locomotive.config.default_domain}"
62
74
  end
63
75
 
64
76
  def to_liquid
@@ -60,7 +60,7 @@ class AssetUploader < CarrierWave::Uploader::Base
60
60
 
61
61
  def self.content_types
62
62
  {
63
- :image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'],
63
+ :image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'image/x-icon'],
64
64
  :video => [/^video/, 'application/x-shockwave-flash', 'application/x-swf'],
65
65
  :audio => [/^audio/, 'application/ogg', 'application/x-mp3'],
66
66
  :pdf => ['application/pdf', 'application/x-pdf'],
@@ -15,7 +15,18 @@ class ThemeAssetUploader < AssetUploader
15
15
  end
16
16
 
17
17
  def extension_white_list
18
- %w(jpg jpeg gif png css js swf flv eot svg ttf woff)
18
+ %w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico)
19
+ end
20
+
21
+ def self.url_for(site, path)
22
+ build(site, path).url
23
+ end
24
+
25
+ def self.build(site, path)
26
+ asset = ThemeAsset.new(:site => site, :folder => File.dirname(path))
27
+ uploader = ThemeAssetUploader.new(asset)
28
+ uploader.retrieve_from_store!(File.basename(path))
29
+ uploader
19
30
  end
20
31
 
21
32
  end
@@ -0,0 +1,19 @@
1
+ class ThemeUploader < ::CarrierWave::Uploader::Base
2
+
3
+ def store_dir
4
+ if Locomotive.config.delayed_job
5
+ "sites/#{model.id}/tmp/themes"
6
+ else
7
+ "#{Rails.root}/tmp/themes"
8
+ end
9
+ end
10
+
11
+ def cache_dir
12
+ "#{Rails.root}/tmp/uploads"
13
+ end
14
+
15
+ def extension_white_list
16
+ %w(zip)
17
+ end
18
+
19
+ end
@@ -1,8 +1,8 @@
1
1
  - title link_to(@asset_collection.name.blank? ? @asset_collection.name_was : @asset_collection.name, '#', :rel => 'asset_collection_name', :title => t('.ask_for_name'), :class => 'editable')
2
2
 
3
3
  - content_for :head do
4
- = javascript_include_tag 'admin/plugins/fancybox', 'admin/asset_collections', 'admin/custom_fields'
5
- = stylesheet_link_tag 'admin/plugins/fancybox', 'admin/fancybox_changes'
4
+ = include_javascripts :asset_collections
5
+ = include_stylesheets :fancybox
6
6
 
7
7
  - content_for :submenu do
8
8
  = render 'admin/shared/menu/assets'
@@ -1,7 +1,7 @@
1
1
  - title t('.title')
2
2
 
3
3
  - content_for :head do
4
- = javascript_include_tag 'admin/asset_collections.js'
4
+ = include_javascripts :asset_collections
5
5
 
6
6
  - content_for :submenu do
7
7
  = render 'admin/shared/menu/assets'
@@ -1,6 +1,6 @@
1
1
  - content_for :head do
2
- = javascript_include_tag 'admin/plugins/tiny_mce/tinymce', 'admin/plugins/json2', 'admin/plugins/fancybox', 'admin/custom_fields/category', 'admin/assets'
3
- = stylesheet_link_tag 'admin/plugins/fancybox', 'admin/box'
2
+ = include_javascripts :edit_custom_fields, :assets
3
+ = include_stylesheets :custom_fields
4
4
 
5
5
  = f.inputs :name => :information do
6
6
  = f.input :name
@@ -1,6 +1,6 @@
1
1
  - content_for :head do
2
- = javascript_include_tag 'admin/plugins/fancybox', 'admin/custom_fields'
3
- = stylesheet_link_tag 'admin/plugins/fancybox', 'admin/fancybox_changes'
2
+ = include_javascripts :custom_fields
3
+ = include_stylesheets :fancybox
4
4
 
5
5
  = f.inputs :name => :information do
6
6
  = f.input :name
@@ -1,7 +1,7 @@
1
1
  - title t('.title')
2
2
 
3
3
  - content_for :head do
4
- = javascript_include_tag 'admin/content_types.js'
4
+ = include_javascripts :content_types
5
5
 
6
6
  - content_for :submenu do
7
7
  = render 'admin/shared/menu/contents'
@@ -1,5 +1,5 @@
1
1
  - content_for :head do
2
- = javascript_include_tag 'admin/plugins/tiny_mce/tinymce', 'admin/plugins/json2', 'admin/plugins/fancybox', 'admin/custom_fields/category', 'admin/contents'
3
- = stylesheet_link_tag 'admin/plugins/fancybox', 'admin/fancybox_changes'
2
+ = include_javascripts :edit_custom_fields, :contents
3
+ = include_stylesheets :fancybox
4
4
 
5
5
  = render 'admin/custom_fields/custom_form', :form => f, :title => :attributes, :parent => @content_type
@@ -4,7 +4,7 @@
4
4
  = render 'admin/shared/menu/contents'
5
5
 
6
6
  - content_for :head do
7
- = javascript_include_tag 'admin/contents'
7
+ = include_javascripts :contents
8
8
 
9
9
  - content_for :buttons do
10
10
  = admin_button_tag :edit, edit_admin_content_type_url(@content_type), :class => 'edit'
@@ -8,7 +8,7 @@
8
8
  %p.notice= t('.notice')
9
9
 
10
10
  .footer
11
- = login_button_tag t('admin.buttons.switch_to_site')
11
+ = box_button_tag t('admin.buttons.switch_to_site')
12
12
 
13
13
  :javascript
14
14
  $(document).ready(function() { $('form').submit(); });
@@ -1,5 +1,5 @@
1
1
  - content_for :head do
2
- = javascript_include_tag 'admin/site'
2
+ = include_javascripts :site
3
3
 
4
4
  = f.foldable_inputs :name => :information, :style => "#{'display: none' unless @site.new_record?}" do
5
5
  = f.input :name, :required => false
@@ -23,7 +23,7 @@
23
23
  %li{ :class => "item added #{'last' if index == @site.domains.size - 1}"}
24
24
  %em
25
25
  http://
26
- = text_field_tag 'current_site[domains][]', name
26
+ = text_field_tag 'site[domains][]', name, :class => 'string label void domain'
27
27
  &nbsp;
28
28
  = error_on_domain(@site, name)
29
29
  %span.actions
@@ -32,7 +32,7 @@
32
32
  %li.item.template
33
33
  %em
34
34
  http://
35
- = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void'
35
+ = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'
36
36
  &nbsp;
37
37
  %span.actions
38
38
  = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm')
@@ -9,7 +9,7 @@
9
9
 
10
10
  %p!= t('.help')
11
11
 
12
- = semantic_form_for @site, :as => :current_site, :url => admin_current_site_url, :html => { :class => 'save-with-shortcut' } do |f|
12
+ = semantic_form_for @site, :url => admin_current_site_url, :html => { :class => 'save-with-shortcut' } do |f|
13
13
 
14
14
  = render 'form', :f => f
15
15
 
@@ -0,0 +1 @@
1
+ No Page!
@@ -0,0 +1 @@
1
+ No Site!
@@ -18,4 +18,15 @@
18
18
  %p.inline-errors= @error
19
19
  %p.inline-hints= t('formtastic.hints.import.source')
20
20
 
21
+ %li.input.toggle
22
+ = label_tag 'samples', t('formtastic.labels.import.new.samples')
23
+ = check_box_tag 'samples'
24
+ %p.inline-hints= t('formtastic.hints.import.samples')
25
+
26
+ %li.input.toggle
27
+ = label_tag 'reset', t('formtastic.labels.import.new.reset')
28
+ = check_box_tag 'reset'
29
+ %p.inline-hints= t('formtastic.hints.import.reset')
30
+
31
+
21
32
  = render 'admin/shared/form_actions', :button_label => :send
@@ -1,5 +1,5 @@
1
1
  - content_for :head do
2
- = javascript_include_tag 'admin/plugins/json2', 'admin/plugins/smartupdater', 'admin/import'
2
+ = include_javascripts :import
3
3
 
4
4
  - title t('.title')
5
5
 
@@ -0,0 +1,24 @@
1
+ - content_for :head_title do
2
+ = t('admin.installation.common.title')
3
+
4
+ - title t('.title')
5
+
6
+ - content_for :head do
7
+ = include_stylesheets :installation
8
+
9
+ .inner
10
+ %p.explanations
11
+ = t('.explanations')
12
+
13
+ %dl
14
+ %dt!= t('.database.label', :name => Mongoid.config.database.name)
15
+ %dd
16
+ %p.notes!= t('.database.notes')
17
+
18
+ %dt!= t('.default_domain.label', :name => Locomotive.config.default_domain)
19
+ %dd
20
+ %p.notes!= t('.default_domain.notes', :domain => Locomotive.config.default_domain)
21
+
22
+
23
+ .footer
24
+ = next_installation_step_link(2)