locomotivecms 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/README.md +7 -1
  4. data/app/api/locomotive/api/entities/content_type_entity.rb +4 -1
  5. data/app/api/locomotive/api/forms/base_form.rb +4 -2
  6. data/app/api/locomotive/api/forms/content_type_form.rb +1 -0
  7. data/app/api/locomotive/api/forms/theme_asset_form.rb +1 -1
  8. data/app/api/locomotive/api/resources/content_type_resource.rb +4 -2
  9. data/app/assets/javascripts/locomotive/views/inputs/array_view.js.coffee +1 -0
  10. data/app/controllers/locomotive/current_site_controller.rb +8 -0
  11. data/app/helpers/locomotive/editable_elements_helper.rb +2 -2
  12. data/app/helpers/locomotive/errors_helper.rb +7 -3
  13. data/app/helpers/locomotive/pages_helper.rb +2 -2
  14. data/app/helpers/locomotive/shared/accounts_helper.rb +1 -1
  15. data/app/inputs/locomotive/api_key_input.rb +2 -2
  16. data/app/mailers/locomotive/notifications.rb +14 -3
  17. data/app/models/locomotive/concerns/content_type/entry_template.rb +7 -1
  18. data/app/models/locomotive/concerns/content_type/public_submission_title_template.rb +24 -0
  19. data/app/models/locomotive/concerns/site/access_points.rb +1 -0
  20. data/app/models/locomotive/concerns/site/url_redirections.rb +30 -0
  21. data/app/models/locomotive/content_entry.rb +9 -1
  22. data/app/models/locomotive/content_type.rb +1 -0
  23. data/app/models/locomotive/page.rb +1 -1
  24. data/app/models/locomotive/site.rb +1 -0
  25. data/app/policies/locomotive/site_policy.rb +4 -3
  26. data/app/uploaders/locomotive/theme_asset_uploader.rb +6 -9
  27. data/app/views/locomotive/content_assets/_list.html.slim +1 -1
  28. data/app/views/locomotive/content_entries/_entry.html.slim +1 -1
  29. data/app/views/locomotive/content_entries/_list.html.slim +1 -1
  30. data/app/views/locomotive/content_entries/edit.html.slim +2 -0
  31. data/app/views/locomotive/content_entries/form/_tabs.html.slim +3 -3
  32. data/app/views/locomotive/content_entries/new.html.slim +3 -0
  33. data/app/views/locomotive/current_site/_membership.html.slim +1 -1
  34. data/app/views/locomotive/current_site/_url_redirection.html.slim +17 -0
  35. data/app/views/locomotive/current_site/form/_access_points.html.slim +2 -0
  36. data/app/views/locomotive/current_site/form/_panes.html.slim +1 -1
  37. data/app/views/locomotive/current_site/form/_tabs.html.slim +3 -0
  38. data/app/views/locomotive/current_site/form/_url_redirections.html.slim +5 -0
  39. data/app/views/locomotive/custom_fields/select_options/_option.html.slim +3 -1
  40. data/app/views/locomotive/editable_elements/index_without_preview.html.slim +3 -3
  41. data/app/views/locomotive/notifications/new_content_entry.html.slim +4 -0
  42. data/app/views/locomotive/pages/form/_actions.html.slim +1 -1
  43. data/app/views/locomotive/pages/form/_tabs.html.slim +3 -3
  44. data/app/views/locomotive/passwords/edit.html.slim +1 -1
  45. data/app/views/locomotive/passwords/new.html.slim +1 -1
  46. data/app/views/locomotive/public_submission_accounts/edit.html.slim +1 -1
  47. data/app/views/locomotive/registrations/new.html.slim +1 -1
  48. data/app/views/locomotive/sessions/new.html.slim +1 -1
  49. data/app/views/locomotive/translations/index.html.slim +2 -1
  50. data/config/i18n-tasks.yml +110 -0
  51. data/config/locales/carrierwave.fr.yml +1 -1
  52. data/config/locales/default.en.yml +0 -49
  53. data/config/locales/default.fr.yml +1 -232
  54. data/config/locales/devise.fr.yml +1 -68
  55. data/config/locales/{admin_ui.en.yml → en.yml} +31 -91
  56. data/config/locales/flash.en.yml +8 -37
  57. data/config/locales/flash.fr.yml +1 -106
  58. data/config/locales/fr.yml +5 -0
  59. data/config/locales/inputs.fr.yml +1 -0
  60. data/config/locales/mongoid.en.yml +49 -0
  61. data/config/locales/mongoid.fr.yml +12 -0
  62. data/config/locales/simple_form.en.yml +26 -65
  63. data/config/locales/simple_form.fr.yml +1 -0
  64. data/config/{locales → old-locales}/admin_ui.bg.yml +0 -0
  65. data/config/{locales → old-locales}/admin_ui.cs.yml +0 -0
  66. data/config/{locales → old-locales}/admin_ui.de.yml +0 -0
  67. data/config/{locales → old-locales}/admin_ui.es.yml +0 -0
  68. data/config/{locales → old-locales}/admin_ui.et.yml +0 -0
  69. data/config/{locales → old-locales}/admin_ui.fr.yml +0 -0
  70. data/config/{locales → old-locales}/admin_ui.it.yml +0 -0
  71. data/config/{locales → old-locales}/admin_ui.ja.yml +0 -0
  72. data/config/{locales → old-locales}/admin_ui.nb.yml +0 -0
  73. data/config/{locales → old-locales}/admin_ui.nl.yml +0 -0
  74. data/config/{locales → old-locales}/admin_ui.pl.yml +0 -0
  75. data/config/{locales → old-locales}/admin_ui.pt-BR.yml +0 -0
  76. data/config/{locales → old-locales}/admin_ui.pt.yml +0 -0
  77. data/config/{locales → old-locales}/admin_ui.ru.yml +0 -0
  78. data/config/{locales → old-locales}/admin_ui.sk.yml +0 -0
  79. data/config/{locales → old-locales}/admin_ui.sr.yml +0 -0
  80. data/config/{locales → old-locales}/admin_ui.zh-CN.yml +0 -0
  81. data/config/{locales → old-locales}/carrierwave.bg.yml +0 -0
  82. data/config/{locales → old-locales}/carrierwave.cs.yml +0 -0
  83. data/config/{locales → old-locales}/carrierwave.de.yml +0 -0
  84. data/config/{locales → old-locales}/carrierwave.es.yml +0 -0
  85. data/config/{locales → old-locales}/carrierwave.et.yml +0 -0
  86. data/config/old-locales/carrierwave.fr.yml +4 -0
  87. data/config/{locales → old-locales}/carrierwave.it.yml +0 -0
  88. data/config/{locales → old-locales}/carrierwave.ja.yml +0 -0
  89. data/config/{locales → old-locales}/carrierwave.nb.yml +0 -0
  90. data/config/{locales → old-locales}/carrierwave.nl.yml +0 -0
  91. data/config/{locales → old-locales}/carrierwave.pl.yml +0 -0
  92. data/config/{locales → old-locales}/carrierwave.pt-BR.yml +0 -0
  93. data/config/{locales → old-locales}/carrierwave.pt.yml +0 -0
  94. data/config/{locales → old-locales}/carrierwave.ru.yml +0 -0
  95. data/config/{locales → old-locales}/carrierwave.sk.yml +0 -0
  96. data/config/{locales → old-locales}/carrierwave.sr.yml +0 -0
  97. data/config/{locales → old-locales}/carrierwave.zh-CN.yml +0 -0
  98. data/config/{locales → old-locales}/default.bg.yml +0 -0
  99. data/config/{locales → old-locales}/default.cs.yml +0 -0
  100. data/config/{locales → old-locales}/default.de.yml +0 -0
  101. data/config/{locales → old-locales}/default.es.yml +0 -0
  102. data/config/{locales → old-locales}/default.et.yml +0 -0
  103. data/config/old-locales/default.fr.yml +232 -0
  104. data/config/{locales → old-locales}/default.it.yml +0 -0
  105. data/config/{locales → old-locales}/default.ja.yml +0 -0
  106. data/config/{locales → old-locales}/default.nb.yml +0 -0
  107. data/config/{locales → old-locales}/default.nl.yml +0 -0
  108. data/config/{locales → old-locales}/default.pl.yml +0 -0
  109. data/config/{locales → old-locales}/default.pt-BR.yml +0 -0
  110. data/config/{locales → old-locales}/default.pt.yml +0 -0
  111. data/config/{locales → old-locales}/default.ru.yml +0 -0
  112. data/config/{locales → old-locales}/default.sk.yml +0 -0
  113. data/config/{locales → old-locales}/default.sr.yml +0 -0
  114. data/config/{locales → old-locales}/default.zh-CN.yml +0 -0
  115. data/config/{locales → old-locales}/devise.bg.yml +0 -0
  116. data/config/{locales → old-locales}/devise.cs.yml +0 -0
  117. data/config/{locales → old-locales}/devise.de.yml +0 -0
  118. data/config/{locales → old-locales}/devise.es.yml +0 -0
  119. data/config/{locales → old-locales}/devise.et.yml +0 -0
  120. data/config/old-locales/devise.fr.yml +68 -0
  121. data/config/{locales → old-locales}/devise.it.yml +0 -0
  122. data/config/{locales → old-locales}/devise.ja.yml +0 -0
  123. data/config/{locales → old-locales}/devise.nb.yml +0 -0
  124. data/config/{locales → old-locales}/devise.nl.yml +0 -0
  125. data/config/{locales → old-locales}/devise.pl.yml +0 -0
  126. data/config/{locales → old-locales}/devise.pt-BR.yml +0 -0
  127. data/config/{locales → old-locales}/devise.pt.yml +0 -0
  128. data/config/{locales → old-locales}/devise.ru.yml +0 -0
  129. data/config/{locales → old-locales}/devise.sk.yml +0 -0
  130. data/config/{locales → old-locales}/devise.sr.yml +0 -0
  131. data/config/{locales → old-locales}/devise.zh-CN.yml +0 -0
  132. data/config/{locales → old-locales}/flash.bg.yml +0 -0
  133. data/config/{locales → old-locales}/flash.cs.yml +0 -0
  134. data/config/{locales → old-locales}/flash.de.yml +0 -0
  135. data/config/{locales → old-locales}/flash.es.yml +0 -0
  136. data/config/{locales → old-locales}/flash.et.yml +0 -0
  137. data/config/old-locales/flash.fr.yml +106 -0
  138. data/config/{locales → old-locales}/flash.it.yml +0 -0
  139. data/config/{locales → old-locales}/flash.ja.yml +0 -0
  140. data/config/{locales → old-locales}/flash.nb.yml +0 -0
  141. data/config/{locales → old-locales}/flash.nl.yml +0 -0
  142. data/config/{locales → old-locales}/flash.pl.yml +0 -0
  143. data/config/{locales → old-locales}/flash.pt-BR.yml +0 -0
  144. data/config/{locales → old-locales}/flash.pt.yml +0 -0
  145. data/config/{locales → old-locales}/flash.ru.yml +0 -0
  146. data/config/{locales → old-locales}/flash.sk.yml +0 -0
  147. data/config/{locales → old-locales}/flash.sr.yml +0 -0
  148. data/config/{locales → old-locales}/flash.zh-CN.yml +0 -0
  149. data/config/routes.rb +1 -0
  150. data/lib/generators/locomotive/install/templates/carrierwave.rb +12 -7
  151. data/lib/generators/locomotive/install/templates/devise.rb +127 -55
  152. data/lib/generators/locomotive/install/templates/dragonfly.rb +1 -1
  153. data/lib/generators/locomotive/install/templates/locomotive.rb +2 -0
  154. data/lib/locomotive/carrierwave/asset.rb +23 -11
  155. data/lib/locomotive/carrierwave/patches.rb +18 -0
  156. data/lib/locomotive/configuration.rb +6 -5
  157. data/lib/locomotive/dependencies.rb +1 -0
  158. data/lib/locomotive/engine.rb +4 -0
  159. data/lib/locomotive/middlewares/site.rb +1 -0
  160. data/lib/locomotive/steam/middlewares/missing_translations.rb +1 -1
  161. data/lib/locomotive/steam/services/api_entry_submission_service.rb +8 -1
  162. data/lib/locomotive/steam_adaptor.rb +9 -7
  163. data/lib/locomotive/version.rb +1 -1
  164. data/spec/fixtures/assets/ruby_logo.svg +948 -0
  165. data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +1 -1
  166. data/spec/mailers/locomotive/notifications_spec.rb +39 -1
  167. data/spec/models/locomotive/concerns/site/url_redirections_spec.rb +42 -0
  168. data/spec/models/locomotive/theme_asset_spec.rb +29 -0
  169. data/spec/support/factories.rb +15 -1
  170. data/spec/support/features/site_helpers.rb +8 -1
  171. data/spec/support/shared_contexts/api_site_setup.rb +1 -1
  172. metadata +120 -106
  173. data/app/views/locomotive/shared/_footer.html.slim +0 -2
  174. data/app/views/locomotive/shared/_form_actions.html.slim +0 -14
  175. data/app/views/locomotive/shared/actions/_contents.html.slim +0 -7
  176. data/config/cucumber.yml +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d10fc58170b51a43910d6f1471a3f3ef30f06591
4
- data.tar.gz: 7e07b1bb55d2f426bbdb595e4e92f31b7e4d5a15
3
+ metadata.gz: f5fcc2bd87ac0d01a19c8ea5f798ff338f1eb8fc
4
+ data.tar.gz: b189780fd9fbc5c04631715245fa79a068d355f9
5
5
  SHA512:
6
- metadata.gz: f4a440454798b26f56aa64e1a60ad77a8b676ac7337e6c11075b2c594528d877b0337a7326d6cd8d64fa0674de8f960f2a6e92341c13d01230b1daa4ec450089
7
- data.tar.gz: 1406d6ea958450d83374bc6a5ce5ac59e0fdf72bf82b798ce693fc2436b37e690b6e3e4c1a23083b6123ba4d79de63a4a41171fdbf7aca1197370e96da6db16f
6
+ metadata.gz: 0b3a1a9f8d51163f4c16999f78e02d9cbcde1b00875bbb8694be328d50d2afcece5af4f8eb087b6ebb0d0bae1322770f363a5100d99acd8785f148c86334762c
7
+ data.tar.gz: a48ea5fc1565b9a175ae2b3e515644fed3dd15664961c75a37ab152630108cd3052db6f50bd867f21381d6601ad2dfde8420d8180f3e57d25dcc99a0e72a8231
data/Gemfile CHANGED
@@ -22,10 +22,8 @@ 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: 'c487443', require: false
25
+ # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'c1d1120', require: false
26
26
 
27
- # gem 'locomotive-aloha-rails', path: '../gems/aloha-rails' # for Developers
28
- # gem 'locomotive-tinymce-rails', path: '../gems/tinymce-rails' # for Developers
29
27
  # gem 'locomotive_liquid', path: '../gems/liquid' # for Developers
30
28
  # gem 'locomotivecms_solid', path: '../gems/solid' # for Developers
31
29
 
@@ -42,6 +40,9 @@ group :development do
42
40
  # gem 'unicorn-rails' # Using unicorn_rails instead of webrick (default server)
43
41
  # gem 'thin'
44
42
  gem 'puma'
43
+
44
+ # i18n-tasks helps you find and manage missing and unused translations.
45
+ gem 'i18n-tasks', '~> 0.8.7'
45
46
  end
46
47
 
47
48
  group :profile, :development do
data/README.md CHANGED
@@ -40,7 +40,7 @@ If you can not wait for playing with our new version, you still can use the curr
40
40
 
41
41
  ## Technologies ##
42
42
 
43
- Here is a list of the main gems used to power the Locomotive backend:
43
+ Here is a list of the main gems used to power the Locomotive platform:
44
44
 
45
45
  - Rails 4.2 - *web framework*
46
46
  - Bootstrap - *UI framework*
@@ -55,6 +55,12 @@ Here is a list of the main gems used to power the Locomotive backend:
55
55
  - Get help or discuss Locomotive at the [Locomotive Google group](https://groups.google.com/forum/?fromgroups#!forum/locomotivecms)
56
56
  - [Follow us on twitter](http://twitter.com/locomotivecms)
57
57
 
58
+ ## Translating the back-office ##
59
+
60
+ By default, the Locomotive back-office is fully translated in English. But adding a new language is pretty straightforward since we now manage all our I18n translation keys in [Transifex](https://www.transifex.com), a platform dedicated to this kind of task.
61
+
62
+ Here is our Transifex portal page: [https://www.transifex.com/locomotive/locomotive-engine](https://www.transifex.com/locomotive/locomotive-engine). Feel free to sign up and translate!
63
+
58
64
  ## Contributing to Locomotive ##
59
65
 
60
66
  Locomotive is an open source project, we encourage contributions. If you have found a bug and want to contribute a fix, or have a new feature you would like to add, follow the steps below to get your patch into the project:
@@ -5,7 +5,10 @@ module Locomotive
5
5
  class ContentTypeEntity < BaseEntity
6
6
 
7
7
  expose :name, :slug, :description, :label_field_name, :order_direction,
8
- :public_submission_enabled, :entry_template, :display_settings
8
+ :public_submission_enabled,
9
+ :public_submission_accounts,
10
+ :public_submission_title_template,
11
+ :entry_template, :display_settings
9
12
 
10
13
  expose :fields, using: ContentTypeFieldEntity do |content_type, _|
11
14
  content_type.ordered_entries_custom_fields || []
@@ -52,9 +52,11 @@ module Locomotive
52
52
 
53
53
  # @override - only return set attributes
54
54
  def serializable_hash
55
- changed.inject({}) do |hash, attribute|
55
+ changed.sort_by do |name|
56
+ self.class.attributes.index(:"#{name}=")
57
+ end.inject({}) do |hash, attribute|
56
58
  hash.merge({ attribute => send(attribute) })
57
- end.with_indifferent_access
59
+ end.to_h.with_indifferent_access
58
60
  end
59
61
 
60
62
  def persisted?
@@ -10,6 +10,7 @@ module Locomotive
10
10
  :order_by, :order_direction, :group_by,
11
11
  :public_submission_enabled,
12
12
  :public_submission_accounts,
13
+ :public_submission_title_template,
13
14
  :entry_template,
14
15
  :entries_custom_fields_attributes,
15
16
  :display_settings
@@ -4,7 +4,7 @@ module Locomotive
4
4
 
5
5
  class ThemeAssetForm < BaseForm
6
6
 
7
- attrs :source, :folder, :checksum
7
+ attrs :folder, :source, :checksum
8
8
 
9
9
  end
10
10
 
@@ -61,8 +61,9 @@ module Locomotive
61
61
  optional :entry_template
62
62
  optional :raw_item_template # deprecated
63
63
  optional :display_settings
64
- optional :public_submission_account_emails
65
64
  optional :public_submission_enabled
65
+ optional :public_submission_account_emails
66
+ optional :public_submission_title_template
66
67
  end
67
68
  end
68
69
  post do
@@ -105,8 +106,9 @@ module Locomotive
105
106
  optional :entry_template
106
107
  optional :raw_item_template # deprecated
107
108
  optional :display_settings
108
- optional :public_submission_account_emails
109
109
  optional :public_submission_enabled
110
+ optional :public_submission_account_emails
111
+ optional :public_submission_title_template
110
112
  end
111
113
  end
112
114
  put ':id' do
@@ -40,6 +40,7 @@ class Locomotive.Views.Inputs.ArrayView extends Backbone.View
40
40
 
41
41
  make_remote_selectable: ->
42
42
  Select2.helpers.build @$new_input
43
+ @$new_input.on 'change', (e) => @begin_add_item(e)
43
44
 
44
45
  make_simple_selectable: ->
45
46
  @$new_input.select2
@@ -44,6 +44,14 @@ module Locomotive
44
44
  end
45
45
  end
46
46
 
47
+ def new_url_redirection
48
+ if params[:url_redirection].present? && params[:url_redirection].include?(' ')
49
+ render partial: 'url_redirection', locals: { url_redirection: params[:url_redirection].split(' ') }
50
+ else
51
+ head :unprocessable_entity
52
+ end
53
+ end
54
+
47
55
  private
48
56
 
49
57
  def load_site
@@ -46,9 +46,9 @@ module Locomotive
46
46
 
47
47
  def options_for_page_blocks(blocks)
48
48
  options_for_select(
49
- [[t('.blocks.all'), '']] +
49
+ [[t(:all, scope: 'locomotive.editable_elements.edit.blocks'), '']] +
50
50
  blocks.map do |block|
51
- block[:name].nil? ? [t('.blocks.unknown'), '_unknown'] : [block[:label], block[:name]]
51
+ block[:name].nil? ? [t(:unknown, scope: 'locomotive.editable_elements.edit.blocks'), '_unknown'] : [block[:label], block[:name]]
52
52
  end)
53
53
  end
54
54
 
@@ -9,13 +9,17 @@ module Locomotive
9
9
  options = Locomotive.config.host ? { host: Locomotive.config.host } : { only_path: true }
10
10
 
11
11
  if Locomotive::Account.count == 0
12
- [t('.message.create_account'), sign_up_url(options)]
12
+ [no_site_message(:create_account), sign_up_url(options)]
13
13
  elsif current_locomotive_account
14
- [t('.message.add_domain', host: request.host), sites_url(options)]
14
+ [no_site_message(:add_domain), sites_url(options)]
15
15
  else
16
- [t('.message.sign_in', host: request.host), new_locomotive_account_session_url(options)]
16
+ [no_site_message(:sign_in), new_locomotive_account_session_url(options)]
17
17
  end
18
18
  end
19
19
 
20
+ def no_site_message(error_type)
21
+ t(error_type, host: request.host, scope: 'locomotive.errors.no_site.messsage')
22
+ end
23
+
20
24
  end
21
25
  end
@@ -39,8 +39,8 @@ module Locomotive
39
39
 
40
40
  def options_for_page_redirect_type
41
41
  [
42
- [t('.redirect_type.permanent'), 301],
43
- [t('.redirect_type.temporary'), 302]
42
+ [t('redirect_type.permanent', scope: 'locomotive.pages.form'), 301],
43
+ [t('redirect_type.temporary', scope: 'locomotive.pages.form'), 302]
44
44
  ]
45
45
  end
46
46
 
@@ -12,7 +12,7 @@ module Locomotive
12
12
 
13
13
  def account_avatar_and_name(account, size = '70x70#')
14
14
  avatar = image_tag(account_avatar_url(account, size), class: 'img-circle', style: 'width: 20px')
15
- profile = avatar + (account.try(:name) || t('.unknown_account'))
15
+ profile = avatar + (account.try(:name) || t(:unknown_account, scope: 'locomotive.dashboard.activity'))
16
16
  end
17
17
 
18
18
  end
@@ -8,13 +8,13 @@ module Locomotive
8
8
  end
9
9
 
10
10
  def api_key_html
11
- api_key = object.api_key || I18n.t('locomotive.api_key.none')
11
+ api_key = object.api_key || I18n.t('simple_form.labels.locomotive.account.no_api_key')
12
12
  template.content_tag :code, api_key
13
13
  end
14
14
 
15
15
  def regenerate_button
16
16
  url = options[:url]
17
- template.content_tag :button, I18n.t('locomotive.api_key.button'),
17
+ template.content_tag :button, I18n.t('simple_form.buttons.locomotive.account.new_api_key'),
18
18
  class: 'btn btn-default btn-primary btn-sm',
19
19
  data: {
20
20
  url: url,
@@ -4,16 +4,27 @@ module Locomotive
4
4
  default from: Locomotive.config.mailer_sender
5
5
 
6
6
  def new_content_entry(account, entry)
7
- @account, @entry, @type = account, entry, entry.content_type
7
+ @site, @account = entry.site, account
8
+ @entry, @type = entry, entry.content_type
8
9
 
9
10
  @domain = entry.site.domains.first ||
10
11
  ActionMailer::Base.default_url_options[:host] ||
11
12
  'localhost'
12
13
 
13
- subject = t('locomotive.notifications.new_content_entry.subject', domain: @domain, type: @type.name, locale: account.locale)
14
+ subject = new_content_entry_subject(entry, domain: @domain, type: @type.name, locale: account.locale)
14
15
 
15
16
  mail subject: subject, to: account.email
16
17
  end
17
- end
18
18
 
19
+ protected
20
+
21
+ def new_content_entry_subject(entry, options)
22
+ if entry.content_type.public_submission_title_template.blank?
23
+ t('locomotive.notifications.new_content_entry.subject', options)
24
+ else
25
+ entry.content_type.public_submission_title(entry, options)
26
+ end
27
+ end
28
+
29
+ end
19
30
  end
@@ -25,7 +25,13 @@ module Locomotive
25
25
  def to_steam_entry(entry)
26
26
  entry_attributes = entry.attributes.symbolize_keys
27
27
 
28
- steam_repositories.content_entry.with(to_steam).build(entry_attributes)
28
+ steam_repositories.content_entry.with(to_steam).build(entry_attributes).tap do |entity|
29
+ # copy error messages
30
+ entry.errors.each do |name, message|
31
+ next if name == :_slug
32
+ entity.errors.add(name, message)
33
+ end
34
+ end
29
35
  end
30
36
 
31
37
  def steam_repositories
@@ -0,0 +1,24 @@
1
+ module Locomotive
2
+ module Concerns
3
+ module ContentType
4
+ module PublicSubmissionTitleTemplate
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ field :public_submission_title_template
10
+ end
11
+
12
+ def public_submission_title(entry, options)
13
+ template = ::Liquid::Template.parse(self.public_submission_title_template, {})
14
+
15
+ assigns = { 'site' => self.site, 'entry' => entry }.merge(options)
16
+ registers = { site: self.site }
17
+
18
+ template.render(::Liquid::Context.new({}, assigns, registers))
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -10,6 +10,7 @@ module Locomotive
10
10
  ## fields ##
11
11
  field :handle
12
12
  field :domains, type: Array, default: []
13
+ field :redirect_to_first_domain, type: Boolean, default: false
13
14
 
14
15
  ## indexes ##
15
16
  index domains: 1
@@ -0,0 +1,30 @@
1
+ module Locomotive
2
+ module Concerns
3
+ module Site
4
+ module UrlRedirections
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+
10
+ ## fields ##
11
+ field :url_redirections, type: Array
12
+
13
+ end
14
+
15
+ def url_redirections=(array)
16
+ super((array || []).flatten.map do |path|
17
+ add_leading_slash_to(path)
18
+ end.each_slice(2).to_a)
19
+ end
20
+
21
+ protected
22
+
23
+ def add_leading_slash_to(path)
24
+ path.starts_with?('/') ? path : "/#{path}"
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -77,6 +77,10 @@ module Locomotive
77
77
 
78
78
  alias :to_label :_label
79
79
 
80
+ def content_type_slug
81
+ self.content_type.try(:slug)
82
+ end
83
+
80
84
  def as_json(*args)
81
85
  super.tap { |json| json['_label'] = _label }
82
86
  end
@@ -116,8 +120,12 @@ module Locomotive
116
120
  end
117
121
  end
118
122
 
123
+ def to_steam(type = nil)
124
+ (type || self.content_type).to_steam_entry(self)
125
+ end
126
+
119
127
  def to_liquid(type = nil)
120
- (type || self.content_type).to_steam_entry(self).to_liquid
128
+ to_steam(type).to_liquid
121
129
  end
122
130
 
123
131
  def touch_site_attribute
@@ -13,6 +13,7 @@ module Locomotive
13
13
  include Concerns::ContentType::GroupBy
14
14
  include Concerns::ContentType::OrderBy
15
15
  include Concerns::ContentType::ClassHelpers
16
+ include Concerns::ContentType::PublicSubmissionTitleTemplate
16
17
 
17
18
  ## fields ##
18
19
  field :name
@@ -130,7 +130,7 @@ module Locomotive
130
130
 
131
131
  def build_fullpath
132
132
  if self.index_or_not_found?
133
- self.fullpath = self.slug
133
+ self.site.each_locale { |locale, current| self.fullpath = self.slug }
134
134
  else
135
135
  _parent = self.parent # do not hit the database more than once
136
136
 
@@ -9,6 +9,7 @@ module Locomotive
9
9
  include Concerns::Site::Locales
10
10
  include Concerns::Site::Timezone
11
11
  include Concerns::Site::Cache
12
+ include Concerns::Site::UrlRedirections
12
13
 
13
14
  ## fields ##
14
15
  field :name
@@ -46,16 +46,17 @@ module Locomotive
46
46
  end
47
47
 
48
48
  def permitted_attributes
49
- plain = [:name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :timezone_name, :robots_txt, :cache_enabled]
50
- hash = { domains: [], locales: [] }
49
+ plain = [:name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :timezone_name, :robots_txt, :cache_enabled, :redirect_to_first_domain]
50
+ hash = { domains: [], locales: [], url_redirections: [] }
51
51
 
52
52
  unless update_advanced?
53
53
  plain -= [:timezone_name, :robots_txt, :cache_enabled]
54
54
  hash.delete(:locales)
55
+ hash.delete(:url_redirections)
55
56
  end
56
57
 
57
58
  unless point?
58
- plain -= [:handle]
59
+ plain -= [:handle, :redirect_to_first_domain]
59
60
  hash.delete(:domains)
60
61
  end
61
62
 
@@ -13,15 +13,12 @@ module Locomotive
13
13
  %w(jpg jpeg gif png css js swf flv eot svg ttf woff woff2 otf ico htc map)
14
14
  end
15
15
 
16
- def self.url_for(site, path)
17
- build(site, path).url
18
- end
19
-
20
- def self.build(site, path)
21
- asset = site.theme_assets.build(folder: File.dirname(path))
22
- uploader = ThemeAssetUploader.new(asset)
23
- uploader.retrieve_from_store!(File.basename(path))
24
- uploader
16
+ def apply_content_type_exception(value)
17
+ if content_type == 'image/svg+xml' && model.folder.starts_with?('fonts')
18
+ :font
19
+ else
20
+ value
21
+ end
25
22
  end
26
23
 
27
24
  def self.content_types
@@ -31,7 +31,7 @@
31
31
 
32
32
  | &nbsp;&nbsp;
33
33
 
34
- = link_to content_asset_path(current_site, asset, params.slice(:types, :query, :page, :per_page)), class: 'remove', method: :delete, data: { confirm: t('locomotive.messages.confirm'), return_url: request.original_url }, title: t('locomotive.buttons.delete'), remote: remote do
34
+ = link_to content_asset_path(current_site, asset, params.slice(:types, :query, :page, :per_page)), class: 'remove', method: :delete, data: { confirm: t('locomotive.messages.confirm'), return_url: request.original_url }, title: t(:delete, scope: 'simple_form.buttons.defaults.locomotive'), remote: remote do
35
35
  i.fa.fa-trash-o
36
36
 
37
37
  .text-center
@@ -17,7 +17,7 @@
17
17
  = item._label
18
18
 
19
19
  .buttons
20
- = link_to t(:edit, scope: 'locomotive.shared.form.array_input'), edit_content_entry_path(current_site, slug, item, _location: false), class: 'choose btn btn-primary btn-sm'
20
+ = link_to t(:edit, scope: 'locomotive.inputs.array'), edit_content_entry_path(current_site, slug, item, _location: false), class: 'choose btn btn-primary btn-sm'
21
21
  | &nbsp;
22
22
  = link_to '#', class: 'delete' do
23
23
  i.fa.fa-trash-o