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
@@ -1,11 +1,9 @@
1
1
  module Locomotive
2
2
  module Import
3
- module Site
3
+ class Site < Base
4
4
 
5
- def self.process(context)
6
- site, database = context[:site], context[:database]
7
-
8
- attributes = database['site'].clone.delete_if { |name, value| %w{pages assets content_types asset_collections}.include?(name) }
5
+ def process
6
+ attributes = database['site'].clone.delete_if { |name, value| %w{name pages assets content_types asset_collections}.include?(name) }
9
7
 
10
8
  site.attributes = attributes
11
9
 
@@ -1,20 +1,18 @@
1
1
  module Locomotive
2
2
  module Import
3
- module Snippets
4
-
5
- def self.process(context)
6
- site, theme_path = context[:site], context[:theme_path]
3
+ class Snippets < Base
7
4
 
5
+ def process
8
6
  Dir[File.join(theme_path, 'snippets', '*')].each do |snippet_path|
7
+ self.log "path = #{snippet_path}"
9
8
 
10
9
  name = File.basename(snippet_path, File.extname(snippet_path)).parameterize('_')
11
-
10
+
12
11
  snippet = site.snippets.where(:slug => name).first || site.snippets.build(:name => name)
13
12
 
14
- snippet.template = File.read(snippet_path) # = site.snippets.create! :name => name, :template =>
15
-
13
+ snippet.template = File.read(snippet_path) # = site.snippets.create! :name => name, :template =>
14
+
16
15
  snippet.save!
17
- # puts "snippet = #{snippet.inspect}"
18
16
  end
19
17
  end
20
18
 
@@ -1,3 +1,4 @@
1
+ require 'responders'
1
2
  require 'inherited_resources'
2
3
  require 'inherited_resources/actions'
3
4
  require 'inherited_resources/responder'
@@ -18,19 +18,19 @@ module Locomotive
18
18
  end
19
19
 
20
20
  def first
21
- @collection.assets.first
21
+ @collection.ordered_assets.first
22
22
  end
23
23
 
24
24
  def last
25
- @collection.assets.last
25
+ @collection.ordered_assets.last
26
26
  end
27
27
 
28
28
  def each(&block)
29
- @collection.assets.each(&block)
29
+ @collection.ordered_assets.each(&block)
30
30
  end
31
31
 
32
32
  def paginate(options = {})
33
- paginated_collection = @collection.assets.paginate(options)
33
+ paginated_collection = @collection.ordered_assets.paginate(options)
34
34
  {
35
35
  :collection => paginated_collection,
36
36
  :current_page => paginated_collection.current_page,
@@ -18,20 +18,34 @@ module Locomotive
18
18
  end
19
19
 
20
20
  def first
21
- content = @content_type.ordered_contents(@context['with_scope']).first
21
+ self.collection.first
22
22
  end
23
23
 
24
24
  def last
25
- content = @content_type.ordered_contents(@context['with_scope']).last
25
+ self.collection.last
26
26
  end
27
27
 
28
28
  def each(&block)
29
- @collection ||= @content_type.ordered_contents(@context['with_scope'])
30
- @collection.each(&block)
29
+ self.collection.each(&block)
30
+ end
31
+
32
+ def api
33
+ { 'create' => @context.registers[:controller].send('admin_api_contents_url', @content_type.slug) }
34
+ end
35
+
36
+ def before_method(meth)
37
+ klass = @content_type.contents.klass # delegate to the proxy class
38
+ if (meth.to_s =~ /^group_by_.+$/) == 0
39
+ klass.send(meth, :ordered_contents)
40
+ else
41
+ klass.send(meth)
42
+ end
31
43
  end
32
44
 
45
+ protected
46
+
33
47
  def paginate(options = {})
34
- @collection ||= @content_type.ordered_contents(@context['with_scope']).paginate(options)
48
+ @collection = self.collection.paginate(options)
35
49
  {
36
50
  :collection => @collection,
37
51
  :current_page => @collection.current_page,
@@ -43,17 +57,8 @@ module Locomotive
43
57
  }
44
58
  end
45
59
 
46
- def api
47
- { 'create' => @context.registers[:controller].send('admin_api_contents_url', @content_type.slug) }
48
- end
49
-
50
- def before_method(meth)
51
- klass = @content_type.contents.klass # delegate to the proxy class
52
- if (meth.to_s =~ /^group_by_.+$/) == 0
53
- klass.send(meth, :ordered_contents)
54
- else
55
- klass.send(meth)
56
- end
60
+ def collection
61
+ @collection ||= @content_type.ordered_contents(@context['with_scope'])
57
62
  end
58
63
  end
59
64
  end
@@ -19,6 +19,10 @@ module Locomotive
19
19
  @fullpath ||= @source.fullpath
20
20
  end
21
21
 
22
+ def depth
23
+ @source.depth
24
+ end
25
+
22
26
  end
23
27
  end
24
28
  end
@@ -9,11 +9,7 @@ module Locomotive
9
9
  return '' if input.nil?
10
10
 
11
11
  unless input =~ /^(\/|http:)/
12
- segments = "stylesheets/#{input}".split('/')
13
-
14
- filename, folder = segments.pop, segments.join('/')
15
-
16
- input = asset_url(folder, filename)
12
+ input = asset_url("stylesheets/#{input}")
17
13
  end
18
14
 
19
15
  input = "#{input}.css" unless input.ends_with?('.css')
@@ -27,14 +23,7 @@ module Locomotive
27
23
  return '' if input.nil?
28
24
 
29
25
  unless input =~ /^(\/|http:)/
30
- segments = "javascripts/#{input}".split('/')
31
-
32
- filename, folder = segments.pop, segments.join('/')
33
-
34
- input = asset_url(folder, filename)
35
- # javascript = ThemeAsset.new(:site => @context.registers[:site], :folder => folder)
36
- #
37
- # input = '/' + ThemeAssetUploader.new(javascript).store_path(filename)
26
+ input = asset_url("javascripts/#{input}")
38
27
  end
39
28
 
40
29
  input = "#{input}.js" unless input.ends_with?('.js')
@@ -47,18 +36,14 @@ module Locomotive
47
36
 
48
37
  input = "images/#{input}" unless input.starts_with?('/')
49
38
 
50
- segments = input.split('/')
51
-
52
- filename, folder = segments.pop, segments.join('/')
53
-
54
- asset_url(folder, filename)
39
+ asset_url(input)
55
40
  end
56
41
 
57
42
  # Write an image tag
58
43
  # input: url of the image OR asset drop
59
44
  def image_tag(input, *args)
60
45
  image_options = inline_options(args_to_options(args))
61
- "<img src=\"#{File.join('/', get_url_from_asset(input))}\" #{image_options}/>"
46
+ "<img src=\"#{get_url_from_asset(input)}\" #{image_options}/>"
62
47
  end
63
48
 
64
49
  # Embed a flash movie into a page
@@ -83,10 +68,13 @@ module Locomotive
83
68
 
84
69
  options = args_to_options(args)
85
70
 
71
+ previous_label = options[:previous_label] || I18n.t('pagination.previous')
72
+ next_label = options[:next_label] || I18n.t('pagination.next')
73
+
86
74
  previous_link = (if paginate['previous'].blank?
87
- "<span class=\"disabled prev_page\">#{I18n.t('pagination.previous')}</span>"
75
+ "<span class=\"disabled prev_page\">#{previous_label}</span>"
88
76
  else
89
- "<a href=\"#{paginate['previous']['url']}\" class=\"prev_page\">#{I18n.t('pagination.previous')}</a>"
77
+ "<a href=\"#{paginate['previous']['url']}\" class=\"prev_page\">#{previous_label}</a>"
90
78
  end)
91
79
 
92
80
  links = ""
@@ -101,9 +89,9 @@ module Locomotive
101
89
  end
102
90
 
103
91
  next_link = (if paginate['next'].blank?
104
- "<span class=\"disabled next_page\">#{I18n.t('pagination.next')}</span>"
92
+ "<span class=\"disabled next_page\">#{next_label}</span>"
105
93
  else
106
- "<a href=\"#{paginate['next']['url']}\" class=\"next_page\">#{I18n.t('pagination.next')}</a>"
94
+ "<a href=\"#{paginate['next']['url']}\" class=\"next_page\">#{next_label}</a>"
107
95
  end)
108
96
 
109
97
  %{<div class="pagination #{options[:css]}">
@@ -131,7 +119,7 @@ module Locomotive
131
119
  # <key1>="<value1>", <key2>="<value2", ...etc
132
120
  def inline_options(options = {})
133
121
  return '' if options.empty?
134
- (options.stringify_keys.to_a.collect { |a, b| "#{a}=\"#{b}\"" }).join(' ') << ' '
122
+ (options.stringify_keys.sort.to_a.collect { |a, b| "#{a}=\"#{b}\"" }).join(' ') << ' '
135
123
  end
136
124
 
137
125
  # Get the url to be used in html tags such as image_tag, flash_tag, ...etc
@@ -140,12 +128,10 @@ module Locomotive
140
128
  input.respond_to?(:url) ? input.url : input
141
129
  end
142
130
 
143
- def asset_url(folder, filename)
144
- asset = ThemeAsset.new(:site => @context.registers[:site], :folder => folder)
145
- uploader = ThemeAssetUploader.new(asset)
146
- uploader.retrieve_from_store!(filename)
147
- uploader.url
131
+ def asset_url(path)
132
+ ThemeAssetUploader.url_for(@context.registers[:site], path)
148
133
  end
134
+
149
135
  end
150
136
 
151
137
  ::Liquid::Template.register_filter(Html)
@@ -39,7 +39,7 @@ module Locomotive
39
39
  protected
40
40
 
41
41
  def render_all_and_cache_it(context)
42
- Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
42
+ Rails.cache.fetch(@cache_key, :expires_in => @expires_in, :force => @expires_in == 0) do
43
43
  context.stack do
44
44
  context.scopes.last[@target.to_s] = Locomotive::Httparty::Webservice.consume(@url, @options.symbolize_keys)
45
45
 
@@ -1,22 +1,26 @@
1
1
  module Locomotive
2
2
  module Liquid
3
3
  module Tags
4
- # Display the children pages of the site or the current page. If not precised, nav is applied on the current page.
4
+ # Display the children pages of the site, current page or the parent page. If not precised, nav is applied on the current page.
5
5
  # The html output is based on the ul/li tags.
6
6
  #
7
7
  # Usage:
8
8
  #
9
9
  # {% nav site %} => <ul class="nav"><li class="on"><a href="/features">Features</a></li></ul>
10
10
  #
11
+ # {% nav site, no_wrapper: true, exclude: 'contact|about', id: 'main-nav' }
12
+ #
11
13
  class Nav < ::Liquid::Tag
12
14
 
13
15
  Syntax = /(#{::Liquid::Expression}+)?/
14
16
 
15
17
  def initialize(tag_name, markup, tokens, context)
16
18
  if markup =~ Syntax
17
- @site_or_page = $1 || 'page'
18
- @options = {}
19
- markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value }
19
+ @source = ($1 || 'page').gsub(/"|'/, '')
20
+ @options = { :id => 'nav' }
21
+ markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') }
22
+
23
+ @options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude]
20
24
  else
21
25
  raise ::Liquid::SyntaxError.new("Syntax Error in 'nav' - Valid syntax: nav <page|site> <options>")
22
26
  end
@@ -25,34 +29,61 @@ module Locomotive
25
29
  end
26
30
 
27
31
  def render(context)
28
- @current_page = context.registers[:page]
32
+ children_output = []
29
33
 
30
- source = context.registers[@site_or_page.to_sym]
34
+ entries = fetch_entries(context)
31
35
 
32
- # puts "#{@site_or_page.to_sym} / source = #{source.inspect}"
36
+ entries.each_with_index do |p, index|
37
+ css = []
38
+ css << 'first' if index == 0
39
+ css << 'last' if index == entries.size - 1
33
40
 
34
- if source.respond_to?(:name) # site ?
35
- source = source.pages.index.first # start from home page
36
- else
37
- source = source.parent || source
41
+ children_output << render_entry_link(p, css.join(' '))
42
+ end
43
+
44
+ output = children_output.join("\n")
45
+
46
+ if @options[:no_wrapper] != 'true'
47
+ output = %{<ul id="#{@options[:id]}">\n#{output}</ul>}
38
48
  end
39
49
 
40
- output = %{<ul id="nav">}
41
- output += source.children.map { |p| render_child_link(p) }.join("\n")
42
- output += %{</ul>}
43
50
  output
44
51
  end
45
52
 
46
53
  private
47
54
 
48
- def render_child_link(page)
49
- selected = @current_page._id == page._id ? ' on' : ''
55
+ def fetch_entries(context)
56
+ @current_page = context.registers[:page]
57
+
58
+ children = (case @source
59
+ when 'site' then context.registers[:site].pages.index.minimal_attributes.first # start from home page
60
+ when 'parent' then @current_page.parent || @current_page
61
+ when 'page' then @current_page
62
+ else
63
+ context.registers[:site].pages.fullpath(@source).minimal_attributes.first
64
+ end).children_with_minimal_attributes.to_a
65
+
66
+ children.delete_if { |p| !include_page?(p) }
67
+ end
68
+
69
+ def include_page?(page)
70
+ if page.templatized? || !page.published?
71
+ false
72
+ elsif @options[:exclude]
73
+ (page.fullpath =~ @options[:exclude]).nil?
74
+ else
75
+ true
76
+ end
77
+ end
78
+
79
+ def render_entry_link(page, css)
80
+ selected = @current_page.fullpath =~ /^#{page.fullpath}/ ? ' on' : ''
50
81
 
51
82
  icon = @options[:icon] ? '<span></span>' : ''
52
83
  label = %{#{icon if @options[:icon] != 'after' }#{page.title}#{icon if @options[:icon] == 'after' }}
53
84
 
54
85
  %{
55
- <li id="#{page.slug.dasherize}" class="link#{selected}">
86
+ <li id="#{page.slug.dasherize}" class="link#{selected} #{css}">
56
87
  <a href="/#{page.fullpath}">#{label}</a>
57
88
  </li>
58
89
  }.strip
@@ -36,13 +36,13 @@ module Locomotive
36
36
 
37
37
  raise ::Liquid::ArgumentError.new("Cannot paginate array '#{@collection_name}'. Not found.") if collection.nil?
38
38
 
39
- pagination = collection.paginate({
39
+ pagination = collection.send(:paginate, {
40
40
  :page => context['current_page'],
41
- :per_page => @per_page }).stringify_keys!
41
+ :per_page => @per_page }).stringify_keys
42
42
 
43
43
  page_count, current_page = pagination['total_pages'], pagination['current_page']
44
44
 
45
- path = context['page'].path rescue '/'
45
+ path = context.registers[:page].fullpath
46
46
 
47
47
  pagination['previous'] = link(I18n.t('pagination.previous'), current_page - 1, path) if pagination['previous_page']
48
48
  pagination['next'] = link(I18n.t('pagination.next'), current_page + 1, path) if pagination['next_page']
@@ -1,15 +1,11 @@
1
- require 'rack/utils'
2
-
3
1
  module Locomotive
4
2
  module Middlewares
5
3
  class Fonts
6
- include Rack::Utils
7
4
 
8
5
  def initialize(app, opts = {})
9
6
  @app = app
10
7
  @path_regexp = opts[:path] || %r{^/fonts/}
11
- @file_server = ::Rack::File.new(opts[:root] || "#{Rails.root}/public")
12
- @expires_in = opts[:expires_in] || 24.hour
8
+ @expires_in = opts[:expires_in] || 24.hour # varnish
13
9
  end
14
10
 
15
11
  def call(env)
@@ -19,13 +15,9 @@ module Locomotive
19
15
  if site.nil?
20
16
  @app.call(env)
21
17
  else
22
- env["PATH_INFO"] = ::File.join('/', 'sites', site.id.to_s, 'theme', env["PATH_INFO"])
23
-
24
- response = @file_server.call(env)
25
-
26
- response[1]['Cache-Control'] = "public; max-age=#{@expires_in}" # varnish
18
+ body = ThemeAssetUploader.build(site, env["PATH_INFO"]).read.to_s
27
19
 
28
- response
20
+ [200, { 'Cache-Control' => "public; max-age=#{@expires_in}" }, [body]]
29
21
  end
30
22
  else
31
23
  @app.call(env)
@@ -34,14 +34,9 @@ module Locomotive
34
34
  end
35
35
  end
36
36
 
37
- def normalize_model_name(name)
38
- if name =~ /(.+)\/(.+)/
39
- [$1, $2]
40
- else
41
- super
42
- end
37
+ def model_name
38
+ @object.present? ? (@object.class.name || @object.class.model_name) : @object_name.to_s.classify
43
39
  end
44
40
 
45
-
46
41
  end
47
42
  end
@@ -0,0 +1,16 @@
1
+ # Re-definitions are appended to existing tasks
2
+
3
+ # Embed tasks from Delayed_job
4
+
5
+ namespace :jobs do
6
+ desc "Clear the delayed_job queue."
7
+ task :clear => :environment do
8
+ Delayed::Job.delete_all
9
+ end
10
+
11
+ desc "Start a delayed_job worker."
12
+ task :work => :environment do
13
+ puts "Delayed::Job.new = #{Delayed::Job.new.inspect}"
14
+ ::Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
15
+ end
16
+ end
@@ -1,7 +1,7 @@
1
1
  module Locomotive
2
2
  module Regexps
3
3
 
4
- SUBDOMAIN = /^[a-z][a-z0-9]*[a-z0-9]{1}$/
4
+ SUBDOMAIN = /^[a-z][a-z0-9_-]*[a-z0-9]{1}$/
5
5
 
6
6
  DOMAIN = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
7
7