ecm_pictures2 1.0.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +78 -0
- data/Rakefile +28 -0
- data/app/admin/ecm_pictures_attached_pictures.rb +14 -0
- data/app/admin/ecm_pictures_picture_galleries.rb +111 -0
- data/app/admin/ecm_pictures_pictures.rb +98 -0
- data/app/assets/stylesheets/ecm_pictures.css.less +5 -0
- data/app/controllers/ecm/pictures/picture_galleries_controller.rb +11 -0
- data/app/controllers/ecm/pictures/pictures_controller.rb +11 -0
- data/app/helpers/ecm/pictures_helper.rb +72 -0
- data/app/helpers/markup_helper.rb +7 -0
- data/app/models/ecm/pictures/attached_picture.rb +16 -0
- data/app/models/ecm/pictures/picture.rb +68 -0
- data/app/models/ecm/pictures/picture_gallery.rb +55 -0
- data/app/views/ecm/pictures/picture_galleries/_picture_gallery.html.erb +7 -0
- data/app/views/ecm/pictures/picture_galleries/_picture_gallery_for_index.html.erb +17 -0
- data/app/views/ecm/pictures/picture_galleries/_picture_gallery_for_index2.html.erb +12 -0
- data/app/views/ecm/pictures/picture_galleries/index.html.erb +7 -0
- data/app/views/ecm/pictures/picture_galleries/show.html.erb +12 -0
- data/app/views/ecm/pictures/pictures/_picture.html.erb +5 -0
- data/app/views/ecm/pictures/pictures/_picture_for_gallery.html.erb +10 -0
- data/app/views/ecm/pictures/pictures/index.html.erb +5 -0
- data/app/views/ecm/pictures/pictures/show.html.erb +14 -0
- data/config/locales/ecm.pictures.attached_picture.de.yml +15 -0
- data/config/locales/ecm.pictures.attached_picture.en.yml +15 -0
- data/config/locales/ecm.pictures.de.yml +17 -0
- data/config/locales/ecm.pictures.en.yml +15 -0
- data/config/locales/ecm.pictures.picture.de.yml +25 -0
- data/config/locales/ecm.pictures.picture.en.yml +25 -0
- data/config/locales/ecm.pictures.picture_gallery.de.yml +21 -0
- data/config/locales/ecm.pictures.picture_gallery.en.yml +21 -0
- data/db/migrate/001_create_ecm_pictures_picture_galleries.rb +23 -0
- data/db/migrate/002_create_ecm_pictures_pictures.rb +30 -0
- data/db/migrate/003_create_ecm_pictures_attached_pictures.rb +10 -0
- data/lib/ecm/pictures/active_admin/pictureable_helper.rb +53 -0
- data/lib/ecm/pictures/configuration.rb +33 -0
- data/lib/ecm/pictures/engine.rb +12 -0
- data/lib/ecm/pictures/routing.rb +22 -0
- data/lib/ecm/pictures/version.rb +6 -0
- data/lib/ecm_pictures2.rb +18 -0
- data/lib/generators/ecm/pictures/install/install_generator.rb +15 -0
- data/lib/generators/ecm/pictures/install/templates/ecm_pictures.rb +35 -0
- data/lib/generators/ecm/pictures/locales/locales_generator.rb +26 -0
- data/lib/tasks/ecm_pictures_tasks.rake +62 -0
- metadata +430 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ecm::Pictures
|
2
|
+
class AttachedPicture < ActiveRecord::Base
|
3
|
+
self.table_name = 'ecm_pictures_attached_pictures'
|
4
|
+
|
5
|
+
# associations
|
6
|
+
belongs_to :picture, :foreign_key => 'ecm_pictures_picture_id'
|
7
|
+
belongs_to :pictureable, :polymorphic => true
|
8
|
+
|
9
|
+
# attributes
|
10
|
+
attr_accessible :ecm_pictures_picture_id if respond_to?(:attr_accessible)
|
11
|
+
|
12
|
+
# validations
|
13
|
+
validates :picture, :pictureable, :presence => true
|
14
|
+
end # class AttachedPicture < ActiveRecord::Base
|
15
|
+
end# module Ecm::Pictures
|
16
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Ecm::Pictures::Picture < ActiveRecord::Base
|
2
|
+
self.table_name = 'ecm_pictures_pictures'
|
3
|
+
|
4
|
+
# associations
|
5
|
+
belongs_to :picture_gallery, :counter_cache => true
|
6
|
+
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
|
+
|
15
|
+
# acts as list
|
16
|
+
acts_as_list :scope => :picture_gallery
|
17
|
+
|
18
|
+
# acts as markup
|
19
|
+
acts_as_markup :language => :variable, :columns => [ :description, :description ]
|
20
|
+
|
21
|
+
# callbacks
|
22
|
+
after_initialize :set_defaults
|
23
|
+
before_validation :set_name_from_image_file_name, :if => Proc.new { |p| ( p.name.nil? || p.name.empty? ) }
|
24
|
+
|
25
|
+
# default scope
|
26
|
+
default_scope { order(:picture_gallery_id, :position) }
|
27
|
+
# friendly id
|
28
|
+
extend FriendlyId
|
29
|
+
friendly_id :name, :use => [:slugged, :finders]
|
30
|
+
# paperclip
|
31
|
+
has_attached_file :image, Ecm::Pictures::Configuration.paperclip_options
|
32
|
+
|
33
|
+
# validations
|
34
|
+
validates :image, :attachment_presence => true
|
35
|
+
# validates_attachment_presence :image
|
36
|
+
validates_attachment :image, content_type: { content_type: /\Aimage\/.*\Z/ }
|
37
|
+
|
38
|
+
validates :markup_language, :presence => true,
|
39
|
+
:inclusion => Ecm::Pictures::Configuration.markup_languages
|
40
|
+
validates :name, :presence => true
|
41
|
+
|
42
|
+
def display_code(style)
|
43
|
+
case style
|
44
|
+
when :erb
|
45
|
+
"<%= render_picture '#{self.name}' %>"
|
46
|
+
when :textile
|
47
|
+
"!#{image.url}!".gsub(/\?[0-9]*/, '')
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
name
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def set_defaults
|
59
|
+
if self.new_record?
|
60
|
+
self.markup_language ||= Ecm::Pictures::Configuration.default_markup_language
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_name_from_image_file_name
|
65
|
+
self.name = File.basename(image_file_name, File.extname(image_file_name)) unless image_file_name.nil?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,55 @@
|
|
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
|
+
# validations
|
33
|
+
validates :markup_language, :presence => true,
|
34
|
+
:inclusion => Ecm::Pictures::Configuration.markup_languages
|
35
|
+
validates :name, :presence => true,
|
36
|
+
:uniqueness => true
|
37
|
+
|
38
|
+
def display_code
|
39
|
+
"<%= render_picture_gallery '#{self.name}' %>"
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
name
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def set_defaults
|
49
|
+
if self.new_record?
|
50
|
+
self.link_images = true if self.link_images.nil?
|
51
|
+
self.markup_language ||= Ecm::Pictures::Configuration.default_markup_language
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<li class="<%= Ecm::Pictures::Configuration.picture_gallery_preview_li_css_classes %>">
|
2
|
+
<div class="<%= Ecm::Pictures::Configuration.picture_gallery_preview_div_css_classes %>" id="picture-gallery-<%= picture_gallery.id %>">
|
3
|
+
<% if picture_gallery.pictures.first.respond_to?(:image) %>
|
4
|
+
<div class="picture-image">
|
5
|
+
<%= image_tag picture_gallery.pictures.first.image.url(:default_thumb) %>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
<div class="caption">
|
9
|
+
<h3><%= picture_gallery.name %></h3>
|
10
|
+
<div class="description"><%= mu(picture_gallery, :description) %></div>
|
11
|
+
</div>
|
12
|
+
<div class="controls">
|
13
|
+
<%= link_to t('ecm.pictures.actions.view'), picture_gallery, :class => 'btn btn-primary' %>
|
14
|
+
<span class="pull-right small picture-count"><%= Ecm::Pictures::PictureGallery.human_attribute_name(:pictures) %>: <%= picture_gallery.pictures_count %></span>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</li>
|
@@ -0,0 +1,12 @@
|
|
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
|
+
<h3><%= picture_gallery.name %></h3>
|
8
|
+
<p><%= mu(picture_gallery, :description) %></p>
|
9
|
+
<p><%= link_to t('ecm.pictures.actions.view'), picture_gallery, :class => 'btn btn-primary', :role => 'button' %></p>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<h1><%= Ecm::Pictures::PictureGallery.model_name.human(:count => :other) %></h1>
|
2
|
+
|
3
|
+
<div class="row">
|
4
|
+
<% @picture_galleries.each do |pg| %>
|
5
|
+
<%= render :partial => 'ecm/pictures/picture_galleries/picture_gallery_for_index2', :locals => { :picture_gallery => pg } %>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h1><%= @picture_gallery.to_s %></h1>
|
2
|
+
|
3
|
+
<%= render @picture_gallery %>
|
4
|
+
|
5
|
+
<div class="actions well">
|
6
|
+
<div class="page-actions">
|
7
|
+
<div class="btn-group" role="group">
|
8
|
+
<%= link_to Ecm::Pictures::PictureGallery.model_name.human(:count => :other), ecm_pictures_picture_galleries_path, :class => 'btn btn-primary' %>
|
9
|
+
<%= link_to t('back'), :back, class: 'btn btn-default' %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<li class="<%= Ecm::Pictures::Configuration.picture_for_gallery_css_classes %>" id="picture-<%= picture.to_param %>">
|
2
|
+
<% if picture.picture_gallery.link_images %>
|
3
|
+
<%= link_to("#{picture.image.url}#{File.extname(picture.image_file_name).downcase}", :'data-gallery' => "gallery") do %>
|
4
|
+
<% image_tag(picture.image.url(:default_thumb)) %>
|
5
|
+
<% end %>
|
6
|
+
<% else %>
|
7
|
+
<%= image_tag(picture.image.url(:default_thumb), :class => 'thumbnail') %>
|
8
|
+
<% end %>
|
9
|
+
<div class="caption"><%= mu(picture, :description) %></div>
|
10
|
+
</li>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1><%= @picture.to_s %></h1>
|
2
|
+
|
3
|
+
<div class="row">
|
4
|
+
<%= render @picture %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="actions well">
|
8
|
+
<div class="page-actions">
|
9
|
+
<div class="btn-group" role="group">
|
10
|
+
<%= link_to(@picture.picture_gallery, @picture.picture_gallery, :class => 'btn btn-primary') if @picture.picture_gallery.present? %>
|
11
|
+
<%= link_to t('back'), :back, class: 'btn btn-default' %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/attached_picture:
|
5
|
+
one: Verknüpftes Bild
|
6
|
+
other: Verknüpfte Bilder
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/attached_picture:
|
9
|
+
picture: Bild
|
10
|
+
pictureable: Verknüpft mit
|
11
|
+
created_at: Erstellt am
|
12
|
+
updated_at: Aktualisiert am
|
13
|
+
routes:
|
14
|
+
ecm_pictures_pictures: verknuepfte-bilder
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/attached_picture:
|
5
|
+
one: attached picture
|
6
|
+
other: attached pictures
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/attached_picture:
|
9
|
+
picture: picture
|
10
|
+
pictureable: attached to
|
11
|
+
created_at: created at
|
12
|
+
updated_at: updated at
|
13
|
+
routes:
|
14
|
+
ecm_pictures_pictures: attached-pictures
|
15
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
de:
|
2
|
+
active_admin:
|
3
|
+
delete_link: "Verknüpfung entfernen"
|
4
|
+
back: Zurück
|
5
|
+
ecm:
|
6
|
+
pictures:
|
7
|
+
actions:
|
8
|
+
view: Anzeigen
|
9
|
+
active_admin:
|
10
|
+
menu: "Bilder"
|
11
|
+
picture:
|
12
|
+
warnings:
|
13
|
+
missing: "Das Bild %{name} wurde nicht gefunden."
|
14
|
+
picture_gallery:
|
15
|
+
warnings:
|
16
|
+
missing: "Die Galerie %{name} wurde nicht gefunden."
|
17
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
back: back
|
3
|
+
ecm:
|
4
|
+
pictures:
|
5
|
+
actions:
|
6
|
+
view: view
|
7
|
+
active_admin:
|
8
|
+
menu: pictures
|
9
|
+
picture:
|
10
|
+
warnings:
|
11
|
+
missing_gallery: "Could not find picture %{name}"
|
12
|
+
picture_gallery:
|
13
|
+
warnings:
|
14
|
+
missing_gallery: "Could not find picture gallery %{name}"
|
15
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/picture:
|
5
|
+
one: Bild
|
6
|
+
other: Bilder
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/picture:
|
9
|
+
created_at: Erstellt am
|
10
|
+
description: Beschreibung
|
11
|
+
display_code: Anzeigecode
|
12
|
+
image: Datei
|
13
|
+
image_file: Datei
|
14
|
+
image_file_name: Dateiname
|
15
|
+
image_file_size: Größe
|
16
|
+
image_fingerprint: Fingerabdruck
|
17
|
+
markup_language: Markup Sprache
|
18
|
+
name: Name
|
19
|
+
picture_gallery: Galerie
|
20
|
+
position: Position
|
21
|
+
thumbnail: Vorschau
|
22
|
+
updated_at: Aktualisiert am
|
23
|
+
routes:
|
24
|
+
ecm_pictures_pictures: bilder
|
25
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/picture:
|
5
|
+
one: picture
|
6
|
+
other: pictures
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/picture:
|
9
|
+
created_at: created at
|
10
|
+
description: description
|
11
|
+
display_code: display code
|
12
|
+
image: image
|
13
|
+
image_file: image
|
14
|
+
image_file_name: image filename
|
15
|
+
image_file_size: image size
|
16
|
+
image_fingerprint: image fingerprint
|
17
|
+
markup_language: markup language
|
18
|
+
name: name
|
19
|
+
picture_gallery: picture gallery
|
20
|
+
position: position
|
21
|
+
thumbnail: thumbnail
|
22
|
+
updated_at: updated at
|
23
|
+
routes:
|
24
|
+
ecm_pictures_pictures: pictures
|
25
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/picture_gallery:
|
5
|
+
one: Bildgalerie
|
6
|
+
other: Bildgalerien
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/picture_gallery:
|
9
|
+
created_at: Erstellt am
|
10
|
+
description: Beschreibung
|
11
|
+
display_code: Anzeigecode
|
12
|
+
link_images: Bilder verlinken
|
13
|
+
markup_language: Markup Sprache
|
14
|
+
name: Name
|
15
|
+
pictures: Bilder
|
16
|
+
pictures_count: Bilder
|
17
|
+
position: Position
|
18
|
+
updated_at: Aktualisiert am
|
19
|
+
routes:
|
20
|
+
ecm_pictures_picture_galleries: bildgalerien
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/pictures/picture_gallery:
|
5
|
+
one: picture gallery
|
6
|
+
other: picture galleries
|
7
|
+
attributes:
|
8
|
+
ecm/pictures/picture_gallery:
|
9
|
+
created_at: created at
|
10
|
+
description: description
|
11
|
+
display_code: display code
|
12
|
+
link_images: link images
|
13
|
+
markup_language: markup language
|
14
|
+
name: name
|
15
|
+
pictures: pictures
|
16
|
+
pictures_count: pictures
|
17
|
+
position: position
|
18
|
+
updated_at: updated at
|
19
|
+
routes:
|
20
|
+
ecm_pictures_picture_galleries: picture-galleries
|
21
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateEcmPicturesPictureGalleries < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_pictures_picture_galleries do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
t.boolean :link_images
|
7
|
+
|
8
|
+
# associations
|
9
|
+
t.integer :pictures_count, :default => 0, :null => false
|
10
|
+
|
11
|
+
# acts as list
|
12
|
+
t.integer :position
|
13
|
+
|
14
|
+
# acts as markup
|
15
|
+
t.string :markup_language
|
16
|
+
|
17
|
+
# friendly id
|
18
|
+
t.string :slug
|
19
|
+
|
20
|
+
t.timestamps
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|