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.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +1 -1
- data/app/api/locomotive/api/forms/membership_form.rb +13 -0
- data/app/api/locomotive/api/resources/membership_resource.rb +5 -3
- data/app/assets/javascripts/locomotive.js +2 -0
- data/app/assets/javascripts/locomotive/utils/backbone_patches.js.coffee +15 -1
- data/app/assets/javascripts/locomotive/utils/file.js.coffee +20 -0
- data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/utils/rails_ujs.js.coffee +36 -0
- data/app/assets/javascripts/locomotive/utils/wysihtml5.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +9 -17
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_view.js.coffee +39 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +104 -1
- data/app/assets/javascripts/locomotive/views/inputs/file_view.js.coffee +79 -10
- data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +24 -4
- data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +18 -0
- data/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +3 -6
- data/app/assets/javascripts/locomotive/views/shared/drawer_view.js.coffee +24 -8
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +21 -148
- data/app/assets/stylesheets/locomotive/application.scss +6 -0
- data/app/assets/stylesheets/locomotive/base/_form.scss +1 -0
- data/app/assets/stylesheets/locomotive/base/form/_base.scss +9 -0
- data/app/assets/stylesheets/locomotive/base/form/_file_input.scss +1 -1
- data/app/assets/stylesheets/locomotive/base/form/_link.scss +13 -0
- data/app/assets/stylesheets/locomotive/base/form/_select2.scss +28 -1
- data/app/assets/stylesheets/locomotive/components/_drawer.scss +8 -18
- data/app/assets/stylesheets/locomotive/components/_live_editing.scss +83 -0
- data/app/assets/stylesheets/locomotive/components/_transitions.scss +63 -1
- data/app/assets/stylesheets/locomotive/components/header/_base.scss +5 -1
- data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +5 -7
- data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +4 -4
- data/app/assets/stylesheets/locomotive/globals/_mixins.scss +16 -0
- data/app/assets/stylesheets/locomotive/globals/_nprogress.scss +3 -0
- data/app/assets/stylesheets/locomotive/globals/_variables.scss +57 -49
- data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +29 -0
- data/app/controllers/locomotive/editable_elements_controller.rb +49 -2
- data/app/controllers/locomotive/pages_controller.rb +2 -2
- data/app/helpers/locomotive/custom_fields_helper.rb +1 -1
- data/app/helpers/locomotive/editable_elements_helper.rb +40 -0
- data/app/helpers/locomotive/pages_helper.rb +0 -1
- data/app/inputs/locomotive/array_input.rb +1 -1
- data/app/inputs/locomotive/file_input.rb +35 -7
- data/app/inputs/locomotive/rte_input.rb +2 -1
- data/app/inputs/locomotive/toggle_input.rb +1 -1
- data/app/models/locomotive/concerns/content_entry/localized.rb +4 -4
- data/app/models/locomotive/concerns/content_type/sync.rb +0 -5
- data/app/models/locomotive/concerns/page/redirect.rb +1 -1
- data/app/models/locomotive/content_entry.rb +5 -11
- data/app/models/locomotive/content_type.rb +22 -0
- data/app/models/locomotive/editable_control.rb +12 -27
- data/app/models/locomotive/editable_element.rb +8 -0
- data/app/models/locomotive/editable_file.rb +0 -1
- data/app/models/locomotive/editable_text.rb +10 -10
- data/app/models/locomotive/page.rb +1 -1
- data/app/policies/locomotive/page_policy.rb +1 -1
- data/app/services/locomotive/editable_element_service.rb +47 -0
- data/app/services/locomotive/page_parsing_service.rb +85 -31
- data/app/uploaders/locomotive/editable_file_uploader.rb +5 -1
- data/app/views/locomotive/editable_elements/_edit.html.haml +49 -0
- data/app/views/locomotive/editable_elements/_edit_with_content_entry.html.haml +21 -0
- data/app/views/locomotive/editable_elements/_form.html.haml +23 -0
- data/app/views/locomotive/editable_elements/index.html.haml +8 -2
- data/app/views/locomotive/editable_elements/index_without_preview.html.haml +33 -0
- data/app/views/locomotive/layouts/{preview.html.haml → live_editing.html.haml} +9 -9
- data/app/views/locomotive/my_account/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_actions.html.haml +8 -1
- data/app/views/locomotive/pages/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_tabs.html.haml +2 -2
- data/app/views/locomotive/pages/new.html.haml +1 -1
- data/app/views/locomotive/shared/header/_site.html.haml +1 -1
- data/app/views/locomotive/shared/rte/_image_popover.html.haml +2 -2
- data/app/views/locomotive/shared/rte/_link_popover.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_page.html.haml +5 -2
- data/config/locales/admin_ui.en.yml +10 -16
- data/config/locales/inputs.en.yml +18 -11
- data/config/locales/simple_form.en.yml +13 -1
- data/config/routes.rb +3 -1
- data/lib/locomotive.rb +1 -1
- data/lib/locomotive/action_controller/responder.rb +16 -0
- data/lib/locomotive/carrierwave/patches.rb +54 -0
- data/lib/locomotive/dependencies.rb +1 -0
- data/lib/locomotive/engine.rb +9 -3
- data/lib/locomotive/middlewares.rb +1 -1
- data/lib/locomotive/middlewares/page_editing.rb +41 -0
- data/lib/locomotive/middlewares/site.rb +2 -0
- data/lib/locomotive/simple_form.rb +6 -5
- data/lib/locomotive/steam_adaptor.rb +2 -0
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +4 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/mongoid.yml +2 -2
- data/spec/models/locomotive/content_entry_spec.rb +11 -2
- data/spec/support/factories.rb +0 -1
- data/vendor/assets/javascripts/locomotive/history.js +2122 -0
- data/vendor/assets/javascripts/locomotive/subscribe.js +206 -329
- metadata +44 -127
- data/lib/locomotive/middlewares/permalink.rb +0 -22
- data/lib/locomotive/previous_liquid/asset_host.rb +0 -51
- data/lib/locomotive/previous_liquid/drops/base.rb +0 -40
- data/lib/locomotive/previous_liquid/drops/content_entry.rb +0 -78
- data/lib/locomotive/previous_liquid/drops/content_types.rb +0 -119
- data/lib/locomotive/previous_liquid/drops/current_user.rb +0 -21
- data/lib/locomotive/previous_liquid/drops/page.rb +0 -115
- data/lib/locomotive/previous_liquid/drops/proxy_collection.rb +0 -64
- data/lib/locomotive/previous_liquid/drops/session_proxy.rb +0 -16
- data/lib/locomotive/previous_liquid/drops/site.rb +0 -29
- data/lib/locomotive/previous_liquid/drops/uploader.rb +0 -21
- data/lib/locomotive/previous_liquid/errors.rb +0 -8
- data/lib/locomotive/previous_liquid/filters/base.rb +0 -61
- data/lib/locomotive/previous_liquid/filters/date.rb +0 -82
- data/lib/locomotive/previous_liquid/filters/html.rb +0 -117
- data/lib/locomotive/previous_liquid/filters/misc.rb +0 -75
- data/lib/locomotive/previous_liquid/filters/resize.rb +0 -18
- data/lib/locomotive/previous_liquid/filters/text.rb +0 -53
- data/lib/locomotive/previous_liquid/filters/translate.rb +0 -38
- data/lib/locomotive/previous_liquid/patches.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/consume.rb +0 -104
- data/lib/locomotive/previous_liquid/tags/csrf.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/editable.rb +0 -4
- data/lib/locomotive/previous_liquid/tags/editable/base.rb +0 -88
- data/lib/locomotive/previous_liquid/tags/editable/control.rb +0 -41
- data/lib/locomotive/previous_liquid/tags/editable/file.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/editable/text.rb +0 -79
- data/lib/locomotive/previous_liquid/tags/extends.rb +0 -47
- data/lib/locomotive/previous_liquid/tags/fetch_page.rb +0 -36
- data/lib/locomotive/previous_liquid/tags/google_analytics.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/hybrid.rb +0 -25
- data/lib/locomotive/previous_liquid/tags/inherited_block.rb +0 -31
- data/lib/locomotive/previous_liquid/tags/inline_editor.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/javascript.rb +0 -16
- data/lib/locomotive/previous_liquid/tags/link_to.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/locale_switcher.rb +0 -83
- data/lib/locomotive/previous_liquid/tags/model_form.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/nav.rb +0 -164
- data/lib/locomotive/previous_liquid/tags/paginate.rb +0 -114
- data/lib/locomotive/previous_liquid/tags/path_helper.rb +0 -85
- data/lib/locomotive/previous_liquid/tags/path_to.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/seo.rb +0 -72
- data/lib/locomotive/previous_liquid/tags/session_assign.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/snippet.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/with_scope.rb +0 -65
- data/spec/fixtures/portfolio/Gemfile +0 -21
- data/spec/fixtures/portfolio/app/content_types/messages.yml +0 -57
- data/spec/fixtures/portfolio/app/content_types/projects.yml +0 -74
- data/spec/fixtures/portfolio/app/views/pages/404.liquid.haml +0 -10
- data/spec/fixtures/portfolio/app/views/pages/index.liquid.haml +0 -213
- data/spec/fixtures/portfolio/app/views/snippets/footer.liquid.haml +0 -2
- data/spec/fixtures/portfolio/config.ru +0 -3
- data/spec/fixtures/portfolio/config/deploy.yml +0 -18
- data/spec/fixtures/portfolio/config/site.yml +0 -33
- data/spec/fixtures/portfolio/config/translations.yml +0 -8
- data/spec/fixtures/portfolio/data/messages.yml +0 -1
- data/spec/fixtures/portfolio/data/projects.yml +0 -41
- data/spec/fixtures/portfolio/icon.png +0 -0
- data/spec/fixtures/portfolio/public/javascripts/bootstrap.min.js +0 -6
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.js +0 -44
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.min.js +0 -11
- data/spec/fixtures/portfolio/public/javascripts/classie.js +0 -80
- data/spec/fixtures/portfolio/public/javascripts/contact_me.js +0 -65
- data/spec/fixtures/portfolio/public/javascripts/freelancer.js +0 -37
- data/spec/fixtures/portfolio/public/javascripts/jqBootstrapValidation.js +0 -912
- data/spec/fixtures/portfolio/public/samples/portfolio/cabin.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/cake.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/circus.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/game.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/safe.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/submarine.png +0 -0
- data/spec/fixtures/portfolio/public/samples/profile.png +0 -0
- data/spec/fixtures/portfolio/public/stylesheets/bootstrap.min.css +0 -7
- data/spec/fixtures/portfolio/public/stylesheets/freelancer.css +0 -445
- data/spec/lib/locomotive/liquid/tags/editable/file_spec.rb +0 -72
- data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +0 -85
- data/spec/lib/locomotive/liquid/tags/extends_spec.rb +0 -58
- data/vendor/assets/javascripts/locomotive/editable_field.js +0 -50
- data/vendor/assets/javascripts/locomotive/form_submit_notification.js +0 -39
- data/vendor/assets/javascripts/locomotive/slugify.js +0 -47
@@ -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.
|
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
|
-
=
|
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
|
-
|
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:
|
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} — <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:
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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: "
|
176
|
+
loading_text: "Saving..."
|
177
|
+
or: or
|
166
178
|
locomotive:
|
167
179
|
image_resize_form:
|
168
180
|
loading_text: Resizing...
|
data/config/routes.rb
CHANGED
@@ -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
|
|
data/lib/locomotive.rb
CHANGED
@@ -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
|
|
data/lib/locomotive/engine.rb
CHANGED
@@ -10,8 +10,9 @@ module Locomotive
|
|
10
10
|
|
11
11
|
paths['mongodb/migrate'] = 'mongodb/migrate'
|
12
12
|
|
13
|
-
initializer
|
14
|
-
|
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
|
-
|
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
|
@@ -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
|
-
|
62
|
-
template.
|
63
|
-
|
60
|
+
template.content_tag(:div, action +
|
61
|
+
' '.html_safe +
|
62
|
+
template.t('simple_form.buttons.default.locomotive.or') +
|
63
|
+
' '.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.
|
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
|
# }
|
data/lib/locomotive/version.rb
CHANGED
data/lib/tasks/development.rake
CHANGED
@@ -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
|