locomotivecms 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -0
  3. data/app/api/locomotive/api/entities/content_type_entity.rb +1 -1
  4. data/app/api/locomotive/api/entities/site_entity.rb +1 -0
  5. data/app/api/locomotive/api/forms/content_type_form.rb +2 -1
  6. data/app/api/locomotive/api/forms/site_form.rb +2 -0
  7. data/app/api/locomotive/api/helpers/persistence_helper.rb +1 -1
  8. data/app/api/locomotive/api/resources/content_asset_resource.rb +6 -0
  9. data/app/api/locomotive/api/resources/content_type_resource.rb +2 -0
  10. data/app/api/locomotive/api/resources/current_site_resource.rb +2 -1
  11. data/app/api/locomotive/api/resources/site_resource.rb +5 -1
  12. data/app/assets/javascripts/locomotive/editor.js +7819 -100
  13. data/app/assets/javascripts/locomotive/views/content_entry_imports/new_view.js.coffee +12 -0
  14. data/app/assets/javascripts/locomotive/views/content_entry_imports/show_view.js.coffee +8 -0
  15. data/app/assets/stylesheets/locomotive/application.scss +2 -0
  16. data/app/assets/stylesheets/locomotive/editor.css +105 -12
  17. data/app/assets/stylesheets/locomotive/new/_dashboard.scss +20 -0
  18. data/app/assets/stylesheets/locomotive/old/_content_assets.scss +1 -1
  19. data/app/controllers/locomotive/content_assets_controller.rb +1 -1
  20. data/app/controllers/locomotive/content_entry_imports_controller.rb +50 -0
  21. data/app/helpers/locomotive/base_helper.rb +1 -1
  22. data/app/helpers/locomotive/shared/pages_helper.rb +1 -1
  23. data/app/jobs/locomotive/import_content_entry_job.rb +12 -0
  24. data/app/mailers/locomotive/notifications.rb +37 -11
  25. data/app/models/locomotive/account.rb +1 -0
  26. data/app/models/locomotive/concerns/asset/vignette.rb +7 -5
  27. data/app/models/locomotive/concerns/content_entry/slug.rb +7 -2
  28. data/app/models/locomotive/concerns/content_type/import.rb +124 -0
  29. data/app/models/locomotive/concerns/shared/slug.rb +3 -3
  30. data/app/models/locomotive/concerns/site/metafields.rb +26 -0
  31. data/app/models/locomotive/content_asset.rb +9 -2
  32. data/app/models/locomotive/content_type.rb +1 -0
  33. data/app/models/locomotive/section.rb +3 -1
  34. data/app/models/locomotive/site.rb +3 -0
  35. data/app/policies/locomotive/content_entry_policy.rb +1 -2
  36. data/app/policies/locomotive/content_type_policy.rb +3 -0
  37. data/app/policies/locomotive/site_policy.rb +5 -3
  38. data/app/services/locomotive/content_asset_service.rb +27 -4
  39. data/app/services/locomotive/content_entry_import_service.rb +107 -0
  40. data/app/services/locomotive/content_entry_service.rb +1 -1
  41. data/app/uploaders/locomotive/picture_uploader.rb +1 -1
  42. data/app/uploaders/locomotive/theme_asset_uploader.rb +1 -1
  43. data/app/views/locomotive/content_assets/_dropzone.html.slim +5 -1
  44. data/app/views/locomotive/content_assets/_list.html.slim +2 -2
  45. data/app/views/locomotive/content_entries/index.html.slim +8 -0
  46. data/app/views/locomotive/content_entry_imports/new.html.slim +23 -0
  47. data/app/views/locomotive/content_entry_imports/show.html.slim +54 -0
  48. data/app/views/locomotive/current_site/form/_advanced.html.slim +2 -0
  49. data/app/views/locomotive/page_content/edit.html.erb +1 -0
  50. data/app/views/locomotive/shared/account/_head.html.slim +2 -0
  51. data/app/views/locomotive/shared/account/_main_app_head.html.slim +1 -0
  52. data/config/locales/editor.en.yml +22 -0
  53. data/config/locales/editor.fr.yml +22 -0
  54. data/config/locales/en.yml +19 -0
  55. data/config/locales/es.yml +2 -0
  56. data/config/locales/flash.en.yml +6 -0
  57. data/config/locales/mongoid.en.yml +5 -1
  58. data/config/locales/mongoid.es.yml +4 -0
  59. data/config/locales/simple_form.en.yml +13 -1
  60. data/config/locales/simple_form.es.yml +2 -0
  61. data/config/routes.rb +3 -2
  62. data/lib/generators/locomotive/install/templates/carrierwave_aws.rb +5 -0
  63. data/lib/generators/locomotive/install/templates/locomotive.rb +5 -1
  64. data/lib/locomotive/configuration.rb +3 -0
  65. data/lib/locomotive/core_ext.rb +21 -0
  66. data/lib/locomotive/dragonfly.rb +6 -4
  67. data/lib/locomotive/steam_adaptor.rb +9 -5
  68. data/lib/locomotive/version.rb +1 -1
  69. metadata +37 -27
@@ -35,9 +35,19 @@ en:
35
35
  remove_button: "Remove"
36
36
  crop_button: "Crop"
37
37
 
38
+ asset_picker:
39
+ select_button: "Select"
40
+ change_button: "Change"
41
+ remove_button: "Remove"
42
+
38
43
  content_type:
39
44
  show: "Show"
40
45
 
46
+ content_entry:
47
+ select_button: "Select"
48
+ change_button: "Change"
49
+ remove_button: "Remove"
50
+
41
51
  views:
42
52
  action_bar:
43
53
  header:
@@ -54,6 +64,12 @@ en:
54
64
  seo: "SEO"
55
65
 
56
66
  pickers:
67
+ assets:
68
+ title: "Assets"
69
+ loading: "Loading the assets. Please wait!"
70
+ add: "+ add"
71
+ upload_in_progress: "Uploading..."
72
+ search_placeholder: "Name of your asset"
57
73
  images:
58
74
  title: "Images"
59
75
  loading: "Loading the images. Please wait!"
@@ -82,9 +98,15 @@ en:
82
98
  email:
83
99
  label: Email address
84
100
  placeholder: "name@example.com"
101
+ content_entry:
102
+ title: "Pick an entry"
103
+ input:
104
+ label: Instance
105
+ placeholder: Type the label of the instance
85
106
 
86
107
  preview:
87
108
  view: "View"
109
+ errorMessage: "The page couldn't be loaded. Please contact the developer of the site."
88
110
 
89
111
  sections:
90
112
  edit:
@@ -35,9 +35,19 @@ fr:
35
35
  remove_button: "Enlever"
36
36
  crop_button: "Rogner"
37
37
 
38
+ asset_picker:
39
+ select_button: "Sélectionner"
40
+ change_button: "Changer"
41
+ remove_button: "Enlever"
42
+
38
43
  content_type:
39
44
  show: "Voir"
40
45
 
46
+ content_entry:
47
+ select_button: "Sélectionner"
48
+ change_button: "Changer"
49
+ remove_button: "Enlever"
50
+
41
51
  views:
42
52
  action_bar:
43
53
  header:
@@ -54,6 +64,12 @@ fr:
54
64
  seo: "SEO"
55
65
 
56
66
  pickers:
67
+ assets:
68
+ title: "Fichiers"
69
+ loading: "Chargement des fichiers en cours !"
70
+ add: "+ ajouter"
71
+ upload_in_progress: "Téléchargement en cours..."
72
+ search_placeholder: "Nom du fichier"
57
73
  images:
58
74
  title: "Images"
59
75
  loading: "Chargement des images en cours !"
@@ -82,9 +98,15 @@ fr:
82
98
  email:
83
99
  label: Adresse Email
84
100
  placeholder: "name@example.com"
101
+ content_entry:
102
+ title: "Sélectionner une ressource"
103
+ input:
104
+ label: Titre d'une ressource
105
+ placeholder: Taper le tire de votre ressource
85
106
 
86
107
  preview:
87
108
  view: "Aperçu"
109
+ errorMessage: "La page n'a pas pu être chargée. Veuillez contacter le développeur du site."
88
110
 
89
111
  sections:
90
112
  edit:
@@ -334,6 +334,7 @@ en:
334
334
  dropzone:
335
335
  instructions: "<strong>Drop files from your computer here.</strong><br/>You can also"
336
336
  browse: "browse for a file"
337
+ maximum_file_size: "Maximum file size allowed is %{maximum}."
337
338
 
338
339
  list:
339
340
  no_items: "There are no media for now."
@@ -365,6 +366,7 @@ en:
365
366
  title: '%{type}'
366
367
  download: Download entries
367
368
  new: New entry
369
+ import: CSV Import
368
370
  bulk_destroy: Delete entries
369
371
  edit_notification_settings: Edit notification settings
370
372
  search_placeholder: "Enter your search keywords here"
@@ -379,6 +381,23 @@ en:
379
381
  shared:
380
382
  back: '&larr; Back to list'
381
383
 
384
+ content_entry_imports:
385
+ new:
386
+ title: "%{type} - Import a CSV file"
387
+ show: "See last import"
388
+ show:
389
+ title: "%{type} - Report of the CSV import"
390
+ report:
391
+ status: "Status"
392
+ created_rows: "Created entries"
393
+ updated_rows: "Updated entries"
394
+ failed_rows: "Failed entries"
395
+ statuses:
396
+ ready: "Ready"
397
+ done: "Done"
398
+ canceled: "Canceled"
399
+ failed: "Failer"
400
+
382
401
  developers_documentation:
383
402
  show:
384
403
  title: Developers
@@ -291,6 +291,8 @@ es:
291
291
  dropzone:
292
292
  instructions: "<strong>Coloca los archivos desde tu computadora aqui.</strong><br/>Tambien puedes"
293
293
  browse: "buscar un fichero"
294
+ maximum_file_size: "El tamaño máximo permitido es %{maximum}."
295
+
294
296
  list:
295
297
  no_items: "No hay archivos por ahora"
296
298
  buttons:
@@ -32,6 +32,12 @@ en:
32
32
  notice: "Model was successfully updated."
33
33
  alert: "Model was not updated."
34
34
 
35
+ content_entry_imports:
36
+ create:
37
+ notice: "The import task was successfully launched."
38
+ destroy:
39
+ notice: "The import task was manually cancelled."
40
+
35
41
  current_site:
36
42
  update:
37
43
  notice: "My site was successfully updated."
@@ -14,10 +14,14 @@ en:
14
14
  unique_account: "is already used"
15
15
  email:
16
16
  unique_account: "is already used"
17
+ locomotive/content_asset:
18
+ attributes:
19
+ source:
20
+ maximum_file_size_exceeded: exceeds the maximum file size allowed
17
21
  attributes:
18
22
  locomotive/content_entry:
19
23
  created_at: Created at
20
-
24
+
21
25
  errors:
22
26
  messages:
23
27
  domain_taken: "%{value} is already taken"
@@ -14,6 +14,10 @@ es:
14
14
  unique_account: "ya estaba en uso"
15
15
  email:
16
16
  unique_account: "ya esta en uso"
17
+ locomotive/content_asset:
18
+ attributes:
19
+ source:
20
+ maximum_file_size_exceeded: supera el tamaño máximo de fichero permitido
17
21
  attributes:
18
22
  locomotive/content_entry:
19
23
  created_at: Creado el
@@ -32,6 +32,9 @@ en:
32
32
  public_submission_accounts: "Notified Accounts"
33
33
  # "custom_fields/field":
34
34
  # select_options: "Options"
35
+ content_entry_import:
36
+ col_sep: "Column separator"
37
+ quote_char: "Quote character"
35
38
  account:
36
39
  api_key: API key
37
40
  no_api_key: None
@@ -52,6 +55,7 @@ en:
52
55
  password: "Site-Wide Password"
53
56
  url_redirections_expert_mode: "Expert mode"
54
57
  url_redirections_plain_text: "Url redirections"
58
+ maximum_uploaded_file_size: "Maximum uploaded files size"
55
59
  new:
56
60
  locales: First language
57
61
  membership:
@@ -74,6 +78,8 @@ en:
74
78
  rows: "Rows"
75
79
  head: "Head row?"
76
80
  class_name: "CSS class"
81
+ content_entry_import:
82
+ file: CSV File
77
83
 
78
84
  hints:
79
85
  locomotive:
@@ -97,6 +103,7 @@ en:
97
103
  meta_keywords: "Meta keywords used within the head tag of the page. They are separated by a comma. Required for SEO."
98
104
  meta_description: "Meta description used within the head tag of the page. Required for SEO."
99
105
  robots_txt: "Content of the <span class='code'>/robots.txt</span> file. Check the following <a href='http://www.w3.org/TR/html4/appendix/notes.html#h-B.4.1.1'>url</a> for more information."
106
+ maximum_uploaded_file_size: "In bytes."
100
107
  domains: "Add your domains just below. Documentation <a href=\"https://locomotive-v3.readme.io/docs/domains\">here</a> for more information."
101
108
  asset_host: "Site-specific asset host that overrides engine asset host (ex. \"localhost\", \"asset.dev\", \"https://asset-host.com/\")."
102
109
  memberships: "You can invite other accounts to edit/manage the site."
@@ -119,11 +126,16 @@ en:
119
126
  seo_title: "The value you fill in will replace the SEO title of the templatized page related to your model."
120
127
  meta_keywords: "Overrides the site's meta keywords used within the head tag of the page. They are separated by a comma."
121
128
  meta_description: "Overrides the site's meta description used within the head tag of the page."
129
+ content_entry_import:
130
+ col_sep: "The String placed between each field. ',' by default."
131
+ quote_char: "The character used to quote fields. '\"' by default."
122
132
  content_type:
123
133
  public_submission_accounts: "When an entry is created, send a notification email to the accounts listed below."
124
134
  image_resize_form:
125
135
  width: "in px"
126
- height: "in px"
136
+ height: "in px"
137
+ content_entry_import:
138
+ file: "Your CSV must contain a header and use the double quotes to enclose value."
127
139
 
128
140
  placeholders:
129
141
  locomotive:
@@ -46,6 +46,7 @@ es:
46
46
  cache_enabled: Cache
47
47
  private_access: "Habilitar proteccion de password"
48
48
  password: "Password global de sitio"
49
+ maximum_uploaded_file_size: Tamaño máximo de los archivos subidos
49
50
  new:
50
51
  locales: Primer lenguaje
51
52
  membership:
@@ -89,6 +90,7 @@ es:
89
90
  meta_keywords: "Keywords meta usadas dentro de la etiqueta principal de la pagina. Son separadas por una coma. Requeridas para SEO."
90
91
  meta_description: "Meta descripcion usada dentro de la etiqueta principal de la pagina. Requerida para SEO."
91
92
  robots_txt: "Contenido del archivo <span class='code'>/robots.txt</span>. Chequea el siguiente <a href='http://www.w3.org/TR/html4/appendix/notes.html#h-B.4.1.1'>url</a> para mas informacion."
93
+ maximum_uploaded_file_size: "En bytes."
92
94
  domains: "Agrega tus dominios debajo. Encontraras documentacion <a href=\"https://locomotive-v3.readme.io/docs/domains\">aqui</a> para mas informacion."
93
95
  memberships: "Puedes invitar a otras cuentas a editar/manejar el sitio."
94
96
  cache_enabled: "Cuendo este habilitado, tus paginas seran 'cacheadas' siempre y cuando el contenido no cambie. Desahbilitar el cache por pagina es permitido."
data/config/routes.rb CHANGED
@@ -66,12 +66,13 @@ Locomotive::Engine.routes.draw do
66
66
  get :new_account
67
67
  end
68
68
 
69
+ resource :content_entry_import, only: [:show, :new, :create, :destroy], path: 'content_types/:slug/imports'
70
+
69
71
  resources :content_entries, path: 'content_types/:slug/entries' do
70
72
  get :show_in_form, on: :collection
71
73
  put :sort, on: :collection
72
74
  get :export, on: :collection
73
- delete :bulk_destroy, on: :collection
74
-
75
+ delete :bulk_destroy, on: :collection
75
76
  resource :impersonation, only: [:create], controller: 'content_entry_impersonations'
76
77
  end
77
78
 
@@ -27,6 +27,11 @@ CarrierWave.configure do |config|
27
27
  config.aws_credentials[:endpoint] = ENV['S3_ENDPOINT']
28
28
  end
29
29
 
30
+ # For some endpoint like minio you need to rewrite path
31
+ if ENV['S3_PATH_STYLE'].present?
32
+ config.aws_credentials[:force_path_style] = ENV['S3_PATH_STYLE']
33
+ end
34
+
30
35
  # Put your CDN host below instead
31
36
  if ENV['S3_ASSET_HOST_URL'].present?
32
37
  config.asset_host = ENV['S3_ASSET_HOST_URL']
@@ -23,9 +23,13 @@ Locomotive.configure do |config|
23
23
  # available locales suggested to "localize" a site. You will have to pick up at least one among that list.
24
24
  # config.site_locales = %w{en de fr pl pt pt-BR it nl nb es ru ja cs bg sk uk}
25
25
 
26
- # tell if logs are enabled. Useful for debug purpose.
26
+ # tell if logs (back-office) are enabled. Useful for debug purpose.
27
27
  config.enable_logs = true
28
28
 
29
+ # setup the logger for Steam (rendering)
30
+ # config.steam_log_file = ENV['LOCOMOTIVE_STEAM_LOG'] || Rails.root.join('log', 'steam.log')
31
+ # config.steam_log_level = ::Logger::DEBUG
32
+
29
33
  # the API authentication requires to developer to pass 2 params in the header
30
34
  # of the request: X-Locomotive-Account-Email and X-Locomotive-Token.
31
35
  # However, to keep backward compatability with v2.x versions, you can use
@@ -15,6 +15,8 @@ module Locomotive
15
15
  site_locales: @@site_locales,
16
16
  cookie_key: '_locomotive_session',
17
17
  enable_logs: false,
18
+ steam_log_file: nil,
19
+ steam_log_level: ::Logger::DEBUG,
18
20
  enable_admin_ssl: false,
19
21
  delayed_job: false,
20
22
  default_locale: :en,
@@ -22,6 +24,7 @@ module Locomotive
22
24
  unsafe_token_authentication: false,
23
25
  enable_registration: true,
24
26
  optimize_uploaded_files: false,
27
+ default_maximum_uploaded_file_size: 2.megabytes,
25
28
  ui: {
26
29
  per_page: 10
27
30
  },
@@ -30,6 +30,27 @@ class String #:nodoc
30
30
 
31
31
  alias :parameterize! :permalink!
32
32
 
33
+ # Very similar to the to_url from the Stringex gem
34
+ # except that we allow the dots.
35
+ def pathify
36
+ whitespace_replacement_token = self.index('_').nil? ? '-' : '_'
37
+ self
38
+ .convert_smart_punctuation
39
+ .convert_accented_html_entities
40
+ .convert_vulgar_fractions
41
+ .convert_unreadable_control_characters
42
+ .convert_miscellaneous_html_entities
43
+ .to_ascii
44
+ .collapse
45
+ .replace_whitespace(whitespace_replacement_token)
46
+ .collapse(whitespace_replacement_token)
47
+ .downcase
48
+ end
49
+
50
+ def pathify!
51
+ replace(self.pathify)
52
+ end
53
+
33
54
  end
34
55
 
35
56
  ## Hash
@@ -3,18 +3,20 @@ require 'locomotive/dragonfly/processors/smart_thumb'
3
3
  module Locomotive
4
4
  module Dragonfly
5
5
 
6
- def self.resize_url(source, resize_string)
6
+ def self.resize_url(source, resize_string, timestamp = nil)
7
7
  if file = self.fetch_file(source)
8
- file.thumb(resize_string).url
8
+ url = file.thumb(resize_string).url
9
+ timestamp ? url + "?#{timestamp}" : url
9
10
  else
10
11
  Locomotive.log :error, "Unable to resize on the fly: #{source.inspect}"
11
12
  return
12
13
  end
13
14
  end
14
15
 
15
- def self.thumbnail_pdf(source, resize_string)
16
+ def self.thumbnail_pdf(source, resize_string, timestamp = nil)
16
17
  if file = self.fetch_file(source)
17
- file.thumb(resize_string, format: 'png', frame: 0).encode('png').url
18
+ url = file.thumb(resize_string, format: 'png', frame: 0).encode('png').url
19
+ timestamp ? url + "?#{timestamp}" : url
18
20
  else
19
21
  Locomotive.log :error, "Unable to convert the pdf: #{source.inspect}"
20
22
  return
@@ -44,6 +44,10 @@ Locomotive::Steam.configure do |config|
44
44
  # let the Rails engine handle the "no site" error
45
45
  config.render_404_if_no_site = false
46
46
 
47
+ # setup the logger
48
+ config.log_file = Locomotive.config.steam_log_file || ENV['LOCOMOTIVE_STEAM_LOG'] || Rails.root.join('log', 'steam.log')
49
+ config.log_level = Locomotive.config.steam_log_level
50
+
47
51
  config.services_hook = -> (services) {
48
52
  services.cache = Rails.cache
49
53
  repositories = services.repositories
@@ -57,8 +61,8 @@ Locomotive::Steam.configure do |config|
57
61
  }
58
62
  end
59
63
 
60
- Locomotive::Common.reset
61
- Locomotive::Common.configure do |config|
62
- config_file = ENV['LOCOMOTIVE_STEAM_LOG'] || Rails.root.join('log', 'steam.log')
63
- config.notifier = Locomotive::Common::Logger.setup(config_file.to_s)
64
- end
64
+ # Locomotive::Common.reset
65
+ # Locomotive::Common.configure do |config|
66
+ # config_file = ENV['LOCOMOTIVE_STEAM_LOG'] || Rails.root.join('log', 'steam.log')
67
+ # config.notifier = Locomotive::Common::Logger.setup(config_file.to_s, )
68
+ # end
@@ -1,3 +1,3 @@
1
1
  module Locomotive
2
- VERSION = '4.0.3'
2
+ VERSION = '4.1.0'
3
3
  end