locomotivecms 3.0.0.pre.alpha.2 → 3.0.0.pre.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +1 -1
  4. data/app/api/locomotive/api/forms/membership_form.rb +13 -0
  5. data/app/api/locomotive/api/resources/membership_resource.rb +5 -3
  6. data/app/assets/javascripts/locomotive.js +2 -0
  7. data/app/assets/javascripts/locomotive/utils/backbone_patches.js.coffee +15 -1
  8. data/app/assets/javascripts/locomotive/utils/file.js.coffee +20 -0
  9. data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +5 -0
  10. data/app/assets/javascripts/locomotive/utils/rails_ujs.js.coffee +36 -0
  11. data/app/assets/javascripts/locomotive/utils/wysihtml5.js.coffee +1 -1
  12. data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +9 -17
  13. data/app/assets/javascripts/locomotive/views/editable_elements/edit_view.js.coffee +39 -0
  14. data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +104 -1
  15. data/app/assets/javascripts/locomotive/views/inputs/file_view.js.coffee +79 -10
  16. data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +24 -4
  17. data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +18 -0
  18. data/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +3 -6
  19. data/app/assets/javascripts/locomotive/views/shared/drawer_view.js.coffee +24 -8
  20. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +21 -148
  21. data/app/assets/stylesheets/locomotive/application.scss +6 -0
  22. data/app/assets/stylesheets/locomotive/base/_form.scss +1 -0
  23. data/app/assets/stylesheets/locomotive/base/form/_base.scss +9 -0
  24. data/app/assets/stylesheets/locomotive/base/form/_file_input.scss +1 -1
  25. data/app/assets/stylesheets/locomotive/base/form/_link.scss +13 -0
  26. data/app/assets/stylesheets/locomotive/base/form/_select2.scss +28 -1
  27. data/app/assets/stylesheets/locomotive/components/_drawer.scss +8 -18
  28. data/app/assets/stylesheets/locomotive/components/_live_editing.scss +83 -0
  29. data/app/assets/stylesheets/locomotive/components/_transitions.scss +63 -1
  30. data/app/assets/stylesheets/locomotive/components/header/_base.scss +5 -1
  31. data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +5 -7
  32. data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +4 -4
  33. data/app/assets/stylesheets/locomotive/globals/_mixins.scss +16 -0
  34. data/app/assets/stylesheets/locomotive/globals/_nprogress.scss +3 -0
  35. data/app/assets/stylesheets/locomotive/globals/_variables.scss +57 -49
  36. data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +29 -0
  37. data/app/controllers/locomotive/editable_elements_controller.rb +49 -2
  38. data/app/controllers/locomotive/pages_controller.rb +2 -2
  39. data/app/helpers/locomotive/custom_fields_helper.rb +1 -1
  40. data/app/helpers/locomotive/editable_elements_helper.rb +40 -0
  41. data/app/helpers/locomotive/pages_helper.rb +0 -1
  42. data/app/inputs/locomotive/array_input.rb +1 -1
  43. data/app/inputs/locomotive/file_input.rb +35 -7
  44. data/app/inputs/locomotive/rte_input.rb +2 -1
  45. data/app/inputs/locomotive/toggle_input.rb +1 -1
  46. data/app/models/locomotive/concerns/content_entry/localized.rb +4 -4
  47. data/app/models/locomotive/concerns/content_type/sync.rb +0 -5
  48. data/app/models/locomotive/concerns/page/redirect.rb +1 -1
  49. data/app/models/locomotive/content_entry.rb +5 -11
  50. data/app/models/locomotive/content_type.rb +22 -0
  51. data/app/models/locomotive/editable_control.rb +12 -27
  52. data/app/models/locomotive/editable_element.rb +8 -0
  53. data/app/models/locomotive/editable_file.rb +0 -1
  54. data/app/models/locomotive/editable_text.rb +10 -10
  55. data/app/models/locomotive/page.rb +1 -1
  56. data/app/policies/locomotive/page_policy.rb +1 -1
  57. data/app/services/locomotive/editable_element_service.rb +47 -0
  58. data/app/services/locomotive/page_parsing_service.rb +85 -31
  59. data/app/uploaders/locomotive/editable_file_uploader.rb +5 -1
  60. data/app/views/locomotive/editable_elements/_edit.html.haml +49 -0
  61. data/app/views/locomotive/editable_elements/_edit_with_content_entry.html.haml +21 -0
  62. data/app/views/locomotive/editable_elements/_form.html.haml +23 -0
  63. data/app/views/locomotive/editable_elements/index.html.haml +8 -2
  64. data/app/views/locomotive/editable_elements/index_without_preview.html.haml +33 -0
  65. data/app/views/locomotive/layouts/{preview.html.haml → live_editing.html.haml} +9 -9
  66. data/app/views/locomotive/my_account/form/_main.html.haml +1 -1
  67. data/app/views/locomotive/pages/form/_actions.html.haml +8 -1
  68. data/app/views/locomotive/pages/form/_main.html.haml +1 -1
  69. data/app/views/locomotive/pages/form/_tabs.html.haml +2 -2
  70. data/app/views/locomotive/pages/new.html.haml +1 -1
  71. data/app/views/locomotive/shared/header/_site.html.haml +1 -1
  72. data/app/views/locomotive/shared/rte/_image_popover.html.haml +2 -2
  73. data/app/views/locomotive/shared/rte/_link_popover.html.haml +1 -1
  74. data/app/views/locomotive/shared/sidebar/_page.html.haml +5 -2
  75. data/config/locales/admin_ui.en.yml +10 -16
  76. data/config/locales/inputs.en.yml +18 -11
  77. data/config/locales/simple_form.en.yml +13 -1
  78. data/config/routes.rb +3 -1
  79. data/lib/locomotive.rb +1 -1
  80. data/lib/locomotive/action_controller/responder.rb +16 -0
  81. data/lib/locomotive/carrierwave/patches.rb +54 -0
  82. data/lib/locomotive/dependencies.rb +1 -0
  83. data/lib/locomotive/engine.rb +9 -3
  84. data/lib/locomotive/middlewares.rb +1 -1
  85. data/lib/locomotive/middlewares/page_editing.rb +41 -0
  86. data/lib/locomotive/middlewares/site.rb +2 -0
  87. data/lib/locomotive/simple_form.rb +6 -5
  88. data/lib/locomotive/steam_adaptor.rb +2 -0
  89. data/lib/locomotive/version.rb +1 -1
  90. data/lib/tasks/development.rake +4 -0
  91. data/spec/dummy/config/environments/production.rb +2 -0
  92. data/spec/dummy/config/initializers/devise.rb +2 -0
  93. data/spec/dummy/config/mongoid.yml +2 -2
  94. data/spec/models/locomotive/content_entry_spec.rb +11 -2
  95. data/spec/support/factories.rb +0 -1
  96. data/vendor/assets/javascripts/locomotive/history.js +2122 -0
  97. data/vendor/assets/javascripts/locomotive/subscribe.js +206 -329
  98. metadata +44 -127
  99. data/lib/locomotive/middlewares/permalink.rb +0 -22
  100. data/lib/locomotive/previous_liquid/asset_host.rb +0 -51
  101. data/lib/locomotive/previous_liquid/drops/base.rb +0 -40
  102. data/lib/locomotive/previous_liquid/drops/content_entry.rb +0 -78
  103. data/lib/locomotive/previous_liquid/drops/content_types.rb +0 -119
  104. data/lib/locomotive/previous_liquid/drops/current_user.rb +0 -21
  105. data/lib/locomotive/previous_liquid/drops/page.rb +0 -115
  106. data/lib/locomotive/previous_liquid/drops/proxy_collection.rb +0 -64
  107. data/lib/locomotive/previous_liquid/drops/session_proxy.rb +0 -16
  108. data/lib/locomotive/previous_liquid/drops/site.rb +0 -29
  109. data/lib/locomotive/previous_liquid/drops/uploader.rb +0 -21
  110. data/lib/locomotive/previous_liquid/errors.rb +0 -8
  111. data/lib/locomotive/previous_liquid/filters/base.rb +0 -61
  112. data/lib/locomotive/previous_liquid/filters/date.rb +0 -82
  113. data/lib/locomotive/previous_liquid/filters/html.rb +0 -117
  114. data/lib/locomotive/previous_liquid/filters/misc.rb +0 -75
  115. data/lib/locomotive/previous_liquid/filters/resize.rb +0 -18
  116. data/lib/locomotive/previous_liquid/filters/text.rb +0 -53
  117. data/lib/locomotive/previous_liquid/filters/translate.rb +0 -38
  118. data/lib/locomotive/previous_liquid/patches.rb +0 -21
  119. data/lib/locomotive/previous_liquid/tags/consume.rb +0 -104
  120. data/lib/locomotive/previous_liquid/tags/csrf.rb +0 -40
  121. data/lib/locomotive/previous_liquid/tags/editable.rb +0 -4
  122. data/lib/locomotive/previous_liquid/tags/editable/base.rb +0 -88
  123. data/lib/locomotive/previous_liquid/tags/editable/control.rb +0 -41
  124. data/lib/locomotive/previous_liquid/tags/editable/file.rb +0 -43
  125. data/lib/locomotive/previous_liquid/tags/editable/text.rb +0 -79
  126. data/lib/locomotive/previous_liquid/tags/extends.rb +0 -47
  127. data/lib/locomotive/previous_liquid/tags/fetch_page.rb +0 -36
  128. data/lib/locomotive/previous_liquid/tags/google_analytics.rb +0 -39
  129. data/lib/locomotive/previous_liquid/tags/hybrid.rb +0 -25
  130. data/lib/locomotive/previous_liquid/tags/inherited_block.rb +0 -31
  131. data/lib/locomotive/previous_liquid/tags/inline_editor.rb +0 -40
  132. data/lib/locomotive/previous_liquid/tags/javascript.rb +0 -16
  133. data/lib/locomotive/previous_liquid/tags/link_to.rb +0 -43
  134. data/lib/locomotive/previous_liquid/tags/locale_switcher.rb +0 -83
  135. data/lib/locomotive/previous_liquid/tags/model_form.rb +0 -75
  136. data/lib/locomotive/previous_liquid/tags/nav.rb +0 -164
  137. data/lib/locomotive/previous_liquid/tags/paginate.rb +0 -114
  138. data/lib/locomotive/previous_liquid/tags/path_helper.rb +0 -85
  139. data/lib/locomotive/previous_liquid/tags/path_to.rb +0 -21
  140. data/lib/locomotive/previous_liquid/tags/seo.rb +0 -72
  141. data/lib/locomotive/previous_liquid/tags/session_assign.rb +0 -39
  142. data/lib/locomotive/previous_liquid/tags/snippet.rb +0 -75
  143. data/lib/locomotive/previous_liquid/tags/with_scope.rb +0 -65
  144. data/spec/fixtures/portfolio/Gemfile +0 -21
  145. data/spec/fixtures/portfolio/app/content_types/messages.yml +0 -57
  146. data/spec/fixtures/portfolio/app/content_types/projects.yml +0 -74
  147. data/spec/fixtures/portfolio/app/views/pages/404.liquid.haml +0 -10
  148. data/spec/fixtures/portfolio/app/views/pages/index.liquid.haml +0 -213
  149. data/spec/fixtures/portfolio/app/views/snippets/footer.liquid.haml +0 -2
  150. data/spec/fixtures/portfolio/config.ru +0 -3
  151. data/spec/fixtures/portfolio/config/deploy.yml +0 -18
  152. data/spec/fixtures/portfolio/config/site.yml +0 -33
  153. data/spec/fixtures/portfolio/config/translations.yml +0 -8
  154. data/spec/fixtures/portfolio/data/messages.yml +0 -1
  155. data/spec/fixtures/portfolio/data/projects.yml +0 -41
  156. data/spec/fixtures/portfolio/icon.png +0 -0
  157. data/spec/fixtures/portfolio/public/javascripts/bootstrap.min.js +0 -6
  158. data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.js +0 -44
  159. data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.min.js +0 -11
  160. data/spec/fixtures/portfolio/public/javascripts/classie.js +0 -80
  161. data/spec/fixtures/portfolio/public/javascripts/contact_me.js +0 -65
  162. data/spec/fixtures/portfolio/public/javascripts/freelancer.js +0 -37
  163. data/spec/fixtures/portfolio/public/javascripts/jqBootstrapValidation.js +0 -912
  164. data/spec/fixtures/portfolio/public/samples/portfolio/cabin.png +0 -0
  165. data/spec/fixtures/portfolio/public/samples/portfolio/cake.png +0 -0
  166. data/spec/fixtures/portfolio/public/samples/portfolio/circus.png +0 -0
  167. data/spec/fixtures/portfolio/public/samples/portfolio/game.png +0 -0
  168. data/spec/fixtures/portfolio/public/samples/portfolio/safe.png +0 -0
  169. data/spec/fixtures/portfolio/public/samples/portfolio/submarine.png +0 -0
  170. data/spec/fixtures/portfolio/public/samples/profile.png +0 -0
  171. data/spec/fixtures/portfolio/public/stylesheets/bootstrap.min.css +0 -7
  172. data/spec/fixtures/portfolio/public/stylesheets/freelancer.css +0 -445
  173. data/spec/lib/locomotive/liquid/tags/editable/file_spec.rb +0 -72
  174. data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +0 -85
  175. data/spec/lib/locomotive/liquid/tags/extends_spec.rb +0 -58
  176. data/vendor/assets/javascripts/locomotive/editable_field.js +0 -50
  177. data/vendor/assets/javascripts/locomotive/form_submit_notification.js +0 -39
  178. data/vendor/assets/javascripts/locomotive/slugify.js +0 -47
@@ -2,7 +2,7 @@
2
2
  .navbar-text
3
3
  = _title
4
4
  - else
5
+ = link_to current_site.name_was, dashboard_path(current_site)
5
6
  = link_to preview_path(current_site) do
6
- = current_site.name_was
7
7
  %span.arrow
8
8
  %i.fa.fa-external-link
@@ -1,12 +1,12 @@
1
1
  .image-dialog-content{ style: 'display: none' }
2
- = locomotive_form_for image_form, url: '#' do |f|
2
+ = locomotive_form_for image_form, url: '#', defaults: { placeholder: false, hint: false } do |f|
3
3
  = f.inputs do
4
4
  = f.input :src
5
5
  = f.input :title
6
6
  = f.input :alignment, include_blank: false, collection: [[:default, ''],
7
7
  [:left, 'wysiwyg-float-left'],
8
8
  [:right, 'wysiwyg-float-right']],
9
- label_method: ->(el) { t("simple_form.options.locomotive.rte_input_image_form.target.#{el.first}") }
9
+ label_method: ->(el) { t("simple_form.options.locomotive.rte_input_image_form.alignment.#{el.first}") }
10
10
 
11
11
  %p.text-right
12
12
  %a.btn.btn-success.btn-sm.apply
@@ -1,5 +1,5 @@
1
1
  .link-dialog-content{ style: 'display: none' }
2
- = locomotive_form_for link_form, url: '#' do |f|
2
+ = locomotive_form_for link_form, url: '#', defaults: { placeholder: false, hint: false } do |f|
3
3
  = f.inputs do
4
4
  = f.input :url
5
5
  = f.input :target, include_blank: false, collection: [[:not_set, ''],
@@ -2,7 +2,9 @@
2
2
 
3
3
  %i{ class: "fa #{page.icon} icon #{page.draggable}" }
4
4
 
5
- = link_to edit_page_path(current_site, page) do
5
+ - url = page.redirect? ? edit_page_path(current_site, page) : editable_elements_path(current_site, page)
6
+
7
+ = link_to url do
6
8
  %span.text= page.title
7
9
 
8
10
  - unless page.translated?
@@ -16,7 +18,8 @@
16
18
 
17
19
  %ul.leaves{ data: { url: sort_page_path(current_site, page) } }
18
20
 
19
- = render partial: 'locomotive/shared/sidebar/page', collection: page.nodes
21
+ - unless page.content_type && page.nodes.count == 1
22
+ = render partial: 'locomotive/shared/sidebar/page', collection: page.nodes
20
23
 
21
24
  - if page.content_type
22
25
  %li.list-entries
@@ -56,20 +56,6 @@ en:
56
56
  site: Site
57
57
  theme_assets: Theme files
58
58
  translations: Translations
59
- form:
60
- file_input:
61
- none: no file
62
- choose: Choose
63
- change: Change
64
- delete: Delete
65
- cancel: Cancel
66
- array_input:
67
- new: New
68
- add: Add
69
- edit: Edit
70
- toggle_input:
71
- on_text: "Yes"
72
- off_text: "No"
73
59
  form_actions:
74
60
  back: Back without saving
75
61
  create: Create
@@ -177,7 +163,7 @@ en:
177
163
 
178
164
  pages:
179
165
  index:
180
- title: Listing pages
166
+ title: Pages
181
167
  help: "Pages are organized as a tree. You can order pages as well as folders"
182
168
  no_items: "There are no pages for now. Just click <a href=\"%{url}\">here</a> to create the first one."
183
169
  new: new page
@@ -197,6 +183,14 @@ en:
197
183
  permanent: "Permanent (301)"
198
184
  temporary: "Temporary (302)"
199
185
 
186
+ editable_elements:
187
+ index:
188
+ redirection_error: "Editing a non Locomotive page is not allowed."
189
+ index_without_preview:
190
+ title: "%{title} &mdash; <small>%{fullpath}</small>"
191
+ edit:
192
+ settings_link: 'Settings'
193
+
200
194
  sites:
201
195
  index:
202
196
  title: My sites
@@ -286,7 +280,7 @@ en:
286
280
 
287
281
  content_types:
288
282
  index:
289
- title: Listing models
283
+ title: Models
290
284
  new: new model
291
285
  edit: edit model
292
286
  new:
@@ -1,14 +1,21 @@
1
1
  en:
2
2
  locomotive:
3
3
  inputs:
4
- rte:
5
- link:
6
- url: Link URL
7
- target: Target
8
- target_options:
9
- "not_set": "--Not set--"
10
- "self": "Open link in the same window"
11
- "blank": "Open link in a new window"
12
- title: Title
13
- ok: Ok
14
- cancel: Cancel
4
+ file:
5
+ none: no file
6
+ choose: Choose
7
+ change: Change
8
+ delete: Delete
9
+ cancel: Cancel
10
+ select_local_file: Upload local file
11
+ select_content_asset: Select among assets
12
+
13
+ array:
14
+ new: New
15
+ add: Add
16
+ edit: Edit
17
+
18
+ toggle:
19
+ on_text: "Yes"
20
+ off_text: "No"
21
+
@@ -55,6 +55,8 @@ en:
55
55
  page:
56
56
  seo_title: Title
57
57
  target_klass_name: Model
58
+ editable_element:
59
+ region: Region
58
60
  site:
59
61
  locales: Languages
60
62
  timezone_name: Timezone
@@ -67,6 +69,10 @@ en:
67
69
  url: Link URL
68
70
  target: Target
69
71
  title: Title
72
+ rte_input_image_form:
73
+ src: Source
74
+ title: Title
75
+ alignment: Alignment
70
76
  image_resize_form:
71
77
  width: Width
72
78
  height: Height
@@ -154,6 +160,11 @@ en:
154
160
  not_set: "Not set"
155
161
  self: "Open link in the same window"
156
162
  blank: "Open link in a new window"
163
+ rte_input_image_form:
164
+ alignment:
165
+ default: Default
166
+ left: Left
167
+ right: Right
157
168
 
158
169
  buttons:
159
170
  defaults:
@@ -162,7 +173,8 @@ en:
162
173
  update: Save
163
174
  submit: Ok
164
175
  cancel: Cancel
165
- loading_text: "Your form is being submitted"
176
+ loading_text: "Saving..."
177
+ or: or
166
178
  locomotive:
167
179
  image_resize_form:
168
180
  loading_text: Resizing...
@@ -33,7 +33,9 @@ Locomotive::Engine.routes.draw do
33
33
  get :get_path, on: :collection
34
34
  end
35
35
 
36
- resources :editable_elements, only: [:index], path: 'pages/:page_id/editable_elements'
36
+ resources :editable_elements, only: [:index, :update_all], path: 'pages/:page_id/editable_elements' do
37
+ patch :update_all, on: :collection
38
+ end
37
39
 
38
40
  resources :accounts
39
41
 
@@ -15,7 +15,7 @@ require 'locomotive/custom_fields'
15
15
  require 'locomotive/action_controller'
16
16
  require 'locomotive/rails'
17
17
  require 'locomotive/regexps'
18
- require 'locomotive/middlewares'
18
+ # require 'locomotive/middlewares'
19
19
 
20
20
  module Locomotive
21
21
  extend ActiveSupport::Autoload
@@ -16,6 +16,22 @@ module Locomotive
16
16
  super.merge(policy: policy)
17
17
  end
18
18
 
19
+ def to_html
20
+ if controller.request.headers['X-Flash'] == 'true'
21
+ with_flash_message(:notice, true) { super }
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def to_js
28
+ if controller.request.headers['X-Flash'] == 'true'
29
+ with_flash_message(:notice, true) { super }
30
+ else
31
+ super
32
+ end
33
+ end
34
+
19
35
  def to_json
20
36
  if get?
21
37
  add_pagination_header if resource.respond_to?(:num_pages)
@@ -13,8 +13,62 @@ module CarrierWave
13
13
 
14
14
  module Uploader
15
15
 
16
+ module Base64Download
17
+
18
+ # Based on Yury Lebedev's work (https://github.com/lebedev-yury/carrierwave-base64)
19
+ # Our version relies on the remote_<name>_url field. Moreover, we support passing filename into the base64 string.
20
+ class Base64StringIO < StringIO
21
+ class ArgumentError < StandardError; end
22
+
23
+ attr_accessor :file_format, :original_filename
24
+
25
+ def initialize(encoded_file)
26
+ description, encoded_bytes = encoded_file.split(',')
27
+
28
+ raise ArgumentError unless encoded_bytes
29
+
30
+ @file_format = get_file_format(description)
31
+ @original_filename = get_original_filename(description)
32
+
33
+ bytes = ::Base64.decode64 encoded_bytes
34
+
35
+ super bytes
36
+ end
37
+
38
+ private
39
+
40
+ def get_original_filename(description)
41
+ regex = /\Adata:[^;]+;(.+);base64\Z/
42
+ regex.match(description).try(:[], 1) || default_filename
43
+ end
44
+
45
+ def get_file_format(description)
46
+ regex = /\Adata:([^;]+);/
47
+ regex.match(description).try(:[], 1)
48
+ end
49
+
50
+ def default_filename
51
+ File.basename("file.#{@file_format}")
52
+ end
53
+
54
+ end
55
+
56
+ def download!(uri_or_base64)
57
+ if uri_or_base64 =~ /\Adata:/
58
+ file = Base64StringIO.new(uri_or_base64)
59
+ cache!(file)
60
+ else
61
+ download_without_base64!(uri_or_base64)
62
+ end
63
+ end
64
+
65
+ end
66
+
16
67
  class Base
17
68
 
69
+ alias :download_without_base64! :download!
70
+ include CarrierWave::Uploader::Base64Download
71
+
18
72
  def build_store_dir(*args)
19
73
  default_dir = self.class.store_dir
20
74
 
@@ -34,6 +34,7 @@ require 'codemirror/rails'
34
34
  require 'jquery/rails'
35
35
  require 'jquery-ui-rails'
36
36
  require 'backbone-on-rails'
37
+ require 'nprogress-rails'
37
38
 
38
39
  require 'grape'
39
40
  require 'grape-entity'
@@ -10,8 +10,9 @@ module Locomotive
10
10
 
11
11
  paths['mongodb/migrate'] = 'mongodb/migrate'
12
12
 
13
- initializer 'steam' do |app|
14
- require 'locomotive/steam_adaptor'
13
+ initializer "locomotive.params.filter" do |app|
14
+ # Do not log remote_<field>_url params because they can contain huge base64 string
15
+ app.config.filter_parameters += [/\Aremote_.+_url\Z/]
15
16
  end
16
17
 
17
18
  initializer 'locomotive.content_types' do |app|
@@ -52,9 +53,14 @@ module Locomotive
52
53
  end
53
54
 
54
55
  initializer 'locomotive.middlewares' do |app|
55
- app.middleware.insert_before(Rack::Runtime, '::Locomotive::Middlewares::Permalink', nil)
56
+ require 'locomotive/middlewares'
57
+
56
58
  app.middleware.use '::Locomotive::Middlewares::Site'
57
59
  end
58
60
 
61
+ initializer 'steam' do |app|
62
+ require 'locomotive/steam_adaptor'
63
+ end
64
+
59
65
  end
60
66
  end
@@ -1,2 +1,2 @@
1
- require 'locomotive/middlewares/permalink'
2
1
  require 'locomotive/middlewares/site'
2
+ require 'locomotive/middlewares/page_editing'
@@ -0,0 +1,41 @@
1
+ module Locomotive
2
+ module Middlewares
3
+ class PageEditing
4
+
5
+ include Locomotive::Engine.routes.url_helpers
6
+
7
+ def initialize(app, opts = {})
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ status, headers, response = @app.call(env)
13
+ site, page = env['steam.site'], env['steam.page']
14
+
15
+ if page && !page.redirect && page.response_type == 'text/html' && response.first
16
+ html = %(
17
+ <meta name="locomotive-editable-elements-path" content="#{editable_elements_path(site, page, env)}" />
18
+ <meta name="locomotive-page-id" content="#{page._id}" />
19
+ )
20
+ response.first.gsub!('</head>', %(#{html}</head>))
21
+ end
22
+
23
+ [status, headers, response]
24
+ end
25
+
26
+ def editable_elements_path(site, page, env)
27
+ options = {}
28
+
29
+ if content_entry_id = env['steam.content_entry'].try(:_id)
30
+ options = {
31
+ content_entry_id: content_entry_id,
32
+ preview_path: env['steam.path']
33
+ }
34
+ end
35
+
36
+ super(site, page._id, options)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -31,6 +31,8 @@ module Locomotive
31
31
  env['locomotive.mounted_on'] = env['steam.mounted_on'] = mounted_on
32
32
  env['locomotive.path'] = request.path_info.gsub(mounted_on, '')
33
33
 
34
+ env['steam.live_editing'] = true
35
+
34
36
  Locomotive::Site.where(handle: handle).first
35
37
  else
36
38
  env['locomotive.path'] = request.path_info
@@ -57,14 +57,15 @@ module Locomotive
57
57
  def actions_with_back_button(options = {})
58
58
  back_button = back_button_action(options)
59
59
 
60
- template.content_tag(:div,
61
- template.content_tag(:div, back_button, class: 'col-xs-6 text-left') +
62
- template.content_tag(:div, action, class: 'col-xs-6 text-right'),
63
- class: 'row')
60
+ template.content_tag(:div, action +
61
+ '&nbsp;'.html_safe +
62
+ template.t('simple_form.buttons.default.locomotive.or') +
63
+ '&nbsp;'.html_safe +
64
+ back_button, class: 'text-right form-actions')
64
65
  end
65
66
 
66
67
  def back_button_action(options = {})
67
- label = template.escape_once('&larr;&nbsp;') + template.t('.back')
68
+ label = template.t('simple_form.buttons.default.locomotive.cancel')
68
69
  url = options[:back_url]
69
70
 
70
71
  if options[:use_stored_location]
@@ -14,6 +14,8 @@ Locomotive::Steam.configure do |config|
14
14
  config.middleware.delete Rack::Lint
15
15
  config.middleware.delete Rack::Session::Moneta
16
16
 
17
+ config.middleware.insert_after Locomotive::Steam::Middlewares::Page, Locomotive::Middlewares::PageEditing
18
+
17
19
  # config.services_hook = -> (services) {
18
20
  # Rails.logger.warn "TODO: change content entry submission"
19
21
  # }
@@ -2,5 +2,5 @@
2
2
  # MAJOR.MINOR.PATCH format.
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive #:nodoc
5
- VERSION = '3.0.0-alpha.2'
5
+ VERSION = '3.0.0-alpha.3'
6
6
  end
@@ -23,6 +23,10 @@ namespace :development do
23
23
  account.api_key = 'd49cd50f6f0d2b163f48fc73cb249f0244c37074'
24
24
  account.save!
25
25
 
26
+ unassociated_account = Locomotive::Account.new email: "new_admin@locomotivecms.com", password: "locomotive", password_confirmation: "locomotive", name: "New Admin"
27
+ unassociated_account.api_key = 'd49cd50f6f0d2b163f48fc73cb249f0244c37074'
28
+ unassociated_account.save!
29
+
26
30
  site = Locomotive::Site.create! name: "LocomotiveCMS", handle: "www", domains: ["www.example.com"]
27
31
  site.memberships.build account: account, role: 'admin'
28
32
  site.save!
@@ -26,6 +26,8 @@ Dummy::Application.configure do
26
26
 
27
27
  config.assets.compress = false
28
28
 
29
+ config.log_level = :info
30
+
29
31
  # Adds additional error checking when serving assets at runtime.
30
32
  # Checks for improperly declared sprockets dependencies.
31
33
  # Raises helpful error messages.
@@ -14,6 +14,8 @@ Devise.setup do |config|
14
14
  # available as additional gems.
15
15
  require 'devise/orm/mongoid'
16
16
 
17
+ config.secret_key = '8d6ff8102c31815f8395a8c806c9e47d36ba6c607bf7054b4714b4131d8a372fef78adac89930170d77b6d9ec59347315ee1193cb535746249eebf3e5ad5b9b3'
18
+
17
19
  # ==> Configuration for any authentication mechanism
18
20
  # Configure which keys are used when authenticating a user. The default is
19
21
  # just :email. You can configure it to use [:username, :subdomain], so for