ecm_pictures2 2.1.4 → 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/ecm/pictures/galleries_controller.rb +13 -0
- data/app/controllers/ecm/pictures/pictures_controller.rb +2 -2
- data/app/helpers/ecm/pictures_helper.rb +3 -3
- data/app/models/ecm/pictures/attached_picture.rb +2 -7
- data/app/models/ecm/pictures/gallery.rb +63 -0
- data/app/models/ecm/pictures/picture.rb +3 -12
- data/app/views/ecm/pictures/galleries/_gallery.html.erb +17 -0
- data/app/views/ecm/pictures/galleries/_gallery_for_index.html.erb +19 -0
- data/app/views/ecm/pictures/{picture_galleries → galleries}/index.html.erb +5 -5
- data/app/views/ecm/pictures/galleries/show.html.erb +10 -0
- data/app/views/ecm/pictures/pictures/show.html.erb +1 -1
- data/config/locales/ecm.pictures.de.yml +1 -1
- data/config/locales/ecm.pictures.en.yml +1 -1
- data/config/locales/{ecm.pictures.picture_gallery.de.yml → ecm.pictures.gallery.de.yml} +3 -3
- data/config/locales/{ecm.pictures.picture_gallery.en.yml → ecm.pictures.gallery.en.yml} +3 -3
- data/config/locales/ecm.pictures.picture.de.yml +1 -1
- data/config/locales/ecm.pictures.picture.en.yml +1 -1
- data/db/migrate/20160626141629_rename_ecm_pictures_picture_galleries_to_ecm_pictures_galleries.rb +5 -0
- data/db/migrate/20160626143414_rename_ecm_pictures_pictures_picture_gallery_id_to_gallery_id.rb +5 -0
- data/lib/ecm/pictures/configuration.rb +1 -1
- data/lib/ecm/pictures/engine.rb +0 -5
- data/lib/ecm/pictures/routing.rb +4 -4
- data/lib/ecm/pictures/version.rb +1 -1
- data/lib/ecm_pictures2.rb +4 -2
- data/lib/generators/ecm/pictures/install/install_generator.rb +1 -1
- data/lib/generators/ecm/pictures/install/templates/initializer.rb +3 -3
- data/spec/factories/ecm/pictures/galleries.rb +12 -0
- metadata +13 -16
- data/app/admin/ecm_pictures_attached_pictures.rb +0 -13
- data/app/admin/ecm_pictures_picture_galleries.rb +0 -110
- data/app/admin/ecm_pictures_pictures.rb +0 -97
- data/app/controllers/ecm/pictures/picture_galleries_controller.rb +0 -11
- data/app/models/ecm/pictures/picture_gallery.rb +0 -67
- data/app/views/ecm/pictures/picture_galleries/_picture_gallery.html.erb +0 -17
- data/app/views/ecm/pictures/picture_galleries/_picture_gallery_for_index.html.erb +0 -19
- data/app/views/ecm/pictures/picture_galleries/show.html.erb +0 -10
- data/lib/ecm/pictures/active_admin/pictureable_helper.rb +0 -56
- data/lib/generators/ecm/pictures/locales/locales_generator.rb +0 -25
- data/spec/factories/ecm/pictures/picture_galleries.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6faa3c66c58148faeb8544a0493f52b051316cd
|
4
|
+
data.tar.gz: 6de55d5a9f51260afd98c1f3ca28639d11a44bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3152f8db2a49f71344e136b34578841d39510be81085b5ecacb631777f88135bd133bbfffe78747322bbecea39728c8ae39635ee4080a539365bbebf6777a902
|
7
|
+
data.tar.gz: b188cf433da3d05b2235f1bacdfe4d824f5273404affd9d3c669f372d7ca971912a4ca20f6de04a4dcf4c83136d0d5a812bb0104506a4dd4bf785567067d4ca0
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Ecm::Pictures
|
2
2
|
class PicturesController < Ecm::Pictures::Configuration.base_controller.constantize
|
3
3
|
def index
|
4
|
-
@pictures =
|
4
|
+
@pictures = Picture.all
|
5
5
|
end
|
6
6
|
|
7
7
|
def show
|
8
|
-
@picture =
|
8
|
+
@picture = Picture.find(params[:id])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -10,7 +10,7 @@ module Ecm::PicturesHelper
|
|
10
10
|
def render_picture_gallery(name, options = {})
|
11
11
|
options = { preview_style: :thumb }.merge(options)
|
12
12
|
|
13
|
-
gallery = Ecm::Pictures::
|
13
|
+
gallery = Ecm::Pictures::Gallery.where(name: name.to_s).first
|
14
14
|
gallery_identifier = begin
|
15
15
|
gallery.to_param
|
16
16
|
rescue
|
@@ -18,8 +18,8 @@ module Ecm::PicturesHelper
|
|
18
18
|
end
|
19
19
|
|
20
20
|
if gallery.nil?
|
21
|
-
content_tag(:div, class: 'warning missing
|
22
|
-
content_tag(:p, I18n.t('ecm.pictures.
|
21
|
+
content_tag(:div, class: 'warning missing gallery') do
|
22
|
+
content_tag(:p, I18n.t('ecm.pictures.gallery.warnings.missing', name: name.to_s))
|
23
23
|
end
|
24
24
|
else
|
25
25
|
render gallery
|
@@ -1,15 +1,10 @@
|
|
1
1
|
module Ecm::Pictures
|
2
2
|
class AttachedPicture < ActiveRecord::Base
|
3
|
-
self.table_name = 'ecm_pictures_attached_pictures'
|
4
|
-
|
5
3
|
# associations
|
6
4
|
belongs_to :picture, foreign_key: 'ecm_pictures_picture_id'
|
7
5
|
belongs_to :pictureable, polymorphic: true
|
8
6
|
|
9
|
-
# attributes
|
10
|
-
attr_accessible :ecm_pictures_picture_id if respond_to?(:attr_accessible)
|
11
|
-
|
12
7
|
# validations
|
13
8
|
validates :picture, :pictureable, presence: true
|
14
|
-
end
|
15
|
-
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Pictures
|
3
|
+
class Gallery < ActiveRecord::Base
|
4
|
+
# associations
|
5
|
+
has_many :pictures, -> { order :position },
|
6
|
+
dependent: :destroy
|
7
|
+
|
8
|
+
# attributes
|
9
|
+
accepts_nested_attributes_for :pictures, allow_destroy: true
|
10
|
+
|
11
|
+
# acts as list
|
12
|
+
acts_as_list
|
13
|
+
default_scope { order(:position) }
|
14
|
+
|
15
|
+
# acts as markup
|
16
|
+
acts_as_markup language: :variable, columns: [:description]
|
17
|
+
|
18
|
+
# callbacks
|
19
|
+
after_initialize :set_defaults
|
20
|
+
|
21
|
+
# friendly id
|
22
|
+
extend FriendlyId
|
23
|
+
friendly_id :name, use: [:slugged, :finders]
|
24
|
+
|
25
|
+
# tagging
|
26
|
+
acts_as_taggable if respond_to?(:acts_as_taggable)
|
27
|
+
|
28
|
+
# validations
|
29
|
+
validates :markup_language, presence: true,
|
30
|
+
inclusion: Ecm::Pictures::Configuration.markup_languages
|
31
|
+
validates :name, presence: true,
|
32
|
+
uniqueness: true
|
33
|
+
|
34
|
+
def display_code_for_erb
|
35
|
+
"<%= render_picture_gallery '#{name}' %>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def picture_images=(picture_images)
|
39
|
+
picture_images.each do |image|
|
40
|
+
next if image.respond_to?(:empty?) && image.empty?
|
41
|
+
pictures.build(image: image)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
name
|
47
|
+
end
|
48
|
+
|
49
|
+
def human
|
50
|
+
name
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def set_defaults
|
56
|
+
if self.new_record?
|
57
|
+
self.link_images = true if link_images.nil?
|
58
|
+
self.markup_language ||= Ecm::Pictures::Configuration.default_markup_language
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
class Ecm::Pictures::Picture < ActiveRecord::Base
|
2
|
-
self.table_name = 'ecm_pictures_pictures'
|
3
|
-
|
4
2
|
# associations
|
5
|
-
belongs_to :
|
3
|
+
belongs_to :gallery, counter_cache: true
|
6
4
|
has_many :attached_pictures, foreign_key: 'ecm_pictures_picture_id'
|
7
|
-
# attributes
|
8
|
-
attr_accessible :description,
|
9
|
-
:image,
|
10
|
-
:markup_language,
|
11
|
-
:name,
|
12
|
-
:picture_gallery_id,
|
13
|
-
:position if respond_to?(:attr_accessible)
|
14
5
|
|
15
6
|
# acts as list
|
16
|
-
acts_as_list scope: :
|
7
|
+
acts_as_list scope: :gallery
|
17
8
|
|
18
9
|
# acts as markup
|
19
10
|
acts_as_markup language: :variable, columns: [:description, :description]
|
@@ -23,7 +14,7 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
|
|
23
14
|
before_validation :set_name_from_image_file_name, if: proc { |p| (p.name.nil? || p.name.empty?) }
|
24
15
|
|
25
16
|
# default scope
|
26
|
-
default_scope { order(:
|
17
|
+
default_scope { order(:gallery_id, :position) }
|
27
18
|
# friendly id
|
28
19
|
extend FriendlyId
|
29
20
|
friendly_id :name, use: [:slugged, :finders]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= Ecm::Pictures::Configuration.prevent_textile_rendering_in_html ? '<notextile>'.html_safe : '' %>
|
2
|
+
<div class="gallery-description">
|
3
|
+
<%= mu gallery, :description %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<% if gallery.respond_to?(:tag_list) %>
|
7
|
+
<div class="tags bottom-margin-1">
|
8
|
+
<% gallery.tag_list.each do |tag| %>
|
9
|
+
<span class="label label-default"><%= tag %></span>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="gallery-pictures row" data-target="#modal-gallery" data-toggle="modal-gallery">
|
15
|
+
<%= render gallery.pictures %>
|
16
|
+
</div>
|
17
|
+
<%= Ecm::Pictures::Configuration.prevent_textile_rendering_in_html ? '</notextile>'.html_safe : '' %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div class="col-sm-6 col-md-3">
|
2
|
+
<div class="thumbnail">
|
3
|
+
<% if gallery.pictures.first.respond_to?(:image) %>
|
4
|
+
<%= image_tag gallery.pictures.first.image.url(:default_thumb) %>
|
5
|
+
<% end %>
|
6
|
+
<div class="caption">
|
7
|
+
<h4><%= gallery.name %></h4>
|
8
|
+
<% if gallery.respond_to?(:tag_list) %>
|
9
|
+
<div class="tags bottom-margin-1">
|
10
|
+
<% gallery.tag_list.each do |tag| %>
|
11
|
+
<span class="label label-default"><%= tag %></span>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
<div class="truncate lines-3 bottom-margin-1"><%= mu(gallery, :description) %></div>
|
16
|
+
<p><%= link_to t('ecm.pictures.actions.view'), gallery, :class => 'btn btn-primary', :role => 'button' %></p>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<h1><%= Ecm::Pictures::
|
1
|
+
<h1><%= Ecm::Pictures::Gallery.model_name.human(:count => :other) %></h1>
|
2
2
|
|
3
|
-
<% case Ecm::Pictures::Configuration.
|
3
|
+
<% case Ecm::Pictures::Configuration.render_gallery_index_as %>
|
4
4
|
<% when :thumbnail %>
|
5
5
|
<div class="row">
|
6
|
-
<% @
|
7
|
-
<%= render :partial => 'ecm/pictures/
|
6
|
+
<% @galleries.each do |g| %>
|
7
|
+
<%= render :partial => 'ecm/pictures/galleries/gallery_for_index', :locals => { :gallery => g } %>
|
8
8
|
<% end %>
|
9
9
|
</div>
|
10
10
|
<% when :media_object %>
|
11
|
-
<%= render_collection(@
|
11
|
+
<%= render_collection(@galleries, Ecm::Pictures::Gallery, as: :bootstrap_media_object) do |list| %>
|
12
12
|
<h4><%= list.resource.name %>
|
13
13
|
<% if list.resource.respond_to?(:tag_list) %>
|
14
14
|
<span class="tags">
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1><%= @gallery.to_s %></h1>
|
2
|
+
|
3
|
+
<%= render @gallery %>
|
4
|
+
|
5
|
+
<div class="page-actions well">
|
6
|
+
<div class="btn-group" role="group">
|
7
|
+
<%= link_to Ecm::Pictures::Gallery.model_name.human(:count => :other), ecm_pictures_galleries_path, :class => 'btn btn-primary' %>
|
8
|
+
<%= link_to t('ecm.pictures.views.actions.back'), :back, class: 'btn btn-default' %>
|
9
|
+
</div>
|
10
|
+
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
<div class="page-actions well">
|
8
8
|
<div class="btn-group" role="group">
|
9
|
-
<%= link_to(@picture.
|
9
|
+
<%= link_to(@picture.gallery, @picture.gallery, :class => 'btn btn-primary') if @picture.gallery.present? %>
|
10
10
|
<%= link_to t('ecm.pictures.views.actions.back'), :back, class: 'btn btn-default' %>
|
11
11
|
</div>
|
12
12
|
</div>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
de:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
ecm/pictures/
|
4
|
+
ecm/pictures/gallery:
|
5
5
|
one: Bildgalerie
|
6
6
|
other: Bildgalerien
|
7
7
|
attributes:
|
8
|
-
ecm/pictures/
|
8
|
+
ecm/pictures/gallery:
|
9
9
|
created_at: Erstellt am
|
10
10
|
description: Beschreibung
|
11
11
|
display_code_for_erb: Anzeigecode (erb)
|
@@ -17,5 +17,5 @@ de:
|
|
17
17
|
position: Position
|
18
18
|
updated_at: Aktualisiert am
|
19
19
|
routes:
|
20
|
-
|
20
|
+
ecm_pictures_galleries: bildgalerien
|
21
21
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
en:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
ecm/pictures/
|
4
|
+
ecm/pictures/gallery:
|
5
5
|
one: picture gallery
|
6
6
|
other: picture galleries
|
7
7
|
attributes:
|
8
|
-
ecm/pictures/
|
8
|
+
ecm/pictures/gallery:
|
9
9
|
created_at: created at
|
10
10
|
description: description
|
11
11
|
display_code_for_erb: display code (erb)
|
@@ -17,5 +17,5 @@ en:
|
|
17
17
|
position: position
|
18
18
|
updated_at: updated at
|
19
19
|
routes:
|
20
|
-
|
20
|
+
ecm_pictures_galleries: picture-galleries
|
21
21
|
|
data/lib/ecm/pictures/engine.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
module Ecm
|
2
2
|
module Pictures
|
3
3
|
class Engine < Rails::Engine
|
4
|
-
initializer :ecm_pictures_engine do
|
5
|
-
::ActiveAdmin.setup do |config|
|
6
|
-
config.load_paths << File.join(root, 'app', 'admin')
|
7
|
-
end
|
8
|
-
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
9
4
|
end
|
10
5
|
end
|
11
6
|
end
|
data/lib/ecm/pictures/routing.rb
CHANGED
@@ -4,16 +4,16 @@ module Ecm
|
|
4
4
|
# Creates the routes for pictures and galleries. You can pass options to
|
5
5
|
# specify the actions for both pictures and/or galleries.
|
6
6
|
#
|
7
|
-
# Ecm::Pictures::Routing.routes(self, { :
|
7
|
+
# Ecm::Pictures::Routing.routes(self, { :gallery_actions => [ :show ]})
|
8
8
|
#
|
9
|
-
# This will only create the show action for
|
9
|
+
# This will only create the show action for galleries, but omit the index action.
|
10
10
|
def self.routes(router, options = {})
|
11
11
|
options.reverse_merge!(
|
12
|
-
|
12
|
+
gallery_actions: [:index, :show],
|
13
13
|
picture_actions: [:index, :show]
|
14
14
|
)
|
15
15
|
|
16
|
-
router.resources :
|
16
|
+
router.resources :ecm_pictures_galleries, only: options[:gallery_actions], controller: 'ecm/pictures/galleries'
|
17
17
|
router.resources :ecm_pictures_pictures, only: options[:picture_actions], controller: 'ecm/pictures/pictures'
|
18
18
|
end
|
19
19
|
end
|
data/lib/ecm/pictures/version.rb
CHANGED
data/lib/ecm_pictures2.rb
CHANGED
@@ -2,16 +2,18 @@ require 'acts_as_list'
|
|
2
2
|
require 'acts_as_markup'
|
3
3
|
require 'friendly_id'
|
4
4
|
require 'paperclip'
|
5
|
-
require 'active_admin-acts_as_list' if Gem::Specification.find_all_by_name('activeadmin').any?
|
6
5
|
|
7
6
|
require 'ecm/pictures/engine'
|
8
7
|
require 'ecm/pictures/configuration'
|
9
8
|
require 'ecm/pictures/routing'
|
10
9
|
require 'ecm/pictures/version'
|
11
|
-
require 'ecm/pictures/active_admin/pictureable_helper' if Gem::Specification.find_all_by_name('activeadmin').any?
|
12
10
|
|
13
11
|
module Ecm
|
14
12
|
module Pictures
|
15
13
|
extend Configuration
|
14
|
+
|
15
|
+
def self.table_name_prefix
|
16
|
+
'ecm_pictures_'
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -38,10 +38,10 @@ Ecm::Pictures.configure do |config|
|
|
38
38
|
#
|
39
39
|
config.prevent_textile_rendering_in_html = true
|
40
40
|
|
41
|
-
# Render
|
41
|
+
# Render galleries in the index view as :thumbnail
|
42
42
|
# or :media_object.
|
43
43
|
#
|
44
|
-
# Default: config.
|
44
|
+
# Default: config.render_gallery_index_as = :media_object
|
45
45
|
#
|
46
|
-
config.
|
46
|
+
config.render_gallery_index_as = :media_object
|
47
47
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :ecm_pictures_gallery, class: Ecm::Pictures::Gallery do
|
3
|
+
sequence(:name) { |n| "Gallery ##{n}" }
|
4
|
+
|
5
|
+
trait :with_pictures do |gallery|
|
6
|
+
3.times do
|
7
|
+
gallery.after(:create) { |g| FactoryGirl.create(:ecm_pictures_picture, gallery: g) }
|
8
|
+
end
|
9
|
+
gallery.pictures_count 3
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecm_pictures2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -384,20 +384,17 @@ files:
|
|
384
384
|
- MIT-LICENSE
|
385
385
|
- README.rdoc
|
386
386
|
- Rakefile
|
387
|
-
- app/
|
388
|
-
- app/admin/ecm_pictures_picture_galleries.rb
|
389
|
-
- app/admin/ecm_pictures_pictures.rb
|
390
|
-
- app/controllers/ecm/pictures/picture_galleries_controller.rb
|
387
|
+
- app/controllers/ecm/pictures/galleries_controller.rb
|
391
388
|
- app/controllers/ecm/pictures/pictures_controller.rb
|
392
389
|
- app/helpers/ecm/pictures_helper.rb
|
393
390
|
- app/helpers/markup_helper.rb
|
394
391
|
- app/models/ecm/pictures/attached_picture.rb
|
392
|
+
- app/models/ecm/pictures/gallery.rb
|
395
393
|
- app/models/ecm/pictures/picture.rb
|
396
|
-
- app/
|
397
|
-
- app/views/ecm/pictures/
|
398
|
-
- app/views/ecm/pictures/
|
399
|
-
- app/views/ecm/pictures/
|
400
|
-
- app/views/ecm/pictures/picture_galleries/show.html.erb
|
394
|
+
- app/views/ecm/pictures/galleries/_gallery.html.erb
|
395
|
+
- app/views/ecm/pictures/galleries/_gallery_for_index.html.erb
|
396
|
+
- app/views/ecm/pictures/galleries/index.html.erb
|
397
|
+
- app/views/ecm/pictures/galleries/show.html.erb
|
401
398
|
- app/views/ecm/pictures/pictures/_picture.html.erb
|
402
399
|
- app/views/ecm/pictures/pictures/_picture_for_gallery.html.erb
|
403
400
|
- app/views/ecm/pictures/pictures/index.html.erb
|
@@ -406,14 +403,15 @@ files:
|
|
406
403
|
- config/locales/ecm.pictures.attached_picture.en.yml
|
407
404
|
- config/locales/ecm.pictures.de.yml
|
408
405
|
- config/locales/ecm.pictures.en.yml
|
406
|
+
- config/locales/ecm.pictures.gallery.de.yml
|
407
|
+
- config/locales/ecm.pictures.gallery.en.yml
|
409
408
|
- config/locales/ecm.pictures.picture.de.yml
|
410
409
|
- config/locales/ecm.pictures.picture.en.yml
|
411
|
-
- config/locales/ecm.pictures.picture_gallery.de.yml
|
412
|
-
- config/locales/ecm.pictures.picture_gallery.en.yml
|
413
410
|
- db/migrate/001_create_ecm_pictures_picture_galleries.rb
|
414
411
|
- db/migrate/002_create_ecm_pictures_pictures.rb
|
415
412
|
- db/migrate/003_create_ecm_pictures_attached_pictures.rb
|
416
|
-
-
|
413
|
+
- db/migrate/20160626141629_rename_ecm_pictures_picture_galleries_to_ecm_pictures_galleries.rb
|
414
|
+
- db/migrate/20160626143414_rename_ecm_pictures_pictures_picture_gallery_id_to_gallery_id.rb
|
417
415
|
- lib/ecm/pictures/configuration.rb
|
418
416
|
- lib/ecm/pictures/engine.rb
|
419
417
|
- lib/ecm/pictures/routing.rb
|
@@ -422,10 +420,9 @@ files:
|
|
422
420
|
- lib/generators/ecm/pictures/install/install_generator.rb
|
423
421
|
- lib/generators/ecm/pictures/install/templates/initializer.rb
|
424
422
|
- lib/generators/ecm/pictures/install/templates/routes.source
|
425
|
-
- lib/generators/ecm/pictures/locales/locales_generator.rb
|
426
423
|
- lib/tasks/ecm_pictures_tasks.rake
|
427
424
|
- spec/factories/ecm/pictures/attached_pictures.rb
|
428
|
-
- spec/factories/ecm/pictures/
|
425
|
+
- spec/factories/ecm/pictures/galleries.rb
|
429
426
|
- spec/factories/ecm/pictures/pictures.rb
|
430
427
|
- spec/factories/post.rb
|
431
428
|
- spec/files/ecm/pictures/picture/image.jpg
|
@@ -1,13 +0,0 @@
|
|
1
|
-
ActiveAdmin.register Ecm::Pictures::AttachedPicture do
|
2
|
-
menu false
|
3
|
-
|
4
|
-
actions :destroy
|
5
|
-
|
6
|
-
controller do
|
7
|
-
def destroy
|
8
|
-
destroy! do |format|
|
9
|
-
format.html { redirect_to :back }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
@@ -1,110 +0,0 @@
|
|
1
|
-
include ActiveAdmin::ActsAsList::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
|
2
|
-
|
3
|
-
ActiveAdmin.register Ecm::Pictures::PictureGallery do
|
4
|
-
menu parent: I18n.t('ecm.pictures.active_admin.menu')
|
5
|
-
|
6
|
-
permit_params :description,
|
7
|
-
:link_images,
|
8
|
-
:markup_language,
|
9
|
-
:name,
|
10
|
-
:pictures_attributes,
|
11
|
-
:position,
|
12
|
-
pictures_attributes: [
|
13
|
-
:description,
|
14
|
-
:_destroy,
|
15
|
-
:id,
|
16
|
-
:image,
|
17
|
-
:markup_language,
|
18
|
-
:name,
|
19
|
-
:picture_gallery_id,
|
20
|
-
:position
|
21
|
-
]
|
22
|
-
|
23
|
-
config.sort_order = 'position'
|
24
|
-
sortable_member_actions
|
25
|
-
|
26
|
-
form html: { enctype: 'multipart/form-data' } do |f|
|
27
|
-
f.inputs do
|
28
|
-
f.input :name
|
29
|
-
f.input :description
|
30
|
-
f.input :link_images
|
31
|
-
end
|
32
|
-
|
33
|
-
f.inputs do
|
34
|
-
f.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
|
35
|
-
end
|
36
|
-
|
37
|
-
f.inputs do
|
38
|
-
f.has_many :pictures do |p|
|
39
|
-
p.input :name
|
40
|
-
if p.object.persisted?
|
41
|
-
p.input :_destroy, as: :boolean, label: I18n.t('active_admin.delete')
|
42
|
-
end
|
43
|
-
p.input :image, as: :file, hint: p.template.image_tag(p.object.image.url(:default_thumb))
|
44
|
-
p.input :description
|
45
|
-
|
46
|
-
p.inputs do
|
47
|
-
p.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
f.actions
|
53
|
-
end
|
54
|
-
|
55
|
-
index do
|
56
|
-
sortable_columns
|
57
|
-
column :name
|
58
|
-
column :pictures_count
|
59
|
-
column :link_images do |picture_gallery|
|
60
|
-
I18n.t(picture_gallery.link_images)
|
61
|
-
end
|
62
|
-
column :created_at
|
63
|
-
column :updated_at
|
64
|
-
actions
|
65
|
-
end
|
66
|
-
|
67
|
-
show do
|
68
|
-
panel Ecm::Pictures::PictureGallery.human_attribute_name(:description) do
|
69
|
-
div do
|
70
|
-
mu ecm_pictures_picture_gallery, :description
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
panel Ecm::Pictures::PictureGallery.human_attribute_name(:display_code) do
|
75
|
-
div do
|
76
|
-
ecm_pictures_picture_gallery.display_code
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
panel Ecm::Pictures::PictureGallery.human_attribute_name(:pictures) do
|
81
|
-
table_for ecm_pictures_picture_gallery.pictures, i18n: Ecm::Pictures::Picture do
|
82
|
-
sortable_columns
|
83
|
-
column :thumbnail do |picture|
|
84
|
-
link_to(image_tag(picture.image.url(:default_thumb)), [:admin, picture])
|
85
|
-
end # column
|
86
|
-
column :name
|
87
|
-
column :image_file_size, sortable: :image_file_size do |picture|
|
88
|
-
number_to_human_size(picture.image_file_size)
|
89
|
-
end # column
|
90
|
-
column :created_at
|
91
|
-
column do |picture|
|
92
|
-
link_to(I18n.t('active_admin.view'), [:admin, picture], class: 'member_link view_link') +
|
93
|
-
link_to(I18n.t('active_admin.edit'), [:edit, :admin, picture], class: 'member_link edit_link')
|
94
|
-
end # column
|
95
|
-
end # table_for
|
96
|
-
end # panel
|
97
|
-
end # show
|
98
|
-
|
99
|
-
sidebar Ecm::Pictures::PictureGallery.human_attribute_name(:details), only: :show do
|
100
|
-
attributes_table_for ecm_pictures_picture_gallery do
|
101
|
-
row :name
|
102
|
-
row :pictures_count
|
103
|
-
row :link_images do |picture_gallery|
|
104
|
-
I18n.t(picture_gallery.link_images)
|
105
|
-
end
|
106
|
-
row :created_at
|
107
|
-
row :updated_at
|
108
|
-
end
|
109
|
-
end # sidebar
|
110
|
-
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
@@ -1,97 +0,0 @@
|
|
1
|
-
include ActiveAdmin::ActsAsList::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
|
2
|
-
|
3
|
-
ActiveAdmin.register Ecm::Pictures::Picture do
|
4
|
-
menu parent: I18n.t('ecm.pictures.active_admin.menu')
|
5
|
-
|
6
|
-
permit_params :description,
|
7
|
-
:image,
|
8
|
-
:markup_language,
|
9
|
-
:name,
|
10
|
-
:picture_gallery_id,
|
11
|
-
:position
|
12
|
-
|
13
|
-
# active_admin-acts_as_list
|
14
|
-
config.sort_order = 'picture_gallery_id, position'
|
15
|
-
sortable_member_actions
|
16
|
-
|
17
|
-
# controller do
|
18
|
-
# def destroy
|
19
|
-
# destroy! do |format|
|
20
|
-
# format.html { redirect_to :back }
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
|
25
|
-
form html: { enctype: 'multipart/form-data' } do |f|
|
26
|
-
f.inputs do
|
27
|
-
f.input :picture_gallery
|
28
|
-
f.input :name
|
29
|
-
f.input :image, as: :file, hint: f.template.image_tag(f.object.image.url(:thumb))
|
30
|
-
f.input :description
|
31
|
-
end
|
32
|
-
|
33
|
-
f.inputs do
|
34
|
-
f.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
|
35
|
-
end
|
36
|
-
|
37
|
-
f.actions
|
38
|
-
end
|
39
|
-
|
40
|
-
index do
|
41
|
-
selectable_column
|
42
|
-
column :thumbnail do |picture|
|
43
|
-
link_to(image_tag(picture.image.url(:default_thumb)), admin_ecm_pictures_picture_path(picture))
|
44
|
-
end
|
45
|
-
column :picture_gallery
|
46
|
-
column :name
|
47
|
-
column :image_file_size, sortable: :image_file_size do |picture|
|
48
|
-
number_to_human_size(picture.image_file_size)
|
49
|
-
end
|
50
|
-
column :created_at
|
51
|
-
actions
|
52
|
-
end
|
53
|
-
|
54
|
-
show do
|
55
|
-
panel Ecm::Pictures::Picture.human_attribute_name(:image) do
|
56
|
-
div { image_tag ecm_pictures_picture.image.url }
|
57
|
-
end
|
58
|
-
|
59
|
-
panel Ecm::Pictures::Picture.human_attribute_name(:description) do
|
60
|
-
div do
|
61
|
-
mu ecm_pictures_picture, :description
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
panel Ecm::Pictures::Picture.human_attribute_name(:display_code) do
|
66
|
-
div do
|
67
|
-
ecm_pictures_picture.display_code(:textile)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
ecm_pictures_picture.attached_pictures.all.group_by(&:pictureable_type).each do |type, attached_pictures|
|
72
|
-
panel type.constantize.model_name.human do
|
73
|
-
table_for attached_pictures.map(&:pictureable) do
|
74
|
-
column :to_s
|
75
|
-
column do |obj|
|
76
|
-
link_to(I18n.t('active_admin.view'), [:admin, obj], class: 'member_link view_link') +
|
77
|
-
link_to(I18n.t('active_admin.edit'), [:edit, :admin, obj], class: 'member_link edit_link')
|
78
|
-
end # column
|
79
|
-
end # table_for
|
80
|
-
end # panel
|
81
|
-
end # each
|
82
|
-
end # show
|
83
|
-
|
84
|
-
sidebar Ecm::Pictures::Picture.human_attribute_name(:details), only: :show do
|
85
|
-
attributes_table_for ecm_pictures_picture do
|
86
|
-
row :picture_gallery
|
87
|
-
row :name
|
88
|
-
row :image_file_name
|
89
|
-
row :image_file_size do |picture|
|
90
|
-
number_to_human_size(picture.image_file_size)
|
91
|
-
end
|
92
|
-
row :image_fingerprint
|
93
|
-
row :created_at
|
94
|
-
row :updated_at
|
95
|
-
end
|
96
|
-
end # sidebar
|
97
|
-
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Ecm::Pictures
|
2
|
-
class Ecm::Pictures::PictureGalleriesController < Ecm::Pictures::Configuration.base_controller.constantize
|
3
|
-
def index
|
4
|
-
@picture_galleries = Ecm::Pictures::PictureGallery.all
|
5
|
-
end
|
6
|
-
|
7
|
-
def show
|
8
|
-
@picture_gallery = Ecm::Pictures::PictureGallery.find(params[:id])
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Ecm::Pictures::PictureGallery < ActiveRecord::Base
|
2
|
-
self.table_name = 'ecm_pictures_picture_galleries'
|
3
|
-
|
4
|
-
# associations
|
5
|
-
has_many :pictures,
|
6
|
-
dependent: :destroy # ,
|
7
|
-
# :order => 'position'
|
8
|
-
|
9
|
-
# attributes
|
10
|
-
attr_accessible :description,
|
11
|
-
:link_images,
|
12
|
-
:markup_language,
|
13
|
-
:name,
|
14
|
-
:pictures_attributes,
|
15
|
-
:position if respond_to?(:attr_accessible)
|
16
|
-
accepts_nested_attributes_for :pictures, allow_destroy: true
|
17
|
-
|
18
|
-
# acts as list
|
19
|
-
acts_as_list
|
20
|
-
default_scope { order(:position) }
|
21
|
-
|
22
|
-
# acts as markup
|
23
|
-
acts_as_markup language: :variable, columns: [:description]
|
24
|
-
|
25
|
-
# callbacks
|
26
|
-
after_initialize :set_defaults
|
27
|
-
|
28
|
-
# friendly id
|
29
|
-
extend FriendlyId
|
30
|
-
friendly_id :name, use: [:slugged, :finders]
|
31
|
-
|
32
|
-
# tagging
|
33
|
-
acts_as_taggable if respond_to?(:acts_as_taggable)
|
34
|
-
|
35
|
-
# validations
|
36
|
-
validates :markup_language, presence: true,
|
37
|
-
inclusion: Ecm::Pictures::Configuration.markup_languages
|
38
|
-
validates :name, presence: true,
|
39
|
-
uniqueness: true
|
40
|
-
|
41
|
-
def display_code_for_erb
|
42
|
-
"<%= render_picture_gallery '#{name}' %>"
|
43
|
-
end
|
44
|
-
|
45
|
-
def picture_images=(picture_images)
|
46
|
-
picture_images.each do |image|
|
47
|
-
pictures.build(image: image)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_s
|
52
|
-
name
|
53
|
-
end
|
54
|
-
|
55
|
-
def human
|
56
|
-
name
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def set_defaults
|
62
|
-
if self.new_record?
|
63
|
-
self.link_images = true if link_images.nil?
|
64
|
-
self.markup_language ||= Ecm::Pictures::Configuration.default_markup_language
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<%= Ecm::Pictures::Configuration.prevent_textile_rendering_in_html ? '<notextile>'.html_safe : '' %>
|
2
|
-
<div class="picture-gallery-description">
|
3
|
-
<%= mu picture_gallery, :description %>
|
4
|
-
</div>
|
5
|
-
|
6
|
-
<% if picture_gallery.respond_to?(:tag_list) %>
|
7
|
-
<div class="tags bottom-margin-1">
|
8
|
-
<% picture_gallery.tag_list.each do |tag| %>
|
9
|
-
<span class="label label-default"><%= tag %></span>
|
10
|
-
<% end %>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="picture-gallery-pictures row" data-target="#modal-gallery" data-toggle="modal-gallery">
|
15
|
-
<%= render picture_gallery.pictures %>
|
16
|
-
</div>
|
17
|
-
<%= Ecm::Pictures::Configuration.prevent_textile_rendering_in_html ? '</notextile>'.html_safe : '' %>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<div class="col-sm-6 col-md-3">
|
2
|
-
<div class="thumbnail">
|
3
|
-
<% if picture_gallery.pictures.first.respond_to?(:image) %>
|
4
|
-
<%= image_tag picture_gallery.pictures.first.image.url(:default_thumb) %>
|
5
|
-
<% end %>
|
6
|
-
<div class="caption">
|
7
|
-
<h4><%= picture_gallery.name %></h4>
|
8
|
-
<% if picture_gallery.respond_to?(:tag_list) %>
|
9
|
-
<div class="tags bottom-margin-1">
|
10
|
-
<% picture_gallery.tag_list.each do |tag| %>
|
11
|
-
<span class="label label-default"><%= tag %></span>
|
12
|
-
<% end %>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
15
|
-
<div class="truncate lines-3 bottom-margin-1"><%= mu(picture_gallery, :description) %></div>
|
16
|
-
<p><%= link_to t('ecm.pictures.actions.view'), picture_gallery, :class => 'btn btn-primary', :role => 'button' %></p>
|
17
|
-
</div>
|
18
|
-
</div>
|
19
|
-
</div>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<h1><%= @picture_gallery.to_s %></h1>
|
2
|
-
|
3
|
-
<%= render @picture_gallery %>
|
4
|
-
|
5
|
-
<div class="page-actions well">
|
6
|
-
<div class="btn-group" role="group">
|
7
|
-
<%= link_to Ecm::Pictures::PictureGallery.model_name.human(:count => :other), ecm_pictures_picture_galleries_path, :class => 'btn btn-primary' %>
|
8
|
-
<%= link_to t('ecm.pictures.views.actions.back'), :back, class: 'btn btn-default' %>
|
9
|
-
</div>
|
10
|
-
</div>
|
@@ -1,56 +0,0 @@
|
|
1
|
-
if Gem::Specification.find_all_by_name('activeadmin').any?
|
2
|
-
require 'active_admin'
|
3
|
-
|
4
|
-
module Ecm::Pictures
|
5
|
-
module ActiveAdmin
|
6
|
-
module PictureableHelper
|
7
|
-
def form_inputs_for_pictureable(f)
|
8
|
-
f.inputs do
|
9
|
-
f.has_many :pictures do |p|
|
10
|
-
p.input :name
|
11
|
-
p.input :image, as: :file, hint: p.template.image_tag(p.object.image.url(:default_thumb))
|
12
|
-
p.input :description
|
13
|
-
p.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
f.inputs do
|
18
|
-
f.has_many :attached_pictures do |p|
|
19
|
-
p.input :picture, as: :select,
|
20
|
-
collection: Ecm::Pictures::Picture.all.collect do |picture|
|
21
|
-
[picture, picture.id, { style: "background-image: url('#{picture.image.url(:medium_thumb)}'); width: #{Ecm::Pictures::Configuration.paperclip_options[:styles][:medium_thumb].split('x').first}px; height: #{Ecm::Pictures::Configuration.paperclip_options[:styles][:medium_thumb].split('x').last}px; background-repeat: no-repeat; background-position: center;" }]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def panel_for_pictureable
|
28
|
-
panel Ecm::Pictures::PictureGallery.human_attribute_name(:pictures) do
|
29
|
-
table_for resource.pictures, i18n: Ecm::Pictures::Picture do
|
30
|
-
sortable_columns
|
31
|
-
column :thumbnail do |picture|
|
32
|
-
link_to(image_tag(picture.image.url(:default_thumb)), [:admin, picture])
|
33
|
-
end # column
|
34
|
-
column :name
|
35
|
-
column :image_file_size, sortable: :image_file_size do |picture|
|
36
|
-
number_to_human_size(picture.image_file_size)
|
37
|
-
end # column
|
38
|
-
column :created_at
|
39
|
-
column do |picture|
|
40
|
-
link_to(I18n.t('active_admin.view'), [:admin, picture], class: 'member_link view_link') +
|
41
|
-
link_to(I18n.t('active_admin.edit'), [:edit, :admin, picture], class: 'member_link edit_link') +
|
42
|
-
link_to(I18n.t('active_admin.delete'), [:admin, picture], class: 'member_link delete_link', method: :delete) +
|
43
|
-
link_to(I18n.t('active_admin.delete_link'), [:admin, picture.attached_pictures.where(pictureable_type: resource.class, pictureable_id: resource).first], class: 'member_link delete_link', method: :delete)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
::ActiveAdmin::ResourceDSL.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
|
53
|
-
::ActiveAdmin::Views::Pages::Show.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
|
54
|
-
::ActiveAdmin::Views::Pages::Form.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
|
55
|
-
::ActiveAdmin::Views::ActiveAdminForm.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
|
56
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Ecm
|
2
|
-
module Pictures
|
3
|
-
module Generators
|
4
|
-
class LocalesGenerator < Rails::Generators::Base
|
5
|
-
desc 'Copies the locale files to your application'
|
6
|
-
|
7
|
-
source_root File.expand_path('../../../../../../config/locales', __FILE__)
|
8
|
-
|
9
|
-
def generate_locales
|
10
|
-
copy_file 'ecm.pictures.en.yml', 'config/locales/ecm.pictures.en.yml'
|
11
|
-
copy_file 'ecm.pictures.de.yml', 'config/locales/ecm.pictures.de.yml'
|
12
|
-
|
13
|
-
copy_file 'ecm.pictures.attached_picture.en.yml', 'config/locales/ecm.pictures.attached_picture.en.yml'
|
14
|
-
copy_file 'ecm.pictures.attached_picture.de.yml', 'config/locales/ecm.pictures.attached_picture.de.yml'
|
15
|
-
|
16
|
-
copy_file 'ecm.pictures.picture.en.yml', 'config/locales/ecm.pictures.picture.en.yml'
|
17
|
-
copy_file 'ecm.pictures.picture.de.yml', 'config/locales/ecm.pictures.picture.de.yml'
|
18
|
-
|
19
|
-
copy_file 'ecm.pictures.picture_gallery.en.yml', 'config/locales/ecm.pictures.picture_gallery.en.yml'
|
20
|
-
copy_file 'ecm.pictures.picture_gallery.de.yml', 'config/locales/ecm.pictures.picture_gallery.de.yml'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
factory :ecm_pictures_picture_gallery, class: Ecm::Pictures::PictureGallery do
|
3
|
-
sequence(:name) { |n| "Picture gallery ##{n}" }
|
4
|
-
|
5
|
-
factory :ecm_pictures_picture_gallery_with_pictures do |picture_gallery|
|
6
|
-
3.times do
|
7
|
-
picture_gallery.after(:create) { |pg| FactoryGirl.create(:ecm_pictures_picture, picture_gallery: pg) }
|
8
|
-
end
|
9
|
-
picture_gallery.pictures_count 3
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|