udongo 5.7.0 → 5.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/backend/content/rows/pictures_controller.rb +51 -0
- data/app/decorators/content_image_decorator.rb +0 -4
- data/app/decorators/content_picture_decorator.rb +3 -0
- data/app/decorators/content_text_decorator.rb +0 -4
- data/app/helpers/backend/dropdown_helper.rb +6 -0
- data/app/models/asset.rb +2 -1
- data/app/models/concerns/content_type.rb +4 -0
- data/app/models/concerns/searchable.rb +1 -1
- data/app/models/content_picture.rb +9 -0
- data/app/views/backend/content/_image.html.erb +1 -1
- data/app/views/backend/content/_picture.html.erb +13 -0
- data/app/views/backend/content/rows/columns/_dimension_fields.html.erb +9 -1
- data/app/views/backend/content/rows/pictures/_filter.html.erb +10 -0
- data/app/views/backend/content/rows/pictures/edit.html.erb +17 -0
- data/app/views/backend/content/rows/pictures/link_or_upload.html.erb +34 -0
- data/changelog.md +13 -0
- data/config/locales/en_backend.yml +4 -1
- data/config/locales/en_forms.yml +1 -0
- data/config/locales/nl_backend.yml +4 -1
- data/config/locales/nl_forms.yml +1 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20170412074304_create_content_pictures.rb +11 -0
- data/lib/udongo/configs/flexible_content.rb +1 -1
- data/lib/udongo/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/factories/content_pictures.rb +5 -0
- data/spec/support/concerns/content_type.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e012e2dccbe75d74ea00c84ab30ae20423be0be1
|
4
|
+
data.tar.gz: b7b476f535941b05b5b7d857f15819af1c5f2753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e04b226920a07f783df0bd889920bc137905ce349df750acd05f9b056462cf55addd1f357e6b966cb200a0b65cb6fe585a40a4d398572a751bd94d1be7e047
|
7
|
+
data.tar.gz: 90bed388b48beb7a0e1a19b44209558cfc01928b112490064f251dfade8204bbd2065995f6c612d96bf9c9a9362c9f7fd40204c5011e33df480a76df022ffaaa
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Backend::Content::Rows::PicturesController < Backend::BaseController
|
2
|
+
include Concerns::Backend::ContentTypeController
|
3
|
+
before_action :redirect_unless_has_asset, only: [:edit, :update]
|
4
|
+
before_action :redirect_if_has_asset, only: [:link_or_upload, :link, :upload]
|
5
|
+
before_action :prepare_upload, only: [:link_or_upload, :upload]
|
6
|
+
|
7
|
+
model ContentPicture
|
8
|
+
allowed_params :caption, :url
|
9
|
+
|
10
|
+
def link
|
11
|
+
@model.asset = Asset.find params[:asset_id]
|
12
|
+
@model.save!
|
13
|
+
|
14
|
+
redirect_to edit_backend_content_picture_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def upload
|
18
|
+
@asset.filename = params[:asset][:filename]
|
19
|
+
@asset.description = params[:asset][:description]
|
20
|
+
|
21
|
+
if @asset.filename && @asset.filename.content_type.to_s.include?('image') && @asset.save
|
22
|
+
@model.asset = @asset
|
23
|
+
@model.save
|
24
|
+
|
25
|
+
redirect_to edit_backend_content_picture_path(@model)
|
26
|
+
else
|
27
|
+
@asset.errors.add :filename, t('b.msg.please_select_a_valid_image')
|
28
|
+
render :link_or_upload
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def redirect_unless_has_asset
|
35
|
+
unless @model.asset
|
36
|
+
redirect_to link_or_upload_backend_content_picture_path(@model)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def redirect_if_has_asset
|
41
|
+
if @model.asset
|
42
|
+
redirect_to edit_backend_content_picture_path(@model)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_upload
|
47
|
+
@asset = Asset.new
|
48
|
+
@search = Asset.ransack params[:q]
|
49
|
+
@assets = @search.result(distinct: true).image.where.not(id: @model.asset_id).order('id DESC')
|
50
|
+
end
|
51
|
+
end
|
data/app/models/asset.rb
CHANGED
@@ -4,6 +4,7 @@ class Asset < ApplicationRecord
|
|
4
4
|
mount_uploader :filename, AssetUploader
|
5
5
|
|
6
6
|
has_many :images, dependent: :destroy
|
7
|
+
has_many :content_pictures, dependent: :destroy
|
7
8
|
|
8
9
|
scope :image, -> { where(content_type: %w(image/gif image/jpeg image/png)) }
|
9
10
|
|
@@ -24,7 +25,7 @@ class Asset < ApplicationRecord
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def deletable?
|
27
|
-
images.empty?
|
28
|
+
images.empty? && content_pictures.empty?
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% if object.present? && object.asset.present? %>
|
2
|
+
|
3
|
+
<%= image_tag object.asset.image.url(1100, 1100, quality: 65), alt: '', class: 'img-fluid' %>
|
4
|
+
|
5
|
+
<% if object.caption.present? %>
|
6
|
+
<div class="text-xs-center">
|
7
|
+
<%= object.caption.html_safe %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% else %>
|
12
|
+
<%= t 'b.msg.flexible_content.no_picture_present' %>
|
13
|
+
<% end %>
|
@@ -1,3 +1,11 @@
|
|
1
1
|
<% Udongo::Configs::FlexibleContent::BREAKPOINTS.each do |bp| %>
|
2
|
-
<%=
|
2
|
+
<%=
|
3
|
+
form.input(
|
4
|
+
"width_#{bp}",
|
5
|
+
as: :select,
|
6
|
+
collection: options_for_column_widths,
|
7
|
+
include_blank: false,
|
8
|
+
wrapper_html: { hidden: !Udongo.config.flexible_content.allowed_breakpoint?(bp) }
|
9
|
+
)
|
10
|
+
%>
|
3
11
|
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= search_form_for @search, url: link_or_upload_backend_content_picture_path(@model) do |f| %>
|
2
|
+
<div class="row m-b-2">
|
3
|
+
<div class="col-md-6">
|
4
|
+
<%= f.search_field :description_cont, placeholder: t('b.description'), class: 'form-control' %>
|
5
|
+
</div>
|
6
|
+
<div class="col-md-6">
|
7
|
+
<%= f.submit class: 'btn btn-sn' %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= render 'backend/general_form_error', object: @model %>
|
2
|
+
|
3
|
+
<div class="card">
|
4
|
+
<div class="card-header">
|
5
|
+
<%= t 'b.msg.flexible_content.edit_picture' %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="card-block">
|
9
|
+
<%= image_tag @model.asset.image.url(1700, 1700, quality: 65), alt: '', class: 'img-fluid' %>
|
10
|
+
|
11
|
+
<%= simple_form_for [:backend, @model] do |f| %>
|
12
|
+
<%= f.input :url, as: :string %>
|
13
|
+
<%= f.input :caption, as: :text %>
|
14
|
+
<%= render 'backend/form_actions', cancel_url: content_path %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%= simple_form_for @asset, url: upload_backend_content_picture_path(@model) do |f| %>
|
2
|
+
<div class="card">
|
3
|
+
<div class="card-header">
|
4
|
+
<%= t 'b.upload_a_new_image' %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="card-block">
|
8
|
+
<%= f.input :filename, as: :file, label: false, required: false %>
|
9
|
+
<%= f.input :description, as: :text, required: false %>
|
10
|
+
|
11
|
+
<%= render 'backend/form_actions', cancel_url: content_path %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<div class="card">
|
17
|
+
<div class="card-header">
|
18
|
+
<%= t 'b.choose_an_existing_image' %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="card-block">
|
22
|
+
<%= render 'filter' %>
|
23
|
+
|
24
|
+
<div class="row">
|
25
|
+
<% @assets.each do |a| %>
|
26
|
+
<div class="col-sm-6 col-md-4 col-lg-3 col-xl-2">
|
27
|
+
<%= link_to link_backend_content_picture_path(@model, asset_id: a.id), style: '' do %>
|
28
|
+
<%= image_tag a.image.url(550, 550, action: :resize_and_pad, background: :white), alt: '', class: 'img-fluid' %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
data/changelog.md
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
+
5.8.0 - 2017-04-12
|
2
|
+
--
|
3
|
+
* Add missing ```author``` key to form translations.
|
4
|
+
* The ContentImage/Text decorators have been simplified.
|
5
|
+
* Fixed bug where you couldn't include ```Concerns::Searchable``` on models
|
6
|
+
without flexible content without getting an unknown method error.
|
7
|
+
* The column widths for flexible content are displayed in percentages.
|
8
|
+
* An extra widget ```ContentPicture``` has been added. This is the replacement
|
9
|
+
for the ````ContentImage```` which has now been deprecated.
|
10
|
+
|
11
|
+
|
1
12
|
5.7.0 - 2017-03-22
|
2
13
|
--
|
3
14
|
* The ```Navigation``` model now includes the cacheable concern.
|
4
15
|
* A ```NavigationHelper``` module was added which makes it easier to fetch a
|
5
16
|
navigation by identifier.
|
17
|
+
* You can now include ```Concerns::Searchable``` on models without flexible
|
18
|
+
content and not receive errors as a result.
|
6
19
|
|
7
20
|
|
8
21
|
5.6.0 - 2017-03-18
|
@@ -98,7 +98,8 @@ en:
|
|
98
98
|
changes_saved: The changes have been saved.
|
99
99
|
confirm: Are you sure?
|
100
100
|
content_types:
|
101
|
-
image: Image
|
101
|
+
image: Image (deprecated!)
|
102
|
+
picture: Picture
|
102
103
|
text: Text
|
103
104
|
deleted: '%{actor} was deleted.'
|
104
105
|
dirty_inputs_warning: "You are about to leave the page but your changes aren't saved yet.\nDo you still want to leave the page?"
|
@@ -110,8 +111,10 @@ en:
|
|
110
111
|
delete_row: Delete row
|
111
112
|
edit_column: Edit column
|
112
113
|
edit_image: Edit image
|
114
|
+
edit_picture: Edit picture
|
113
115
|
edit_text: Edit text
|
114
116
|
explanation: With this module you can create flexible responsive content. Click the button below to create the first row.
|
117
|
+
no_picture_present: No picture has been uploaded/linked yet.
|
115
118
|
forgot_password: Forgot password?
|
116
119
|
general_form_error: Something went wrong. Please check the marked fields.
|
117
120
|
help_texts:
|
data/config/locales/en_forms.yml
CHANGED
@@ -98,7 +98,8 @@ nl:
|
|
98
98
|
changes_saved: De wijzigingen werden opgeslagen.
|
99
99
|
confirm: Ben je zeker?
|
100
100
|
content_types:
|
101
|
-
image: Afbeelding
|
101
|
+
image: Afbeelding (niet meer gebruiken!)
|
102
|
+
picture: Foto
|
102
103
|
text: Tekst
|
103
104
|
deleted: '%{actor} werd verwijderd.'
|
104
105
|
dirty_inputs_warning: "Je gaat de pagina verlaten maar je aanpassingen zijn nog niet bewaard.\nWil je nog steeds de pagina verlaten?"
|
@@ -110,8 +111,10 @@ nl:
|
|
110
111
|
delete_row: Rij verwijderen
|
111
112
|
edit_column: Kolom bewerken
|
112
113
|
edit_image: Afbeelding bewerken
|
114
|
+
edit_picture: Foto bewerken
|
113
115
|
edit_text: Tekst bewerken
|
114
116
|
explanation: Met deze module kan je flexibele, responsive inhoud toevoegen. Klik op onderstaande knop om een eerste rij toe te voegen.
|
117
|
+
no_picture_present: Er werd nog geen foto geüpload of gelinkt.
|
115
118
|
forgot_password: Wachtwoord vergeten?
|
116
119
|
general_form_error: Er trad een fout op. Controleer de gemarkeerde velden.
|
117
120
|
help_texts:
|
data/config/locales/nl_forms.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -83,8 +83,16 @@ Rails.application.routes.draw do
|
|
83
83
|
|
84
84
|
scope module: 'rows' do
|
85
85
|
Udongo.config.flexible_content.types.each do |content_type|
|
86
|
+
next if content_type == 'picture'
|
86
87
|
resources content_type.to_s.pluralize.to_sym, only: [:edit, :update]
|
87
88
|
end
|
89
|
+
|
90
|
+
resources :pictures, only: [:edit, :update] do
|
91
|
+
member do
|
92
|
+
get :link_or_upload, :link
|
93
|
+
post :upload
|
94
|
+
end
|
95
|
+
end
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
data/lib/udongo/version.rb
CHANGED
data/readme.md
CHANGED
@@ -116,7 +116,7 @@ You can also override the default message with your own:
|
|
116
116
|
## Flexible content
|
117
117
|
### types
|
118
118
|
```ruby
|
119
|
-
Udongo.config.flexible_content.types = %w(text
|
119
|
+
Udongo.config.flexible_content.types = %w(text picture)
|
120
120
|
```
|
121
121
|
|
122
122
|
### allowed_breakpoints
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: udongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davy Hellemans
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -460,6 +460,7 @@ files:
|
|
460
460
|
- app/controllers/backend/base_controller.rb
|
461
461
|
- app/controllers/backend/content/rows/columns_controller.rb
|
462
462
|
- app/controllers/backend/content/rows/images_controller.rb
|
463
|
+
- app/controllers/backend/content/rows/pictures_controller.rb
|
463
464
|
- app/controllers/backend/content/rows/texts_controller.rb
|
464
465
|
- app/controllers/backend/content/rows_controller.rb
|
465
466
|
- app/controllers/backend/dashboard_controller.rb
|
@@ -486,6 +487,7 @@ files:
|
|
486
487
|
- app/controllers/redirects_controller.rb
|
487
488
|
- app/decorators/application_decorator.rb
|
488
489
|
- app/decorators/content_image_decorator.rb
|
490
|
+
- app/decorators/content_picture_decorator.rb
|
489
491
|
- app/decorators/content_row_decorator.rb
|
490
492
|
- app/decorators/content_text_decorator.rb
|
491
493
|
- app/decorators/navigation_item_decorator.rb
|
@@ -549,6 +551,7 @@ files:
|
|
549
551
|
- app/models/concerns/visible.rb
|
550
552
|
- app/models/content_column.rb
|
551
553
|
- app/models/content_image.rb
|
554
|
+
- app/models/content_picture.rb
|
552
555
|
- app/models/content_row.rb
|
553
556
|
- app/models/content_text.rb
|
554
557
|
- app/models/email.rb
|
@@ -602,12 +605,16 @@ files:
|
|
602
605
|
- app/views/backend/assets/index.html.erb
|
603
606
|
- app/views/backend/assets/new.html.erb
|
604
607
|
- app/views/backend/content/_image.html.erb
|
608
|
+
- app/views/backend/content/_picture.html.erb
|
605
609
|
- app/views/backend/content/_rows.html.erb
|
606
610
|
- app/views/backend/content/_text.html.erb
|
607
611
|
- app/views/backend/content/rows/columns/_dimension_fields.html.erb
|
608
612
|
- app/views/backend/content/rows/columns/edit.html.erb
|
609
613
|
- app/views/backend/content/rows/columns/new.html.erb
|
610
614
|
- app/views/backend/content/rows/images/edit.html.erb
|
615
|
+
- app/views/backend/content/rows/pictures/_filter.html.erb
|
616
|
+
- app/views/backend/content/rows/pictures/edit.html.erb
|
617
|
+
- app/views/backend/content/rows/pictures/link_or_upload.html.erb
|
611
618
|
- app/views/backend/content/rows/texts/edit.html.erb
|
612
619
|
- app/views/backend/dashboard/show.html.erb
|
613
620
|
- app/views/backend/email_templates/_form.html.erb
|
@@ -756,6 +763,7 @@ files:
|
|
756
763
|
- db/migrate/20170228183831_create_images.rb
|
757
764
|
- db/migrate/20170305125627_create_articles.rb
|
758
765
|
- db/migrate/20170318184654_add_title_and_content_disabled_to_snippet.rb
|
766
|
+
- db/migrate/20170412074304_create_content_pictures.rb
|
759
767
|
- lib/tasks/task_extras.rb
|
760
768
|
- lib/tasks/udongo_tasks.rake
|
761
769
|
- lib/udongo.rb
|
@@ -808,6 +816,7 @@ files:
|
|
808
816
|
- spec/factories/comments.rb
|
809
817
|
- spec/factories/content_columns.rb
|
810
818
|
- spec/factories/content_images.rb
|
819
|
+
- spec/factories/content_pictures.rb
|
811
820
|
- spec/factories/content_rows.rb
|
812
821
|
- spec/factories/content_texts.rb
|
813
822
|
- spec/factories/email_templates.rb
|