refinerycms-images 2.1.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/refinery/admin/images_controller.rb +62 -49
- data/app/helpers/refinery/admin/images_helper.rb +6 -6
- data/app/models/refinery/image.rb +16 -61
- data/app/models/refinery/thumbnail_dimensions.rb +97 -0
- data/app/views/refinery/admin/images/_actions.html.erb +6 -7
- data/app/views/refinery/admin/images/_form.html.erb +30 -12
- data/app/views/refinery/admin/images/_grid_view.html.erb +9 -16
- data/app/views/refinery/admin/images/_list_view.html.erb +4 -4
- data/app/views/refinery/admin/images/_list_view_image.html.erb +24 -15
- data/app/views/refinery/admin/images/index.html.erb +3 -3
- data/app/views/refinery/admin/images/insert.html.erb +1 -1
- data/config/locales/ca.yml +44 -0
- data/config/locales/cs.yml +5 -0
- data/config/locales/de.yml +5 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/fr.yml +4 -0
- data/config/locales/it.yml +4 -14
- data/config/locales/nl.yml +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20140814073957_add_title_and_alt_to_refinery_images.rb +8 -0
- data/db/migrate/20150430171341_translate_refinery_images.rb +22 -0
- data/lib/generators/refinery/images/templates/config/initializers/refinery/images.rb.erb +2 -5
- data/lib/refinery/images.rb +4 -1
- data/lib/refinery/images/configuration.rb +4 -6
- data/lib/refinery/images/dragonfly.rb +38 -27
- data/lib/refinery/images/engine.rb +2 -3
- data/license.md +1 -1
- data/refinerycms-images.gemspec +6 -3
- data/spec/factories/image.rb +6 -2
- data/spec/features/refinery/admin/images_spec.rb +49 -136
- data/spec/lib/generators/refinery/images/images_generator_spec.rb +1 -1
- data/spec/lib/refinery/images/dragonfly_spec.rb +34 -0
- data/spec/models/refinery/image_spec.rb +81 -43
- data/spec/models/refinery/thumbnail_dimensions_spec.rb +18 -0
- data/spec/support/shared contexts/admin_images_tab.rb +17 -0
- data/spec/support/shared contexts/many_images.rb +5 -0
- data/spec/support/shared contexts/no_images.rb +3 -0
- data/spec/support/shared contexts/one_image.rb +3 -0
- data/spec/support/shared contexts/visual_editor_add_image.rb +31 -0
- data/spec/support/shared examples/image_deleter.rb +31 -0
- data/spec/support/shared examples/image_editor.rb +3 -0
- data/spec/support/shared examples/image_indexer.rb +118 -0
- data/spec/support/shared examples/image_inserter.rb +53 -0
- data/spec/support/shared examples/image_previewer.rb +41 -0
- data/spec/support/shared examples/image_translator.rb +31 -0
- data/spec/support/shared examples/image_uploader.rb +37 -0
- data/spec/support/spec_helper.rb +19 -0
- data/test.html +126 -0
- metadata +64 -9
@@ -1,9 +1,11 @@
|
|
1
|
-
<%= form_for @image, :
|
2
|
-
:
|
1
|
+
<%= form_for @image, url: (@url_override or @image.persisted? ? refinery.admin_image_path(@image) : refinery.admin_images_path),
|
2
|
+
html: { multipart: true } do |f| %>
|
3
3
|
|
4
4
|
<%= render '/refinery/admin/error_messages',
|
5
|
-
:
|
6
|
-
:
|
5
|
+
object: @image,
|
6
|
+
include_object_name: false %>
|
7
|
+
|
8
|
+
<%= render '/refinery/admin/locale_picker', :current_locale => Globalize.locale if @image.persisted? %>
|
7
9
|
|
8
10
|
<div class="field">
|
9
11
|
<% if action_name =~ /(edit)|(update)/ %>
|
@@ -16,21 +18,37 @@
|
|
16
18
|
</p>
|
17
19
|
<% else %>
|
18
20
|
<% # we must only hint at multiple when it's a new record otherwise update fails. %>
|
19
|
-
<%= f.file_field :image, :
|
21
|
+
<%= f.file_field :image, multiple: true %>
|
20
22
|
<% end %>
|
21
23
|
</div>
|
22
24
|
|
23
25
|
<div class="field">
|
24
|
-
<label><%= t('.maximum_image_size', :
|
26
|
+
<label><%= t('.maximum_image_size', bytes: number_to_human_size(Refinery::Images.max_image_size)) %></label>
|
27
|
+
</div>
|
28
|
+
<div class="field" id="title">
|
29
|
+
<span class='label_with_help'>
|
30
|
+
<%= f.label :image_title, t('.image_title') %>
|
31
|
+
<%= refinery_help_tag t('.image_title_help') %>
|
32
|
+
</span>
|
33
|
+
<%= f.text_field :image_title, placeholder: t('.image_title') %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="field" id="alt">
|
37
|
+
<span class='label_with_help'>
|
38
|
+
<%= f.label :image_alt, t('.image_alt') %>
|
39
|
+
<%= refinery_help_tag t('.image_alt_help') %>
|
40
|
+
</span>
|
41
|
+
<%= f.text_field :image_alt, placeholder: t('.image_alt') %>
|
25
42
|
</div>
|
26
43
|
|
27
44
|
<input type="hidden" name="wymeditor" value="<%= params[:wymeditor] %>">
|
28
45
|
|
29
|
-
<%= render '/refinery/admin/form_actions', :
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
46
|
+
<%= render '/refinery/admin/form_actions', f: f,
|
47
|
+
continue_editing: false,
|
48
|
+
hide_cancel: (@app_dialog or action_name == 'insert' or from_dialog?),
|
49
|
+
delete_title: t('delete', scope: 'refinery.admin.images'),
|
50
|
+
delete_confirmation: t('message', scope: 'refinery.admin.delete', title: @image.image_name),
|
51
|
+
cancel_url: refinery.admin_images_path -%>
|
34
52
|
|
35
53
|
<% if @app_dialog %>
|
36
54
|
<input type="hidden" name="app_dialog" value="<%= @app_dialog %>" />
|
@@ -45,6 +63,6 @@
|
|
45
63
|
<% if action_name =~ /(edit)|(update)/ %>
|
46
64
|
<div id="existing_image">
|
47
65
|
<label><%=t('.current_image') %></label>
|
48
|
-
<%= image_fu @thumbnail || @image, '225x255>', :
|
66
|
+
<%= image_fu @thumbnail || @image, '225x255>', class: 'brown_border' %>
|
49
67
|
</div>
|
50
68
|
<% end %>
|
@@ -1,22 +1,15 @@
|
|
1
|
-
<ul id="image_grid" class="<%= ['clearfix', 'pagination_frame', pagination_css_class].compact.join(' ') %>">
|
1
|
+
<ul id="image_grid" class="<%= ['clearfix', 'pagination_frame', 'images_list', pagination_css_class].compact.join(' ') %>">
|
2
2
|
<% @images.each_with_index do |image, index| -%>
|
3
3
|
<li id="image_<%= image.id %>" class="image_<%= index % 5 %>">
|
4
|
-
<%= image_fu image, '135x135#c', :
|
4
|
+
<%= image_fu image, '135x135#c', title: image.title %>
|
5
5
|
<span class="actions">
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
refinery.admin_image_path(image, params.slice(:page)),
|
14
|
-
:class => 'cancel confirm-delete',
|
15
|
-
:title => t('delete', :scope => 'refinery.admin.images'),
|
16
|
-
:data => {
|
17
|
-
:confirm => t('message', :scope => 'refinery.admin.delete', :title => image.title)
|
18
|
-
},
|
19
|
-
:method => :delete %>
|
6
|
+
|
7
|
+
<%= action_icon :preview, image.url, t('view_live_html', scope: 'refinery.admin.images') %>
|
8
|
+
<%= action_icon :edit, refinery.edit_admin_image_path(image), t('edit', scope: 'refinery.admin.images') %>
|
9
|
+
<%= action_icon :delete, refinery.admin_image_path(image, params.slice(:page)), t('delete', scope: 'refinery.admin.images'), class: 'confirm-delete',
|
10
|
+
data: { confirm: t('message', scope: 'refinery.admin.delete', title: image.title) } %>
|
11
|
+
<%= action_icon :info, '#', "Title: #{image.title} Alt text: #{image.alt}" %>
|
12
|
+
|
20
13
|
</span>
|
21
14
|
</li>
|
22
15
|
<% end -%>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<div class="<%= ['clearfix', 'pagination_frame', pagination_css_class].compact.join(' ') %>">
|
1
|
+
<div id= 'image_list' class="<%= ['clearfix', 'pagination_frame', pagination_css_class].compact.join(' ') %>">
|
2
2
|
<% group_by_date(@images).each do |container| %>
|
3
3
|
<% date_time = (image_group = container.last).first.created_at %>
|
4
4
|
<% date = Date.parse(date_time.to_s) %>
|
5
|
-
<h3><%= l(date, :
|
6
|
-
<ul>
|
7
|
-
<%= render :
|
5
|
+
<h3><%= l(date, format: :long ) %></h3>
|
6
|
+
<ul class='images_list'>
|
7
|
+
<%= render partial: 'list_view_image', collection: image_group %>
|
8
8
|
</ul>
|
9
9
|
<% end %>
|
10
10
|
</div>
|
@@ -1,21 +1,30 @@
|
|
1
1
|
<li id="sortable_<%= list_view_image.id %>" class="clearfix record <%= cycle('on', 'on-hover') %>">
|
2
2
|
<span class="title">
|
3
|
-
<%= list_view_image.title %>
|
3
|
+
<%= list_view_image.title %>
|
4
4
|
</span>
|
5
|
+
|
6
|
+
<% if Refinery::I18n.frontend_locales.many? %>
|
7
|
+
<span class='locales'>
|
8
|
+
<% list_view_image.translations.sort_by{ |t| Refinery::I18n.frontend_locales.index(t.locale)}.each do |translation| %>
|
9
|
+
<% if translation.image_title.present? %>
|
10
|
+
<%= link_to refinery.edit_admin_image_path(list_view_image, switch_locale: translation.locale),
|
11
|
+
class: 'locale', title: translation.locale.upcase do %>
|
12
|
+
|
13
|
+
<div class="<%=translation.locale %> locale_marker">
|
14
|
+
<%= locale_text_icon(translation.locale.upcase) %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
</span>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<span class="preview"><%= list_view_image.image_name %></span>
|
5
23
|
<span class="actions">
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<%=
|
10
|
-
|
11
|
-
:title => t('edit', :scope => 'refinery.admin.images') %>
|
12
|
-
<%= link_to refinery_icon_tag('delete.png'),
|
13
|
-
refinery.admin_image_path(list_view_image),
|
14
|
-
:class => 'cancel confirm-delete',
|
15
|
-
:title => t('delete', :scope => 'refinery.admin.images'),
|
16
|
-
:data => {
|
17
|
-
:confirm => t('message', :scope => 'refinery.admin.delete', :title => list_view_image.title)
|
18
|
-
},
|
19
|
-
:method => :delete %>
|
24
|
+
|
25
|
+
<%= action_icon :preview, list_view_image.url, t('view_live_html', scope: 'refinery.admin.images') %>
|
26
|
+
<%= action_icon :edit, refinery.edit_admin_image_path(list_view_image), t('edit', scope: 'refinery.admin.images') %>
|
27
|
+
<%= action_icon :delete, refinery.admin_image_path(list_view_image), t('delete', scope: 'refinery.admin.images'), class: 'confirm-delete',
|
28
|
+
data: { confirm: t('message', scope: 'refinery.admin.delete', title: list_view_image.title)} %>
|
20
29
|
</span>
|
21
30
|
</li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% user_can_modify_images =
|
1
|
+
<% user_can_modify_images = current_refinery_user.has_plugin?('refinery_images') %>
|
2
2
|
<div id="dialog_menu_left">
|
3
3
|
<% if (any_images = @images.any?) or searching? %>
|
4
4
|
<span id="existing_image_radio" class="radio<%= ' selected_radio' if (no_errors = @image.errors.empty?) %>">
|
@@ -0,0 +1,44 @@
|
|
1
|
+
ca:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_images:
|
5
|
+
title: Imatges
|
6
|
+
description: Gestionar imatges
|
7
|
+
article: femení
|
8
|
+
admin:
|
9
|
+
images:
|
10
|
+
delete: Esborrar aquesta imatge per sempre
|
11
|
+
edit: Editar aquesta imatge
|
12
|
+
form:
|
13
|
+
image: Imatge
|
14
|
+
use_current_image: Usar imatge actual
|
15
|
+
or: o
|
16
|
+
replace_image: " reemplaçar-la amb aquesta altra..."
|
17
|
+
current_image: Imatge actual
|
18
|
+
maximum_image_size: "El pes màxim per a una imatge són %{bytes}."
|
19
|
+
actions:
|
20
|
+
create_new_image: Crear nova imatge
|
21
|
+
records:
|
22
|
+
no_images_yet: Encara no hi ha imatges. Fes clic a "Crear nova imatge" per afegir la primera.
|
23
|
+
index:
|
24
|
+
view:
|
25
|
+
switch_to: "Canviar a vista %{view_name}"
|
26
|
+
list: llista
|
27
|
+
grid: quadrícula
|
28
|
+
view_live_html: Veure imatge <br/><em>Obre en finestra nova</em>
|
29
|
+
existing_image:
|
30
|
+
button_text: Inserir
|
31
|
+
resize_image: Redimensionar la imatge?
|
32
|
+
size: Mida
|
33
|
+
insert:
|
34
|
+
existing_image: Imatge existent
|
35
|
+
new_image: Nova imatge
|
36
|
+
activerecord:
|
37
|
+
models:
|
38
|
+
refinery/image: "imatge"
|
39
|
+
errors:
|
40
|
+
models:
|
41
|
+
refinery/image:
|
42
|
+
blank: Has d'indicar què imatge vols pujar
|
43
|
+
too_big: "La imatge ha de pesar menys de %{size} bytes"
|
44
|
+
incorrect_format: "La teva imatge ha de ser un arxiu JPG, PNG o GIF"
|
data/config/locales/cs.yml
CHANGED
@@ -15,6 +15,10 @@ cs:
|
|
15
15
|
replace_image: " nahradit jej tímto..."
|
16
16
|
current_image: Vybraný obrázek
|
17
17
|
maximum_image_size: Maximální velikost obrázku je %{bytes}.
|
18
|
+
image_title: Název
|
19
|
+
image_title_help: Extra informace o obrázku
|
20
|
+
image_alt: Alternativní text
|
21
|
+
image_alt_help: "Text místo obrázku, když nemůže být obrázek zobrazen."
|
18
22
|
actions:
|
19
23
|
create_new_image: Přidat nový obrázek
|
20
24
|
records:
|
@@ -41,3 +45,4 @@ cs:
|
|
41
45
|
blank: Musíte zadat obrázek který chcete nahrát
|
42
46
|
too_big: Maximální velikost obrázku je %{size} MB
|
43
47
|
incorrect_format: 'Obrázek musí být ve formátu JPG, PNG nebo GIF'
|
48
|
+
different_file_name: Nový obrázek nesmí mít jiný název
|
data/config/locales/de.yml
CHANGED
@@ -15,6 +15,10 @@ de:
|
|
15
15
|
replace_image: " mit diesem ersetzen..."
|
16
16
|
current_image: Aktuelles Bild
|
17
17
|
maximum_image_size: Die maximale Größe eines Bildes beträgt %{bytes}.
|
18
|
+
image_title: Titel
|
19
|
+
image_title_help: Zusatzinformationen über das Bild
|
20
|
+
image_alt: Alt-Attribut
|
21
|
+
image_alt_help: Platzhalter-Text, der angezeigt wird, wenn Bild nicht ordenltich dargestellt werden kann.
|
18
22
|
actions:
|
19
23
|
create_new_image: Neues Bild anlegen
|
20
24
|
records:
|
@@ -41,3 +45,4 @@ de:
|
|
41
45
|
blank: Sie müssen ein Bild zum Hochladen angeben
|
42
46
|
too_big: Bild sollte kleiner als %{size} Megabytes sein
|
43
47
|
incorrect_format: 'Ihr Bild sollte ein JPG, PNG oder GIF sein'
|
48
|
+
different_file_name: Neues Bild kann keinen anderen Dateinamen haben
|
data/config/locales/en.yml
CHANGED
@@ -15,6 +15,10 @@ en:
|
|
15
15
|
replace_image: " replace it with this one..."
|
16
16
|
current_image: Current Image
|
17
17
|
maximum_image_size: The maximum image size is %{bytes}.
|
18
|
+
image_title: Title
|
19
|
+
image_title_help: Extra information about the image
|
20
|
+
image_alt: Alt
|
21
|
+
image_alt_help: Text to use if the image cannot be displayed.
|
18
22
|
actions:
|
19
23
|
create_new_image: Add new image
|
20
24
|
records:
|
data/config/locales/fr.yml
CHANGED
@@ -15,6 +15,10 @@ fr:
|
|
15
15
|
replace_image: " la remplacer par celle-ci..."
|
16
16
|
current_image: Image actuelle
|
17
17
|
maximum_image_size: "La taille de l'image ne doit pas excéder %{bytes}."
|
18
|
+
image_title: Titre
|
19
|
+
image_title_help: Information complémentaire sur l'image
|
20
|
+
image_alt: Alt
|
21
|
+
image_alt_help: Texte utilise si l'image ne peut pas être affichée.
|
18
22
|
actions:
|
19
23
|
create_new_image: Ajouter une image
|
20
24
|
records:
|
data/config/locales/it.yml
CHANGED
@@ -24,28 +24,18 @@ it:
|
|
24
24
|
switch_to: 'Passa alla modalità di visualizzazione "%{view_name}"'
|
25
25
|
list: Lista
|
26
26
|
grid: Griglia
|
27
|
-
grid_view:
|
28
|
-
edit: Modifica questa immagine
|
29
27
|
view_live_html: Visualizza questa immagine <br/><em>Apri in una nuova finestra</em>
|
30
28
|
existing_image:
|
31
29
|
button_text: Inserisci
|
32
30
|
resize_image: "Ridimensionare l'immagine?"
|
33
31
|
size: Dimensioni
|
34
|
-
list_view_image:
|
35
|
-
edit_this_image: Modifica questa immagine
|
36
32
|
insert:
|
37
33
|
existing_image: Immagine Esistente
|
38
34
|
new_image: Nuova immagine
|
39
|
-
previous: Precedente
|
40
|
-
next: Successivo
|
41
|
-
submit_insert: Inserire
|
42
|
-
or: o
|
43
|
-
cancel: Annullare
|
44
35
|
activerecord:
|
45
36
|
errors:
|
46
37
|
models:
|
47
|
-
refinery:
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
incorrect_format: "L'immagine deve essere in formato JPEG, PNG o GIF"
|
38
|
+
refinery/image:
|
39
|
+
blank: "Devi selezionare un'immagine da caricare"
|
40
|
+
too_big: 'I files devono essere di dimensioni inferiori a %{size} bytes'
|
41
|
+
incorrect_format: "L'immagine deve essere in formato JPEG, PNG o GIF"
|
data/config/locales/nl.yml
CHANGED
@@ -18,7 +18,7 @@ nl:
|
|
18
18
|
actions:
|
19
19
|
create_new_image: Nieuwe afbeelding toevoegen
|
20
20
|
records:
|
21
|
-
no_images_yet: Er zijn nog geen afbeeldingen. Klik op "Nieuwe afbeelding toevoegen" om uw eerste
|
21
|
+
no_images_yet: Er zijn nog geen afbeeldingen. Klik op "Nieuwe afbeelding toevoegen" om uw eerste afbeelding toe te voegen.
|
22
22
|
index:
|
23
23
|
view:
|
24
24
|
switch_to: De %{view_name}versie bekijken
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Refinery::Core::Engine.routes.draw do
|
2
|
-
get '/system/images/*dragonfly', :to => Dragonfly
|
2
|
+
get '/system/images/*dragonfly', :to => Dragonfly.app(:refinery_images)
|
3
3
|
|
4
4
|
namespace :admin, :path => Refinery::Core.backend_route do
|
5
5
|
resources :images, :except => :show do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class TranslateRefineryImages < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
begin
|
4
|
+
::Refinery::Image.create_translation_table!({
|
5
|
+
image_alt: :string,
|
6
|
+
image_title: :string
|
7
|
+
}, {
|
8
|
+
:migrate_data => true
|
9
|
+
})
|
10
|
+
rescue NameError
|
11
|
+
warn "Refinery::Image was not defined!"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
begin
|
17
|
+
Refinery::Image.drop_translation_table! migrate_data: true
|
18
|
+
rescue NameError
|
19
|
+
warn "Refinery::Image was not defined!"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -34,14 +34,11 @@ Refinery::Images.configure do |config|
|
|
34
34
|
# config.s3_region = ENV['S3_REGION']
|
35
35
|
|
36
36
|
# Configure Dragonfly
|
37
|
-
#
|
38
|
-
|
39
|
-
# config.dragonfly_secret = <%= Refinery::Images.dragonfly_secret.inspect %>
|
40
|
-
# If you decide to trust file extensions replace :ext below with :format
|
37
|
+
# config.dragonfly_verify_urls = <%= Refinery::Images.dragonfly_verify_urls %>
|
38
|
+
config.dragonfly_secret = <%= Refinery::Images.dragonfly_secret.inspect %>
|
41
39
|
# config.dragonfly_url_format = <%= Refinery::Images.dragonfly_url_format.inspect %>
|
42
40
|
# config.dragonfly_url_host = <%= Refinery::Images.dragonfly_url_host.inspect %>
|
43
41
|
# config.datastore_root_path = <%= Refinery::Images.datastore_root_path.inspect %>
|
44
|
-
# config.trust_file_extensions = <%= Refinery::Images.trust_file_extensions.inspect %>
|
45
42
|
|
46
43
|
# Configure Dragonfly custom storage backend
|
47
44
|
# The custom_backend setting by default defers to the core setting for this but can be set just for images.
|
data/lib/refinery/images.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'refinerycms-core'
|
2
2
|
require 'dragonfly'
|
3
|
-
require 'rack/cache'
|
4
3
|
|
5
4
|
module Refinery
|
6
5
|
autoload :ImagesGenerator, 'generators/refinery/images/images_generator'
|
@@ -23,3 +22,7 @@ module Refinery
|
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
25
|
+
|
26
|
+
ActiveSupport.on_load(:active_record) do
|
27
|
+
require 'globalize'
|
28
|
+
end
|
@@ -2,23 +2,21 @@ module Refinery
|
|
2
2
|
module Images
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
-
config_accessor :
|
5
|
+
config_accessor :dragonfly_secret, :dragonfly_url_format, :dragonfly_url_host, :dragonfly_verify_urls,
|
6
6
|
:max_image_size, :pages_per_dialog, :pages_per_admin_index,
|
7
7
|
:pages_per_dialog_that_have_size_options, :user_image_sizes,
|
8
8
|
:image_views, :preferred_image_view, :datastore_root_path,
|
9
9
|
:s3_backend, :s3_bucket_name, :s3_region,
|
10
|
-
:s3_access_key_id, :s3_secret_access_key,
|
10
|
+
:s3_access_key_id, :s3_secret_access_key,
|
11
11
|
:whitelisted_mime_types,
|
12
12
|
:custom_backend_class, :custom_backend_opts
|
13
13
|
|
14
|
-
self.dragonfly_insert_before = 'ActionDispatch::Callbacks'
|
15
14
|
self.dragonfly_secret = Core.dragonfly_secret
|
16
|
-
# If you decide to trust file extensions replace :ext below with :format
|
17
15
|
self.dragonfly_url_format = '/system/images/:job/:basename.:ext'
|
18
16
|
self.dragonfly_url_host = ''
|
19
|
-
self.
|
17
|
+
self.dragonfly_verify_urls = true
|
20
18
|
|
21
|
-
self.max_image_size =
|
19
|
+
self.max_image_size = 5_242_880
|
22
20
|
self.pages_per_dialog = 18
|
23
21
|
self.pages_per_dialog_that_have_size_options = 12
|
24
22
|
self.pages_per_admin_index = 20
|
@@ -5,35 +5,39 @@ module Refinery
|
|
5
5
|
module Dragonfly
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
app_images.define_macro(::Refinery::Image, :image_accessor)
|
8
|
+
def configure!
|
9
|
+
ActiveRecord::Base.extend ::Dragonfly::Model
|
10
|
+
ActiveRecord::Base.extend ::Dragonfly::Model::Validations
|
12
11
|
|
13
|
-
app_images.
|
14
|
-
app_images.analyser.register(::Dragonfly::Analysis::FileCommandAnalyser)
|
15
|
-
end
|
12
|
+
app_images = ::Dragonfly.app(:refinery_images)
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
app_images.configure do
|
15
|
+
plugin :imagemagick
|
16
|
+
datastore :file, {
|
17
|
+
:root_path => Refinery::Images.datastore_root_path
|
18
|
+
}
|
19
|
+
url_format Refinery::Images.dragonfly_url_format
|
20
|
+
url_host Refinery::Images.dragonfly_url_host
|
21
|
+
verify_urls Refinery::Images.dragonfly_verify_urls
|
22
|
+
if Refinery::Images.dragonfly_verify_urls
|
23
|
+
secret Refinery::Images.dragonfly_secret
|
24
|
+
end
|
25
|
+
dragonfly_url nil
|
26
|
+
processor :strip do |content|
|
27
|
+
content.process!(:convert, '-strip')
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
if ::Refinery::Images.s3_backend
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
require 'dragonfly/s3_data_store'
|
33
|
+
options = {
|
34
|
+
bucket_name: Refinery::Images.s3_bucket_name,
|
35
|
+
access_key_id: Refinery::Images.s3_access_key_id,
|
36
|
+
secret_access_key: Refinery::Images.s3_secret_access_key
|
37
|
+
}
|
38
|
+
# S3 Region otherwise defaults to 'us-east-1'
|
39
|
+
options.update(region: Refinery::Images.s3_region) if Refinery::Images.s3_region
|
40
|
+
app_images.use_datastore :s3, options
|
37
41
|
end
|
38
42
|
|
39
43
|
if Images.custom_backend?
|
@@ -44,10 +48,17 @@ module Refinery
|
|
44
48
|
##
|
45
49
|
# Injects Dragonfly::Middleware for Refinery::Images into the stack
|
46
50
|
def attach!(app)
|
47
|
-
if ::
|
48
|
-
app.config.
|
51
|
+
if defined?(::Rack::Cache)
|
52
|
+
unless app.config.action_controller.perform_caching && app.config.action_dispatch.rack_cache
|
53
|
+
app.config.middleware.insert 0, ::Rack::Cache, {
|
54
|
+
verbose: true,
|
55
|
+
metastore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
|
56
|
+
entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
|
57
|
+
}
|
58
|
+
end
|
59
|
+
app.config.middleware.insert_after ::Rack::Cache, ::Dragonfly::Middleware, :refinery_images
|
49
60
|
else
|
50
|
-
app.config.middleware.use
|
61
|
+
app.config.middleware.use ::Dragonfly::Middleware, :refinery_images
|
51
62
|
end
|
52
63
|
end
|
53
64
|
end
|