locomotivecms 3.0.0.pre.beta.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/app/api/locomotive/api.rb +1 -0
  4. data/app/api/locomotive/api/entities/page_entity.rb +1 -1
  5. data/app/api/locomotive/api/entities/site_entity.rb +9 -1
  6. data/app/api/locomotive/api/exception_rescuers.rb +3 -5
  7. data/app/api/locomotive/api/forms/page_form.rb +1 -1
  8. data/app/api/locomotive/api/forms/site_form.rb +1 -2
  9. data/app/api/locomotive/api/helpers/authentication_helper.rb +6 -1
  10. data/app/api/locomotive/api/helpers/locales_helper.rb +15 -0
  11. data/app/api/locomotive/api/helpers/params_helper.rb +13 -0
  12. data/app/api/locomotive/api/middlewares/locale_middleware.rb +6 -1
  13. data/app/api/locomotive/api/resources/content_entry_resource.rb +2 -0
  14. data/app/api/locomotive/api/resources/content_type_resource.rb +2 -2
  15. data/app/api/locomotive/api/resources/current_site_resource.rb +2 -1
  16. data/app/api/locomotive/api/resources/membership_resource.rb +0 -4
  17. data/app/api/locomotive/api/resources/page_resource.rb +6 -1
  18. data/app/api/locomotive/api/resources/site_resource.rb +4 -2
  19. data/app/assets/javascripts/locomotive.js +1 -0
  20. data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +3 -1
  21. data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +10 -3
  22. data/app/assets/javascripts/locomotive/views/inputs/markdown_view.js.coffee +82 -0
  23. data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +1 -1
  24. data/app/assets/javascripts/locomotive/views/inputs/rte/link_view.js.coffee +1 -1
  25. data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +1 -1
  26. data/app/assets/javascripts/locomotive/views/inputs/text_view.js.coffee +4 -1
  27. data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +3 -0
  28. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +22 -1
  29. data/app/assets/javascripts/locomotive/views/shared/header_view.js.coffee +2 -2
  30. data/app/assets/stylesheets/locomotive/application.scss +2 -0
  31. data/app/assets/stylesheets/locomotive/base/_form.scss +2 -0
  32. data/app/assets/stylesheets/locomotive/base/form/_api_key.scss +0 -1
  33. data/app/assets/stylesheets/locomotive/base/form/_array_input.scss +2 -0
  34. data/app/assets/stylesheets/locomotive/base/form/_base.scss +13 -2
  35. data/app/assets/stylesheets/locomotive/base/form/_color_input.scss +12 -0
  36. data/app/assets/stylesheets/locomotive/base/form/_markdown.scss +292 -0
  37. data/app/assets/stylesheets/locomotive/base/form/_popover.scss +22 -0
  38. data/app/assets/stylesheets/locomotive/base/form/_rte.scss +2 -1
  39. data/app/assets/stylesheets/locomotive/components/_activity_feed.scss +1 -0
  40. data/app/assets/stylesheets/locomotive/components/_dashboard.scss +29 -0
  41. data/app/assets/stylesheets/locomotive/components/_live_editing.scss +13 -1
  42. data/app/assets/stylesheets/locomotive/components/_main.scss +1 -1
  43. data/app/assets/stylesheets/locomotive/components/_transitions.scss +24 -3
  44. data/app/assets/stylesheets/locomotive/components/sidebar/_base.scss +1 -0
  45. data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +2 -2
  46. data/app/assets/stylesheets/locomotive/globals/_variables.scss +4 -3
  47. data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +4 -0
  48. data/app/controllers/locomotive/concerns/locale_helpers_controller.rb +1 -0
  49. data/app/controllers/locomotive/content_entries_controller.rb +10 -2
  50. data/app/controllers/locomotive/pages_controller.rb +2 -1
  51. data/app/controllers/locomotive/passwords_controller.rb +17 -1
  52. data/app/helpers/locomotive/base_helper.rb +19 -0
  53. data/app/helpers/locomotive/content_types_helper.rb +2 -1
  54. data/app/helpers/locomotive/custom_fields_helper.rb +14 -1
  55. data/app/helpers/locomotive/dashboard_helper.rb +12 -0
  56. data/app/helpers/locomotive/editable_elements_helper.rb +9 -4
  57. data/app/helpers/locomotive/pages_helper.rb +1 -14
  58. data/app/helpers/locomotive/shared/pages_helper.rb +17 -0
  59. data/app/helpers/locomotive/translations_helper.rb +0 -14
  60. data/app/inputs/locomotive/color_input.rb +18 -0
  61. data/app/inputs/locomotive/markdown_input.rb +19 -0
  62. data/app/models/locomotive/account.rb +2 -1
  63. data/app/models/locomotive/concerns/content_entry/file_size.rb +27 -0
  64. data/app/models/locomotive/concerns/content_type/group_by.rb +3 -1
  65. data/app/models/locomotive/concerns/page/layout.rb +63 -19
  66. data/app/models/locomotive/concerns/shared/site_scope.rb +37 -0
  67. data/app/models/locomotive/concerns/site/cache.rb +32 -0
  68. data/app/models/locomotive/concerns/theme_asset/plain_text.rb +85 -0
  69. data/app/models/locomotive/content_entry.rb +7 -7
  70. data/app/models/locomotive/content_type.rb +12 -6
  71. data/app/models/locomotive/page.rb +12 -14
  72. data/app/models/locomotive/site.rb +9 -3
  73. data/app/models/locomotive/snippet.rb +6 -4
  74. data/app/models/locomotive/theme_asset.rb +8 -73
  75. data/app/models/locomotive/translation.rb +6 -5
  76. data/app/policies/locomotive/site_policy.rb +2 -2
  77. data/app/services/locomotive/content_entry_service.rb +7 -6
  78. data/app/services/locomotive/site_service.rb +1 -0
  79. data/app/views/locomotive/content_entries/_entry.html.slim +1 -0
  80. data/app/views/locomotive/content_entries/edit.html.slim +1 -1
  81. data/app/views/locomotive/content_entries/new.html.slim +1 -1
  82. data/app/views/locomotive/current_site/_membership.html.slim +1 -0
  83. data/app/views/locomotive/current_site/edit.html.slim +1 -1
  84. data/app/views/locomotive/current_site/form/_access_points.html.slim +1 -1
  85. data/app/views/locomotive/current_site/form/_advanced.html.slim +2 -0
  86. data/app/views/locomotive/dashboard/_activity.html.slim +26 -0
  87. data/app/views/locomotive/dashboard/_url.html.slim +9 -0
  88. data/app/views/locomotive/dashboard/show.html.slim +3 -21
  89. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -1
  90. data/app/views/locomotive/editable_elements/_edit.html.slim +8 -1
  91. data/app/views/locomotive/editable_elements/_form.html.slim +1 -1
  92. data/app/views/locomotive/editable_elements/index_without_preview.html.slim +24 -17
  93. data/app/views/locomotive/layouts/application.html.slim +6 -4
  94. data/app/views/locomotive/layouts/live_editing.html.slim +9 -0
  95. data/app/views/locomotive/layouts/not_logged_in.html.slim +1 -1
  96. data/app/views/locomotive/layouts/without_site.html.slim +2 -0
  97. data/app/views/locomotive/memberships/edit.html.slim +1 -1
  98. data/app/views/locomotive/memberships/new.html.slim +1 -1
  99. data/app/views/locomotive/my_account/edit.html.slim +7 -5
  100. data/app/views/locomotive/pages/_header.html.slim +7 -0
  101. data/app/views/locomotive/pages/edit.html.slim +2 -4
  102. data/app/views/locomotive/pages/form/_main.html.slim +4 -1
  103. data/app/views/locomotive/pages/form/_tabs.html.slim +4 -3
  104. data/app/views/locomotive/public_submission_accounts/_account.html.slim +1 -1
  105. data/app/views/locomotive/public_submission_accounts/edit.html.slim +1 -1
  106. data/app/views/locomotive/shared/_header.html.slim +25 -22
  107. data/app/views/locomotive/shared/_locale_picker_link.html.slim +3 -0
  108. data/app/views/locomotive/shared/_main_app_header.html.slim +1 -1
  109. data/app/views/locomotive/shared/_sidebar.html.slim +15 -11
  110. data/app/views/locomotive/shared/rte/_markdown_toolbar.html.slim +42 -0
  111. data/config/locales/admin_ui.en.yml +9 -4
  112. data/config/locales/default.en.yml +4 -0
  113. data/config/locales/devise.en.yml +1 -0
  114. data/config/locales/simple_form.en.yml +6 -2
  115. data/lib/locomotive/action_controller/responder.rb +5 -0
  116. data/lib/locomotive/engine.rb +5 -0
  117. data/lib/locomotive/middlewares/site.rb +39 -21
  118. data/lib/locomotive/simple_form.rb +3 -31
  119. data/lib/locomotive/steam/middlewares/cache.rb +62 -0
  120. data/lib/locomotive/steam/middlewares/page_editing.rb +9 -3
  121. data/lib/locomotive/steam/services/api_entry_submission_service.rb +6 -3
  122. data/lib/locomotive/steam/services/liquid_parser_with_cache_service.rb +74 -0
  123. data/lib/locomotive/steam_adaptor.rb +7 -1
  124. data/lib/locomotive/version.rb +1 -1
  125. data/lib/tasks/development.rake +4 -0
  126. data/lib/tasks/locomotive.rake +14 -0
  127. data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +10 -1
  128. data/spec/lib/locomotive/steam/services/liquid_parser_with_cache_service_spec.rb +53 -0
  129. data/spec/models/locomotive/concerns/content_entry/file_size_spec.rb +40 -0
  130. data/spec/models/locomotive/concerns/page/layout_spec.rb +122 -17
  131. data/spec/models/locomotive/concerns/site/cache_spec.rb +60 -0
  132. data/spec/models/locomotive/content_entry_spec.rb +7 -0
  133. data/spec/models/locomotive/content_type_spec.rb +18 -11
  134. data/spec/models/locomotive/page_spec.rb +32 -8
  135. data/spec/models/locomotive/snippet_spec.rb +13 -4
  136. data/spec/models/locomotive/theme_asset_spec.rb +10 -3
  137. data/spec/models/locomotive/translation_spec.rb +28 -0
  138. data/spec/requests/locomotive/steam/cache_spec.rb +83 -0
  139. data/spec/requests/site_spec.rb +24 -0
  140. data/spec/support/capybara.rb +5 -13
  141. data/spec/support/factories.rb +9 -0
  142. data/spec/support/features/session_helpers.rb +19 -3
  143. data/spec/support/features/site_helpers.rb +27 -0
  144. data/spec/support/shared_examples/site_scope_examples.rb +27 -0
  145. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  146. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha.png +0 -0
  147. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue-horizontal.png +0 -0
  148. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue.png +0 -0
  149. data/vendor/assets/images/locomotive/bootstrap-colorpicker/saturation.png +0 -0
  150. data/vendor/assets/javascripts/locomotive/bootstrap-colorpicker.js +1 -0
  151. data/vendor/assets/javascripts/locomotive/datepicker_i18n.js.erb +6 -6
  152. data/vendor/assets/javascripts/locomotive/kramed.min.js +11 -0
  153. data/vendor/assets/stylesheets/locomotive/bootstrap-colorpicker.scss +9 -0
  154. metadata +59 -44
  155. data/app/controllers/locomotive/api/accounts_controller.rb +0 -60
  156. data/app/controllers/locomotive/api/base_controller.rb +0 -35
  157. data/app/controllers/locomotive/api/content_assets_controller.rb +0 -51
  158. data/app/controllers/locomotive/api/content_entries_controller.rb +0 -71
  159. data/app/controllers/locomotive/api/content_types_controller.rb +0 -52
  160. data/app/controllers/locomotive/api/current_site_controller.rb +0 -34
  161. data/app/controllers/locomotive/api/memberships_controller.rb +0 -52
  162. data/app/controllers/locomotive/api/my_account_controller.rb +0 -46
  163. data/app/controllers/locomotive/api/pages_controller.rb +0 -53
  164. data/app/controllers/locomotive/api/sites_controller.rb +0 -58
  165. data/app/controllers/locomotive/api/snippets_controller.rb +0 -52
  166. data/app/controllers/locomotive/api/theme_assets_controller.rb +0 -51
  167. data/app/controllers/locomotive/api/tokens_controller.rb +0 -36
  168. data/app/controllers/locomotive/api/translations_controller.rb +0 -51
  169. data/app/controllers/locomotive/api/version_controller.rb +0 -11
  170. data/spec/models/locomotive/editable_control_spec.rb +0 -79
  171. data/spec/models/locomotive/editable_file_spec.rb +0 -94
  172. data/spec/models/locomotive/editable_text_spec.rb +0 -219
  173. data/vendor/assets/images/select2-spinner.gif +0 -0
  174. data/vendor/assets/images/select2.png +0 -0
  175. data/vendor/assets/images/select2x2.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b4009f2488429e00c7d89ed8d530b3063ce5ebe
4
- data.tar.gz: 523238ddc19928abc3f801e8d09d096baf5a8701
3
+ metadata.gz: d10fc58170b51a43910d6f1471a3f3ef30f06591
4
+ data.tar.gz: 7e07b1bb55d2f426bbdb595e4e92f31b7e4d5a15
5
5
  SHA512:
6
- metadata.gz: 75a9d1de7dab0849ba152f7844ba387dff44dc97ac4bb17da20d3ca7a352085dd46757a9681db1f4e141a39943c11b7a0e8b827976f66ae51bfb5b07173b827a
7
- data.tar.gz: 40665a5be1905a6405f88d476091a79fe2be2530b78abfebe879bf5102c4c969e9ced4ec74bc8f7adefa33b7ae85a48dd14a327e1b343c2a759c266c7eb8a6d0
6
+ metadata.gz: f4a440454798b26f56aa64e1a60ad77a8b676ac7337e6c11075b2c594528d877b0337a7326d6cd8d64fa0674de8f960f2a6e92341c13d01230b1daa4ec450089
7
+ data.tar.gz: 1406d6ea958450d83374bc6a5ce5ac59e0fdf72bf82b798ce693fc2436b37e690b6e3e4c1a23083b6123ba4d79de63a4a41171fdbf7aca1197370e96da6db16f
data/Gemfile CHANGED
@@ -22,7 +22,7 @@ group :development do
22
22
  # gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '15cceb66ed'
23
23
 
24
24
  # gem 'locomotivecms_steam', path: '../in_progress/steam', require: false
25
- # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '2650a1c', require: false
25
+ # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'c487443', require: false
26
26
 
27
27
  # gem 'locomotive-aloha-rails', path: '../gems/aloha-rails' # for Developers
28
28
  # gem 'locomotive-tinymce-rails', path: '../gems/tinymce-rails' # for Developers
@@ -54,7 +54,6 @@ group :test do
54
54
  # gem 'cucumber-rails', require: false
55
55
  gem 'simplecov'
56
56
 
57
-
58
57
  gem 'capybara', '~> 2.4.4'
59
58
  gem 'poltergeist'
60
59
 
@@ -64,8 +63,10 @@ group :test do
64
63
  gem 'factory_girl_rails'
65
64
  gem 'pickle'
66
65
  gem 'json_spec', '~> 1.1.4'
67
- gem 'database_cleaner'
66
+ gem 'database_cleaner', '~> 1.4.1'
68
67
  gem 'timecop', '~> 0.7.1'
69
68
 
69
+ gem 'email_spec'
70
+
70
71
  # gem 'debugger', git: 'git://github.com/cldwalker/debugger.git'
71
72
  end
@@ -20,6 +20,7 @@ module Locomotive
20
20
  helpers API::Helpers::ParamsHelper
21
21
  helpers API::Helpers::PersistenceHelper
22
22
  helpers API::Helpers::PaginationHelper
23
+ helpers API::Helpers::LocalesHelper
23
24
 
24
25
  include API::ExceptionRescuers
25
26
 
@@ -6,7 +6,7 @@ module Locomotive
6
6
 
7
7
  expose :title, :parent_id, :position,
8
8
  :handle, :depth, :response_type,
9
- :listed, :published, :translated_in
9
+ :listed, :published, :translated_in, :cache_enabled
10
10
 
11
11
  # Path
12
12
  expose :slug, :fullpath
@@ -5,7 +5,7 @@ module Locomotive
5
5
  class SiteEntity < BaseEntity
6
6
 
7
7
  expose :name, :handle, :seo_title, :meta_keywords, :meta_description,
8
- :robots_txt
8
+ :robots_txt, :cache_enabled
9
9
 
10
10
  expose :locales, :domains
11
11
 
@@ -19,6 +19,14 @@ module Locomotive
19
19
  site.picture.url
20
20
  end
21
21
 
22
+ expose :content_version do |site, _|
23
+ site.content_version.to_i
24
+ end
25
+
26
+ expose :template_version do |site, _|
27
+ site.template_version.to_i
28
+ end
29
+
22
30
  expose :picture_thumbnail_url do |site, _|
23
31
  Locomotive::Dragonfly.resize_url site.picture.url, '100x100#'
24
32
  end
@@ -8,11 +8,9 @@ module Locomotive
8
8
  included do
9
9
 
10
10
  rescue_from :all do |e|
11
- if Rails.env.development? || Rails.env.test?
12
- raise e
13
- else
14
- error_response(message: { error: e.message }, status: 500)
15
- end
11
+ Rails.logger.error "[API]" + e.message + "\"" + e.backtrace.join("\n")
12
+
13
+ error_response(message: { error: e.message }, status: 500)
16
14
  end
17
15
 
18
16
  rescue_from ::Mongoid::Errors::DocumentNotFound do
@@ -4,7 +4,7 @@ module Locomotive
4
4
 
5
5
  class PageForm < BaseForm
6
6
 
7
- attrs :title, :slug, :handle, :response_type, :published
7
+ attrs :title, :slug, :handle, :response_type, :published, :cache_enabled
8
8
 
9
9
  # Tree
10
10
  attrs :parent_id, :position, :listed
@@ -4,8 +4,7 @@ module Locomotive
4
4
 
5
5
  class SiteForm < BaseForm
6
6
 
7
- attrs :name, :handle, :robots_txt, :locales, :domains, :timezone, :picture
8
-
7
+ attrs :name, :handle, :robots_txt, :locales, :domains, :timezone, :picture, :cache_enabled
9
8
  attrs :seo_title, :meta_keywords, :meta_description, localized: true
10
9
 
11
10
  # Make sure locales and domains are in arrays.
@@ -14,7 +14,7 @@ module Locomotive
14
14
  end
15
15
 
16
16
  def authenticate_locomotive_account!
17
- error!('401 Unauthorized', 401) unless current_membership
17
+ error!('Unauthorized', 401) unless current_membership
18
18
  true
19
19
  end
20
20
 
@@ -22,6 +22,11 @@ module Locomotive
22
22
  @current_site ||= request.env['locomotive.site']
23
23
  end
24
24
 
25
+ def require_site!
26
+ error!('Unknown site', 404) unless current_site
27
+ true
28
+ end
29
+
25
30
  def current_membership
26
31
  return nil if current_account.nil?
27
32
  membership = current_site ? current_site.membership_for(current_account) : nil
@@ -0,0 +1,15 @@
1
+ module Locomotive
2
+ module API
3
+ module Helpers
4
+ module LocalesHelper
5
+
6
+ include Locomotive::Concerns::SiteDispatcherController
7
+
8
+ def back_to_default_site_locale
9
+ ::Mongoid::Fields::I18n.locale = current_site.default_locale
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,6 +7,19 @@ module Locomotive
7
7
  @permitted_params ||= declared(params, include_missing: false)
8
8
  end
9
9
 
10
+ # Much safer than permitted_params because it also uses the current policy
11
+ # (Pundit) to filter the parameters.
12
+ #
13
+ # Example:
14
+ #
15
+ # permitted_params_from_policy(current_site, :site)
16
+ #
17
+ def permitted_params_from_policy(object_or_class, key)
18
+ _params = permitted_params[key]
19
+ _attributes = policy(object_or_class).permitted_attributes
20
+ ::ActionController::Parameters.new(_params).permit(*_attributes)
21
+ end
22
+
10
23
  end
11
24
 
12
25
  end
@@ -26,11 +26,16 @@ module Locomotive
26
26
 
27
27
  def find_locale(env)
28
28
  env['HTTP_X_LOCOMOTIVE_LOCALE'].presence ||
29
- Rack::Request.new(env).params[:locale].presence ||
29
+ params(env)[:locale].presence ||
30
+ params(env)['locale'].presence ||
30
31
  env['locomotive.site'].try(:default_locale).presence ||
31
32
  Locomotive.config.site_locales.first
32
33
  end
33
34
 
35
+ def params(env)
36
+ @params ||= Rack::Request.new(env).params
37
+ end
38
+
34
39
  end
35
40
 
36
41
  end
@@ -59,6 +59,8 @@ module Locomotive
59
59
  post do
60
60
  authorize ContentEntry, :create?
61
61
 
62
+ back_to_default_site_locale
63
+
62
64
  form = form_klass.new(content_type, content_entry_params)
63
65
  @content_entry = service.create(form.serializable_hash)
64
66
 
@@ -62,7 +62,7 @@ module Locomotive
62
62
  optional :raw_item_template # deprecated
63
63
  optional :display_settings
64
64
  optional :public_submission_account_emails
65
- optional :public_submission_accounts
65
+ optional :public_submission_enabled
66
66
  end
67
67
  end
68
68
  post do
@@ -106,7 +106,7 @@ module Locomotive
106
106
  optional :raw_item_template # deprecated
107
107
  optional :display_settings
108
108
  optional :public_submission_account_emails
109
- optional :public_submission_accounts
109
+ optional :public_submission_enabled
110
110
  end
111
111
  end
112
112
  put ':id' do
@@ -9,6 +9,7 @@ module Locomotive
9
9
 
10
10
  before do
11
11
  authenticate_locomotive_account!
12
+ require_site!
12
13
  end
13
14
 
14
15
  helpers do
@@ -45,7 +46,7 @@ module Locomotive
45
46
  put do
46
47
  authorize current_site, :update?
47
48
 
48
- current_site_form = Forms::SiteForm.new(permitted_params[:site])
49
+ current_site_form = Forms::SiteForm.new(permitted_params_from_policy(current_site, :site))
49
50
  service.update(current_site, current_site_form.serializable_hash)
50
51
 
51
52
  present current_site, with: entity_klass
@@ -19,7 +19,6 @@ module Locomotive
19
19
  present memberships, with: entity_klass
20
20
  end
21
21
 
22
-
23
22
  desc "Show a membership"
24
23
  params do
25
24
  requires :id, type: String, desc: 'Membership ID'
@@ -32,7 +31,6 @@ module Locomotive
32
31
  end
33
32
  end
34
33
 
35
-
36
34
  desc 'Create a membership'
37
35
  params do
38
36
  requires :membership, type: Hash do
@@ -50,7 +48,6 @@ module Locomotive
50
48
  present membership, with: entity_klass, policy: current_policy
51
49
  end
52
50
 
53
-
54
51
  desc 'Update a membership'
55
52
  params do
56
53
  requires :id, type: String, desc: 'Membership ID'
@@ -68,7 +65,6 @@ module Locomotive
68
65
  present membership, with: entity_klass
69
66
  end
70
67
 
71
-
72
68
  desc "Delete a membership"
73
69
  params do
74
70
  requires :id, type: String, desc: 'Membership ID'
@@ -38,7 +38,7 @@ module Locomotive
38
38
  end
39
39
  end
40
40
 
41
- desc 'Create a page'
41
+ desc 'Create a page (in the default locale)'
42
42
  params do
43
43
  requires :page, type: Hash do
44
44
  requires :title
@@ -57,6 +57,7 @@ module Locomotive
57
57
  optional :is_layout, type: Boolean
58
58
  optional :allow_layout, type: Boolean
59
59
  optional :editable_elements, type: Array
60
+ optional :cache_enabled
60
61
  optional :seo_title
61
62
  optional :meta_keywords
62
63
  optional :meta_description
@@ -64,6 +65,9 @@ module Locomotive
64
65
  end
65
66
  post do
66
67
  authorize Page, :create?
68
+
69
+ back_to_default_site_locale
70
+
67
71
  form = form_klass.new(current_site, page_params)
68
72
  persist_from_form(form)
69
73
 
@@ -89,6 +93,7 @@ module Locomotive
89
93
  optional :allow_layout, type: Boolean
90
94
  optional :template
91
95
  optional :editable_elements, type: Array
96
+ optional :cache_enabled
92
97
  optional :seo_title
93
98
  optional :meta_keywords
94
99
  optional :meta_description
@@ -65,12 +65,13 @@ module Locomotive
65
65
  optional :domains, type: Array
66
66
  optional :timezone
67
67
  optional :picture
68
+ optional :cache_enabled
68
69
  end
69
70
  end
70
71
  post do
71
72
  authorize Site, :create?
72
73
 
73
- site_form = Forms::SiteForm.new(permitted_params[:site])
74
+ site_form = Forms::SiteForm.new(permitted_params_from_policy(Locomotive::Site, :site))
74
75
  site = service.create!(site_form.serializable_hash)
75
76
 
76
77
  present site, with: entity_klass
@@ -90,13 +91,14 @@ module Locomotive
90
91
  optional :domains, type: Array
91
92
  optional :timezone
92
93
  optional :picture
94
+ optional :cache_enabled
93
95
  end
94
96
  end
95
97
  put ':id' do
96
98
  site = load_site
97
99
  authorize site, :update?
98
100
 
99
- site_form = Forms::SiteForm.new(permitted_params[:site])
101
+ site_form = Forms::SiteForm.new(permitted_params_from_policy(site, :site))
100
102
  site.assign_attributes(site_form.serializable_hash)
101
103
  site.save!
102
104
 
@@ -11,6 +11,7 @@
11
11
  //= require underscore
12
12
  //= require backbone
13
13
  //= require codemirror
14
+ //= require codemirror/modes/markdown
14
15
  //= require select2
15
16
  //= require nprogress
16
17
  //= require nprogress-ajax
@@ -1,5 +1,7 @@
1
+ parent = if $('.content').size() > 0 then '.content' else '.wrapper'
2
+
1
3
  NProgress.configure
2
4
  showSpinner: false
3
5
  ease: 'ease'
4
6
  speed: 500
5
- parent: '.content'
7
+ parent: parent
@@ -5,8 +5,8 @@ class Locomotive.Views.EditableElements.IndexView extends Backbone.View
5
5
  el: '.wrapper'
6
6
 
7
7
  events:
8
- 'click .expand-button': 'expand_preview'
9
- 'click .close-button': 'shrink_preview'
8
+ 'click .content .expand-button': 'expand_preview'
9
+ 'click .content .close-button': 'shrink_preview'
10
10
 
11
11
  expand_preview: (event) ->
12
12
  $('body').addClass('full-width-preview')
@@ -15,7 +15,7 @@ class Locomotive.Views.EditableElements.IndexView extends Backbone.View
15
15
  $('body').removeClass('full-width-preview')
16
16
 
17
17
  initialize: ->
18
- _.bindAll(@, 'refresh_elements', 'refresh_image', 'refresh_image_on_remove', 'refresh_text')
18
+ _.bindAll(@, 'refresh_elements', 'refresh_image', 'refresh_image_on_remove', 'refresh_text', 'reload_page')
19
19
 
20
20
  view_options = if $('body').hasClass('live-editing') then {} else { el: '.main' }
21
21
 
@@ -25,6 +25,7 @@ class Locomotive.Views.EditableElements.IndexView extends Backbone.View
25
25
 
26
26
  @pubsub_image_changed_token = PubSub.subscribe('inputs.image_changed', @refresh_image)
27
27
  @pubsub_image_removed_token = PubSub.subscribe('inputs.image_removed', @refresh_image_on_remove)
28
+ @pubsub_pages_sorted_token = PubSub.subscribe('pages.sorted', @reload_page)
28
29
 
29
30
  $('.preview iframe').load (event) => @on_iframe_load(event)
30
31
 
@@ -68,6 +69,11 @@ class Locomotive.Views.EditableElements.IndexView extends Backbone.View
68
69
  @refresh_elements 'text', data.view, ($elements) ->
69
70
  $elements.each -> $(this).html(data.content)
70
71
 
72
+ reload_page: (event) ->
73
+ $iframe = $('.preview iframe')
74
+ $target_window = $iframe[0].contentWindow
75
+ $iframe.attr('src', @preview_url)
76
+
71
77
  on_iframe_load: (event) ->
72
78
  $iframe = $('.preview iframe')
73
79
  $target_window = $iframe[0].contentWindow
@@ -106,3 +112,4 @@ class Locomotive.Views.EditableElements.IndexView extends Backbone.View
106
112
  PubSub.unsubscribe(@pubsub_image_changed_token)
107
113
  PubSub.unsubscribe(@pubsub_image_removed_token)
108
114
  PubSub.unsubscribe(@pubsub_text_token)
115
+ PubSub.unsubscribe(@pubsub_pages_sorted_token)
@@ -0,0 +1,82 @@
1
+ #= require ./text_view
2
+
3
+ class Locomotive.Views.Inputs.MarkdownView extends Locomotive.Views.Inputs.TextView
4
+
5
+ events: _.extend {}, Locomotive.Views.Inputs.TextView.prototype.events,
6
+ 'click a[data-markdown-command]': 'run_command'
7
+
8
+ opened_picker: false
9
+
10
+ initialize: ->
11
+ super
12
+
13
+ _.bindAll(@, 'insert_file')
14
+
15
+ @$textarea = @$('textarea.markdown')
16
+ @editor = CodeMirror.fromTextArea @$textarea[0],
17
+ mode: 'markdown'
18
+ tabMode: 'indent'
19
+ lineWrapping: true
20
+
21
+ @pubsub_token = PubSub.subscribe('file_picker.select', @insert_file)
22
+
23
+ run_command: (event) ->
24
+ $link = $(event.target).closest('a')
25
+ command = $link.data('markdown-command')
26
+
27
+ switch command
28
+ when 'bold' then @apply_bold()
29
+ when 'italic' then @apply_italic()
30
+ when 'insertFile' then @open_file_picker($link.data('url'))
31
+ else
32
+ console.log "[Markdown input] command not implemented: #{command}"
33
+ return
34
+
35
+ @content_change_with_markdown()
36
+
37
+ apply_bold: ->
38
+ text = @editor.getSelection()
39
+ text = 'Some text' unless text? && text.length > 0
40
+ @editor.replaceSelection "**#{text}**"
41
+
42
+ apply_italic: ->
43
+ text = @editor.getSelection()
44
+ text = 'Some text' unless text? && text.length > 0
45
+ @editor.replaceSelection "*#{text}*"
46
+
47
+ insert_file: (msg, data) ->
48
+ return unless data.parent_view.cid == @.cid
49
+
50
+ text = @editor.getSelection()
51
+ text = data.title if !text? || text.length == 0
52
+
53
+ if data.image
54
+ @editor.replaceSelection " ![#{text}](#{data.url}) "
55
+ else
56
+ @editor.replaceSelection " [#{text}](#{data.url}) "
57
+
58
+ @content_change_with_markdown()
59
+ @hide_file_picker()
60
+
61
+ content_change_with_markdown: ->
62
+ event = $.Event 'change', target: @$textarea
63
+ @content_change(event)
64
+
65
+ text_value: (textarea) ->
66
+ kramed(@editor.getValue())
67
+
68
+ open_file_picker: (url) ->
69
+ if @opened_picker == false
70
+ window.application_view.drawer_view.open(
71
+ url,
72
+ Locomotive.Views.ContentAssets.PickerView,
73
+ { parent_view: @ })
74
+ @opened_picker = true
75
+
76
+ hide_file_picker: ->
77
+ window.application_view.drawer_view.close()
78
+ @opened_picker = false
79
+
80
+ remove: ->
81
+ PubSub.unsubscribe(@pubsub_token)
82
+ super