ecm_pictures2 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +21 -6
  4. data/Rakefile +2 -5
  5. data/app/admin/ecm_pictures_attached_pictures.rb +2 -3
  6. data/app/admin/ecm_pictures_picture_galleries.rb +21 -22
  7. data/app/admin/ecm_pictures_pictures.rb +13 -14
  8. data/app/controllers/ecm/pictures/picture_galleries_controller.rb +1 -1
  9. data/app/controllers/ecm/pictures/pictures_controller.rb +1 -1
  10. data/app/helpers/ecm/pictures_helper.rb +29 -30
  11. data/app/helpers/markup_helper.rb +3 -3
  12. data/app/models/ecm/pictures/attached_picture.rb +4 -5
  13. data/app/models/ecm/pictures/picture.rb +18 -13
  14. data/app/models/ecm/pictures/picture_gallery.rb +24 -12
  15. data/app/views/ecm/pictures/picture_galleries/_picture_gallery.html.erb +8 -0
  16. data/app/views/ecm/pictures/picture_galleries/_picture_gallery_for_index.html.erb +7 -0
  17. data/app/views/ecm/pictures/pictures/_picture.html.erb +9 -0
  18. data/config/locales/ecm.pictures.picture.de.yml +1 -0
  19. data/config/locales/ecm.pictures.picture.en.yml +1 -0
  20. data/db/migrate/001_create_ecm_pictures_picture_galleries.rb +3 -3
  21. data/db/migrate/002_create_ecm_pictures_pictures.rb +3 -3
  22. data/db/migrate/003_create_ecm_pictures_attached_pictures.rb +1 -2
  23. data/lib/ecm/pictures/active_admin/pictureable_helper.rb +51 -49
  24. data/lib/ecm/pictures/configuration.rb +0 -4
  25. data/lib/ecm/pictures/engine.rb +2 -3
  26. data/lib/ecm/pictures/routing.rb +7 -8
  27. data/lib/ecm/pictures/version.rb +1 -2
  28. data/lib/ecm_pictures2.rb +2 -3
  29. data/lib/generators/ecm/pictures/install/install_generator.rb +13 -7
  30. data/lib/generators/ecm/pictures/install/templates/{ecm_pictures.rb → initializer.rb} +4 -5
  31. data/lib/generators/ecm/pictures/install/templates/routes.source +5 -0
  32. data/lib/generators/ecm/pictures/locales/locales_generator.rb +9 -10
  33. data/lib/tasks/ecm_pictures_tasks.rake +24 -26
  34. metadata +42 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62f584e41dc4e85d47f3b363525803e23325de38
4
- data.tar.gz: b7acd89ff0feaf70a6e4859a0ac4d32997a210cf
3
+ metadata.gz: b99e9ac880d8683dcaeb685655a7b05ae393419f
4
+ data.tar.gz: 9ec6f5096b217ca3a69e315d72722c90bb684b14
5
5
  SHA512:
6
- metadata.gz: 7ed1c2bbe0b4d118beed3dd1e8fea3fe3532594c1dd822b6a0edf66f4f1d7017553f2a11856196c3c0e35b5c37ccb0784192046341782946515ac5889a728f29
7
- data.tar.gz: 31702b87d0acf50e08918747584f07e3de99ec74067c7c0c6ed14424efbc621fe3876dd9d2df7a321339b5ffac7712ce4451abf3c51d3c11d0aaf8ba615ecc49
6
+ metadata.gz: 0b1fc42b5eb37bd331f8a2efeb23731550d38a27bd55b4ad1b31a558dd0ed0fefd650121c93554d884f78ea0fda2654314d417b15cd57380859e35490ac94c09
7
+ data.tar.gz: 988e2c4dcd4502061a81776a801961b72e73864e50618fb5810b0b75e14e78e3b5ac08af8daa82964955d070c786f3e3f74b509fb572bcfe21b332f8f66122e8
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 Roberto Vasquez Angel
1
+ Copyright 2015 Roberto Vasquez Angel
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -5,11 +5,26 @@
5
5
  Create and administrate picture galleries in active admin and display them on
6
6
  in your ruby on rails applictation. Orangebox is used for lightbox support.
7
7
 
8
- # Prerequisites
8
+ = Migrating from 1.x.x to 2.0.0
9
+
10
+ Add active_admin-awesome_nested_set to your gemfile, if you are using activeadmin:
11
+
12
+ # Gemfile
13
+ gem 'active_admin-acts_as_list'
14
+
15
+
16
+ = Prerequisites
9
17
 
10
18
  * Ruby on Rails 4.x
11
19
  * Twitter Bootstrap 3
12
20
 
21
+ = Prerequisites when using active admin
22
+
23
+ if you are using activeadmin as backend, ecm_cms2 comes with admin files to provide a backend. In that case, you'll need active_admin-acts_as_list. Add it to your gemfile:
24
+
25
+ # Gemfile
26
+ gem 'active_admin-acts_as_list'
27
+
13
28
  = Features
14
29
 
15
30
  * Drop in module for active admin.
@@ -73,12 +88,12 @@ Once you have a gallery, you can display it like this:
73
88
 
74
89
  <%= render_picture_gallery 'Holidays 2012' %>
75
90
 
76
- = Todo
91
+ = Running specs
77
92
 
78
- * Tests, tests, tests.
79
- * Better docs.
80
- * Render picture helpers.
81
- * Add a published flag to galleries and pictures.
93
+ gem install bundler
94
+ bundle
95
+ cd spec/dummy && rake db:migrate RAILS_ENV=test && cd ../..
96
+ guard
82
97
 
83
98
  = License
84
99
 
data/Rakefile CHANGED
@@ -14,15 +14,12 @@ end
14
14
 
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'EcmPictureGallery'
17
+ rdoc.title = 'ECM Pictures 2'
18
18
  rdoc.options << '--line-numbers'
19
19
  rdoc.rdoc_files.include('README.rdoc')
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
-
24
-
25
-
26
23
  Bundler::GemHelper.install_tasks
27
24
 
28
- require 'rails/dummy/tasks'
25
+ require 'rails/dummy/tasks'
@@ -6,9 +6,8 @@ ActiveAdmin.register Ecm::Pictures::AttachedPicture do
6
6
  controller do
7
7
  def destroy
8
8
  destroy! do |format|
9
- format.html { redirect_to :back }
9
+ format.html { redirect_to :back }
10
10
  end
11
11
  end
12
12
  end
13
- end
14
-
13
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -1,7 +1,7 @@
1
- include ActiveAdmin::ActsAsList::Helper if defined?(::ActiveAdmin)
1
+ include ActiveAdmin::ActsAsList::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
2
2
 
3
3
  ActiveAdmin.register Ecm::Pictures::PictureGallery do
4
- menu :parent => I18n.t('ecm.pictures.active_admin.menu')
4
+ menu parent: I18n.t('ecm.pictures.active_admin.menu')
5
5
 
6
6
  permit_params :description,
7
7
  :link_images,
@@ -23,7 +23,7 @@ ActiveAdmin.register Ecm::Pictures::PictureGallery do
23
23
  config.sort_order = 'position'
24
24
  sortable_member_actions
25
25
 
26
- form :html => { :enctype => "multipart/form-data" } do |f|
26
+ form html: { enctype: 'multipart/form-data' } do |f|
27
27
  f.inputs do
28
28
  f.input :name
29
29
  f.input :description
@@ -31,23 +31,23 @@ ActiveAdmin.register Ecm::Pictures::PictureGallery do
31
31
  end
32
32
 
33
33
  f.inputs do
34
- f.input :markup_language, :as => :select, :collection => Ecm::Pictures::Configuration.markup_languages
34
+ f.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
35
35
  end
36
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
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
45
 
46
- p.inputs do
47
- p.input :markup_language, :as => :select, :collection => Ecm::Pictures::Configuration.markup_languages
46
+ p.inputs do
47
+ p.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
48
+ end
48
49
  end
49
50
  end
50
- end
51
51
 
52
52
  f.actions
53
53
  end
@@ -78,25 +78,25 @@ ActiveAdmin.register Ecm::Pictures::PictureGallery do
78
78
  end
79
79
 
80
80
  panel Ecm::Pictures::PictureGallery.human_attribute_name(:pictures) do
81
- table_for ecm_pictures_picture_gallery.pictures, :i18n => Ecm::Pictures::Picture do
81
+ table_for ecm_pictures_picture_gallery.pictures, i18n: Ecm::Pictures::Picture do
82
82
  sortable_columns
83
83
  column :thumbnail do |picture|
84
84
  link_to(image_tag(picture.image.url(:default_thumb)), [:admin, picture])
85
85
  end # column
86
86
  column :name
87
- column :image_file_size, :sortable => :image_file_size do |picture|
87
+ column :image_file_size, sortable: :image_file_size do |picture|
88
88
  number_to_human_size(picture.image_file_size)
89
89
  end # column
90
90
  column :created_at
91
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")
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
94
  end # column
95
95
  end # table_for
96
96
  end # panel
97
97
  end # show
98
98
 
99
- sidebar Ecm::Pictures::PictureGallery.human_attribute_name(:details), :only => :show do
99
+ sidebar Ecm::Pictures::PictureGallery.human_attribute_name(:details), only: :show do
100
100
  attributes_table_for ecm_pictures_picture_gallery do
101
101
  row :name
102
102
  row :pictures_count
@@ -107,5 +107,4 @@ ActiveAdmin.register Ecm::Pictures::PictureGallery do
107
107
  row :updated_at
108
108
  end
109
109
  end # sidebar
110
- end if defined?(::ActiveAdmin)
111
-
110
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -1,7 +1,7 @@
1
- include ActiveAdmin::ActsAsList::Helper if defined?(::ActiveAdmin)
1
+ include ActiveAdmin::ActsAsList::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
2
2
 
3
3
  ActiveAdmin.register Ecm::Pictures::Picture do
4
- menu :parent => I18n.t('ecm.pictures.active_admin.menu')
4
+ menu parent: I18n.t('ecm.pictures.active_admin.menu')
5
5
 
6
6
  permit_params :description,
7
7
  :image,
@@ -22,16 +22,16 @@ ActiveAdmin.register Ecm::Pictures::Picture do
22
22
  # end
23
23
  # end
24
24
 
25
- form :html => { :enctype => "multipart/form-data" } do |f|
25
+ form html: { enctype: 'multipart/form-data' } do |f|
26
26
  f.inputs do
27
27
  f.input :picture_gallery
28
28
  f.input :name
29
- f.input :image, :as => :file, :hint => f.template.image_tag(f.object.image.url(:thumb))
29
+ f.input :image, as: :file, hint: f.template.image_tag(f.object.image.url(:thumb))
30
30
  f.input :description
31
31
  end
32
32
 
33
33
  f.inputs do
34
- f.input :markup_language, :as => :select, :collection => Ecm::Pictures::Configuration.markup_languages
34
+ f.input :markup_language, as: :select, collection: Ecm::Pictures::Configuration.markup_languages
35
35
  end
36
36
 
37
37
  f.actions
@@ -44,7 +44,7 @@ ActiveAdmin.register Ecm::Pictures::Picture do
44
44
  end
45
45
  column :picture_gallery
46
46
  column :name
47
- column :image_file_size, :sortable => :image_file_size do |picture|
47
+ column :image_file_size, sortable: :image_file_size do |picture|
48
48
  number_to_human_size(picture.image_file_size)
49
49
  end
50
50
  column :created_at
@@ -53,7 +53,7 @@ ActiveAdmin.register Ecm::Pictures::Picture do
53
53
 
54
54
  show do
55
55
  panel Ecm::Pictures::Picture.human_attribute_name(:image) do
56
- div { image_tag ecm_pictures_picture.image.url }
56
+ div { image_tag ecm_pictures_picture.image.url }
57
57
  end
58
58
 
59
59
  panel Ecm::Pictures::Picture.human_attribute_name(:description) do
@@ -72,16 +72,16 @@ ActiveAdmin.register Ecm::Pictures::Picture do
72
72
  panel type.constantize.model_name.human do
73
73
  table_for attached_pictures.map(&:pictureable) do
74
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
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
79
  end # table_for
80
80
  end # panel
81
81
  end # each
82
82
  end # show
83
83
 
84
- sidebar Ecm::Pictures::Picture.human_attribute_name(:details), :only => :show do
84
+ sidebar Ecm::Pictures::Picture.human_attribute_name(:details), only: :show do
85
85
  attributes_table_for ecm_pictures_picture do
86
86
  row :picture_gallery
87
87
  row :name
@@ -94,5 +94,4 @@ ActiveAdmin.register Ecm::Pictures::Picture do
94
94
  row :updated_at
95
95
  end
96
96
  end # sidebar
97
- end if defined?(::ActiveAdmin)
98
-
97
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -8,4 +8,4 @@ module Ecm::Pictures
8
8
  @picture_gallery = Ecm::Pictures::PictureGallery.find(params[:id])
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -8,4 +8,4 @@ module Ecm::Pictures
8
8
  @picture = Ecm::Pictures::Picture.find(params[:id])
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -8,23 +8,25 @@ module Ecm::PicturesHelper
8
8
  #
9
9
  # <%= render_picture_gallery 'Holidays 2012' %>
10
10
  def render_picture_gallery(name, options = {})
11
- begin
12
- options = {:preview_style => :thumb}.merge(options)
11
+ options = { preview_style: :thumb }.merge(options)
13
12
 
14
- gallery = Ecm::Pictures::PictureGallery.where(:name => name.to_s).first
15
- gallery_identifier = gallery.to_param rescue 'missing'
13
+ gallery = Ecm::Pictures::PictureGallery.where(name: name.to_s).first
14
+ gallery_identifier = begin
15
+ gallery.to_param
16
+ rescue
17
+ 'missing'
18
+ end
16
19
 
17
- if gallery.nil?
18
- content_tag(:div, :class => 'warning missing picture-gallery') do
19
- content_tag(:p, I18n.t('ecm.pictures.picture_gallery.warnings.missing', :name => name.to_s))
20
- end
21
- else
22
- render gallery
20
+ if gallery.nil?
21
+ content_tag(:div, class: 'warning missing picture-gallery') do
22
+ content_tag(:p, I18n.t('ecm.pictures.picture_gallery.warnings.missing', name: name.to_s))
23
23
  end
24
-
25
- rescue Exception => e
26
- return e.message
24
+ else
25
+ render gallery
27
26
  end
27
+
28
+ rescue Exception => e
29
+ return e.message
28
30
  end
29
31
 
30
32
  # helper method to build link options for images inside a gallery.
@@ -35,35 +37,32 @@ module Ecm::PicturesHelper
35
37
  link_options[:rel] = "lightbox[#{gallery_identifier}]"
36
38
 
37
39
  # Add thumbnail class for twitter bootstrap
38
- link_options[:class] = "thumbnail"
40
+ link_options[:class] = 'thumbnail'
39
41
 
40
42
  # build the caption
41
- caption = ""
43
+ caption = ''
42
44
  caption << "<div class=\"caption-name\">#{picture.name}</div>" unless picture.name.blank?
43
45
  caption << "<div class=\"caption-description\">#{picture.description}</div>" unless picture.description.blank?
44
46
  link_options[:"data-ob_caption"] = caption if caption.size > 0
45
47
 
46
- return link_options
48
+ link_options
47
49
  end
48
50
 
49
51
  def render_picture(name, options = {})
50
- begin
51
- options = {:preview_style => :thumb}.merge(options)
52
+ options = { preview_style: :thumb }.merge(options)
52
53
 
53
- picture = Ecm::Pictures::Picture.where(:name => name.to_s).first
54
- # gallery_identifier = gallery.to_param rescue 'missing'
54
+ picture = Ecm::Pictures::Picture.where(name: name.to_s).first
55
+ # gallery_identifier = gallery.to_param rescue 'missing'
55
56
 
56
- if picture.nil?
57
- content_tag(:div, :class => 'warning missing picture') do
58
- content_tag(:p, I18n.t('ecm.pictures.picture.warnings.missing', :name => name.to_s))
59
- end
60
- else
61
- render picture
57
+ if picture.nil?
58
+ content_tag(:div, class: 'warning missing picture') do
59
+ content_tag(:p, I18n.t('ecm.pictures.picture.warnings.missing', name: name.to_s))
62
60
  end
63
-
64
- rescue Exception => e
65
- return e.message
61
+ else
62
+ render picture
66
63
  end
64
+
65
+ rescue Exception => e
66
+ return e.message
67
67
  end
68
68
  end
69
-
@@ -1,7 +1,7 @@
1
1
  module MarkupHelper
2
2
  def mu(object, method)
3
3
  handler = object.send(method)
4
- erb_string = ::ERB.new(object[method.to_sym].to_s, 0).result(binding())
5
- return handler.class.new(erb_string).to_html.html_safe
6
- end
4
+ erb_string = ::ERB.new(object[method.to_sym].to_s, 0).result(binding)
5
+ handler.class.new(erb_string).to_html.html_safe
6
+ end
7
7
  end
@@ -3,14 +3,13 @@ module Ecm::Pictures
3
3
  self.table_name = 'ecm_pictures_attached_pictures'
4
4
 
5
5
  # associations
6
- belongs_to :picture, :foreign_key => 'ecm_pictures_picture_id'
7
- belongs_to :pictureable, :polymorphic => true
6
+ belongs_to :picture, foreign_key: 'ecm_pictures_picture_id'
7
+ belongs_to :pictureable, polymorphic: true
8
8
 
9
9
  # attributes
10
10
  attr_accessible :ecm_pictures_picture_id if respond_to?(:attr_accessible)
11
11
 
12
12
  # validations
13
- validates :picture, :pictureable, :presence => true
13
+ validates :picture, :pictureable, presence: true
14
14
  end # class AttachedPicture < ActiveRecord::Base
15
- end# module Ecm::Pictures
16
-
15
+ end # module Ecm::Pictures
@@ -2,8 +2,8 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
2
2
  self.table_name = 'ecm_pictures_pictures'
3
3
 
4
4
  # associations
5
- belongs_to :picture_gallery, :counter_cache => true
6
- has_many :attached_pictures, :foreign_key => 'ecm_pictures_picture_id'
5
+ belongs_to :picture_gallery, counter_cache: true
6
+ has_many :attached_pictures, foreign_key: 'ecm_pictures_picture_id'
7
7
  # attributes
8
8
  attr_accessible :description,
9
9
  :image,
@@ -13,39 +13,41 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
13
13
  :position if respond_to?(:attr_accessible)
14
14
 
15
15
  # acts as list
16
- acts_as_list :scope => :picture_gallery
16
+ acts_as_list scope: :picture_gallery
17
17
 
18
18
  # acts as markup
19
- acts_as_markup :language => :variable, :columns => [ :description, :description ]
19
+ acts_as_markup language: :variable, columns: [:description, :description]
20
20
 
21
21
  # callbacks
22
22
  after_initialize :set_defaults
23
- before_validation :set_name_from_image_file_name, :if => Proc.new { |p| ( p.name.nil? || p.name.empty? ) }
23
+ before_validation :set_name_from_image_file_name, if: proc { |p| (p.name.nil? || p.name.empty?) }
24
24
 
25
25
  # default scope
26
26
  default_scope { order(:picture_gallery_id, :position) }
27
27
  # friendly id
28
28
  extend FriendlyId
29
- friendly_id :name, :use => [:slugged, :finders]
29
+ friendly_id :name, use: [:slugged, :finders]
30
30
  # paperclip
31
31
  has_attached_file :image, Ecm::Pictures::Configuration.paperclip_options
32
32
 
33
+ # tagging
34
+ acts_as_taggable if respond_to?(:acts_as_taggable)
35
+
33
36
  # validations
34
- validates :image, :attachment_presence => true
37
+ validates :image, attachment_presence: true
35
38
  # validates_attachment_presence :image
36
39
  validates_attachment :image, content_type: { content_type: /\Aimage\/.*\Z/ }
37
40
 
38
- validates :markup_language, :presence => true,
39
- :inclusion => Ecm::Pictures::Configuration.markup_languages
40
- validates :name, :presence => true
41
+ validates :markup_language, presence: true,
42
+ inclusion: Ecm::Pictures::Configuration.markup_languages
43
+ validates :name, presence: true
41
44
 
42
45
  def display_code(style)
43
46
  case style
44
47
  when :erb
45
- "<%= render_picture '#{self.name}' %>"
48
+ "<%= render_picture '#{name}' %>"
46
49
  when :textile
47
50
  "!#{image.url}!".gsub(/(\?[0-9]{1,})/, '')
48
- else
49
51
  end
50
52
  end
51
53
 
@@ -53,6 +55,10 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
53
55
  name
54
56
  end
55
57
 
58
+ def human
59
+ name
60
+ end
61
+
56
62
  private
57
63
 
58
64
  def set_defaults
@@ -65,4 +71,3 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
65
71
  self.name = File.basename(image_file_name, File.extname(image_file_name)) unless image_file_name.nil?
66
72
  end
67
73
  end
68
-
@@ -3,8 +3,8 @@ class Ecm::Pictures::PictureGallery < ActiveRecord::Base
3
3
 
4
4
  # associations
5
5
  has_many :pictures,
6
- :dependent => :destroy # ,
7
- # :order => 'position'
6
+ dependent: :destroy # ,
7
+ # :order => 'position'
8
8
 
9
9
  # attributes
10
10
  attr_accessible :description,
@@ -13,43 +13,55 @@ class Ecm::Pictures::PictureGallery < ActiveRecord::Base
13
13
  :name,
14
14
  :pictures_attributes,
15
15
  :position if respond_to?(:attr_accessible)
16
- accepts_nested_attributes_for :pictures, :allow_destroy => true
16
+ accepts_nested_attributes_for :pictures, allow_destroy: true
17
17
 
18
18
  # acts as list
19
19
  acts_as_list
20
20
  default_scope { order(:position) }
21
21
 
22
22
  # acts as markup
23
- acts_as_markup :language => :variable, :columns => [ :description ]
23
+ acts_as_markup language: :variable, columns: [:description]
24
24
 
25
25
  # callbacks
26
26
  after_initialize :set_defaults
27
27
 
28
28
  # friendly id
29
29
  extend FriendlyId
30
- friendly_id :name, :use => [:slugged, :finders]
30
+ friendly_id :name, use: [:slugged, :finders]
31
+
32
+ # tagging
33
+ acts_as_taggable if respond_to?(:acts_as_taggable)
31
34
 
32
35
  # validations
33
- validates :markup_language, :presence => true,
34
- :inclusion => Ecm::Pictures::Configuration.markup_languages
35
- validates :name, :presence => true,
36
- :uniqueness => true
36
+ validates :markup_language, presence: true,
37
+ inclusion: Ecm::Pictures::Configuration.markup_languages
38
+ validates :name, presence: true,
39
+ uniqueness: true
37
40
 
38
41
  def display_code
39
- "<%= render_picture_gallery '#{self.name}' %>"
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
40
49
  end
41
50
 
42
51
  def to_s
43
52
  name
44
53
  end
45
54
 
55
+ def human
56
+ name
57
+ end
58
+
46
59
  private
47
60
 
48
61
  def set_defaults
49
62
  if self.new_record?
50
- self.link_images = true if self.link_images.nil?
63
+ self.link_images = true if link_images.nil?
51
64
  self.markup_language ||= Ecm::Pictures::Configuration.default_markup_language
52
65
  end
53
66
  end
54
67
  end
55
-
@@ -3,6 +3,14 @@
3
3
  <%= mu picture_gallery, :description %>
4
4
  </div>
5
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
+
6
14
  <div class="picture-gallery-pictures row" data-target="#modal-gallery" data-toggle="modal-gallery">
7
15
  <%= render picture_gallery.pictures %>
8
16
  </div>
@@ -5,6 +5,13 @@
5
5
  <% end %>
6
6
  <div class="caption">
7
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 %>
8
15
  <div class="truncate lines-3 bottom-margin-1"><%= mu(picture_gallery, :description) %></div>
9
16
  <p><%= link_to t('ecm.pictures.actions.view'), picture_gallery, :class => 'btn btn-primary', :role => 'button' %></p>
10
17
  </div>
@@ -2,6 +2,15 @@
2
2
  <div class="col-xs-6 col-md-3">
3
3
  <%= link_to("#{picture.image.url}#{File.extname(picture.image_file_name).downcase}", :'data-gallery' => "gallery", :class => 'thumbnail') do %>
4
4
  <%= image_tag(picture.image.url(:default_thumb)) %>
5
+ <!--
6
+ <% if picture.respond_to?(:tag_list) && picture.tag_list.any? %>
7
+ <div class="tags">
8
+ <% picture.tag_list.each do |tag| %>
9
+ <span class="label label-default"><%= tag %></span>
10
+ <% end %>
11
+ </div>
12
+ <% end %>
13
+ -->
5
14
  <% end %>
6
15
  </div>
7
16
  <%= Ecm::Pictures::Configuration.prevent_textile_rendering_in_html ? '</notextile>'.html_safe : '' %>
@@ -18,6 +18,7 @@ de:
18
18
  name: Name
19
19
  picture_gallery: Galerie
20
20
  position: Position
21
+ preview_picture: Vorschau
21
22
  thumbnail: Vorschau
22
23
  updated_at: Aktualisiert am
23
24
  routes:
@@ -18,6 +18,7 @@ en:
18
18
  name: name
19
19
  picture_gallery: picture gallery
20
20
  position: position
21
+ preview_picture: preview
21
22
  thumbnail: thumbnail
22
23
  updated_at: updated at
23
24
  routes:
@@ -6,14 +6,14 @@ class CreateEcmPicturesPictureGalleries < ActiveRecord::Migration
6
6
  t.boolean :link_images
7
7
 
8
8
  # associations
9
- t.integer :pictures_count, :default => 0, :null => false
10
-
9
+ t.integer :pictures_count, default: 0, null: false
10
+
11
11
  # acts as list
12
12
  t.integer :position
13
13
 
14
14
  # acts as markup
15
15
  t.string :markup_language
16
-
16
+
17
17
  # friendly id
18
18
  t.string :slug
19
19
 
@@ -6,16 +6,16 @@ class CreateEcmPicturesPictures < ActiveRecord::Migration
6
6
 
7
7
  # associations
8
8
  t.references :picture_gallery
9
-
9
+
10
10
  # acts as list
11
11
  t.integer :position
12
12
 
13
13
  # acts as markup
14
14
  t.string :markup_language
15
-
15
+
16
16
  # friendly id
17
17
  t.string :slug
18
-
18
+
19
19
  # paperclip
20
20
  # t.attachment :image
21
21
  t.string :image_file_name