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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 887ea98642e734bb9fc5d48fcaa288f7dc8259be
|
4
|
+
data.tar.gz: bf809ef7289221349aa8d460b7cac1f794c50708
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b03b026d97fb4d9405892d9eb57ccd07870b471456a455249362c23a6a30403292458e01e08f226530d41fa3866d5e5e2f1d36554c34805bd03514ea82fe1984
|
7
|
+
data.tar.gz: 67a5f039aa91b569a0517c5bab32313bfa1ff1d4ab8908c29a0e48de9ea594b1c36d7f40fd0c2a4c659cc5bfe09bed9b66724c28077217f18410d8d9fc0de834
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Roberto Vasquez Angel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
= Ecm::Pictures 2
|
2
|
+
|
3
|
+
= Purpose
|
4
|
+
|
5
|
+
Create and administrate picture galleries in active admin and display them on
|
6
|
+
in your ruby on rails applictation. Orangebox is used for lightbox support.
|
7
|
+
|
8
|
+
# Prerequisites
|
9
|
+
|
10
|
+
* Ruby on Rails 4.x
|
11
|
+
* Twitter Bootstrap 3
|
12
|
+
|
13
|
+
= Features
|
14
|
+
|
15
|
+
* Drop in module for active admin.
|
16
|
+
* Render a gallery with one method call in your views.
|
17
|
+
* Lightbox support.
|
18
|
+
* Picture and Gallery sorting.
|
19
|
+
|
20
|
+
|
21
|
+
= Installation
|
22
|
+
|
23
|
+
|
24
|
+
Add it to your gemfile:
|
25
|
+
|
26
|
+
# Gemfile
|
27
|
+
gem 'ecm_pictures2'
|
28
|
+
|
29
|
+
Install your bundle:
|
30
|
+
|
31
|
+
> bundle install
|
32
|
+
|
33
|
+
Generate initializer:
|
34
|
+
|
35
|
+
> rails generate ecm:pictures:install
|
36
|
+
|
37
|
+
Add the routes to your config/routes.rb:
|
38
|
+
|
39
|
+
Rails.application.routes.draw do
|
40
|
+
.
|
41
|
+
.
|
42
|
+
.
|
43
|
+
Ecm::Pictures::Routing.routes(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
Generate the migrations:
|
47
|
+
|
48
|
+
> rake ecm_pictures_engine:install:migrations
|
49
|
+
|
50
|
+
Migrate:
|
51
|
+
|
52
|
+
> rake db:migrate
|
53
|
+
|
54
|
+
|
55
|
+
== Optional: Generate locale files
|
56
|
+
|
57
|
+
You may want to copy the locales to your app:
|
58
|
+
|
59
|
+
> rails generate ecm:pictures:locales
|
60
|
+
|
61
|
+
= Usage
|
62
|
+
|
63
|
+
You can administrate your pictures and picture galleries in active admin.
|
64
|
+
|
65
|
+
Once you have a gallery, you can display it like this:
|
66
|
+
|
67
|
+
<%= render_picture_gallery 'Holidays 2012' %>
|
68
|
+
|
69
|
+
= Todo
|
70
|
+
|
71
|
+
* Tests, tests, tests.
|
72
|
+
* Better docs.
|
73
|
+
* Render picture helpers.
|
74
|
+
* Add a published flag to galleries and pictures.
|
75
|
+
|
76
|
+
= License
|
77
|
+
|
78
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EcmPictureGallery'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rails/dummy/tasks'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
include ActiveAdmin::ActsAsList::Helper if defined?(::ActiveAdmin)
|
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 defined?(::ActiveAdmin)
|
111
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
include ActiveAdmin::ActsAsList::Helper if defined?(::ActiveAdmin)
|
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 defined?(::ActiveAdmin)
|
98
|
+
|
@@ -0,0 +1,11 @@
|
|
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
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Ecm::PicturesHelper
|
2
|
+
# renders picture galleries in your views
|
3
|
+
#
|
4
|
+
# = Usage
|
5
|
+
#
|
6
|
+
# Assume you have created a picture gallery named "Holidays 2012". You can
|
7
|
+
# render it in your view as follows:
|
8
|
+
#
|
9
|
+
# <%= render_picture_gallery 'Holidays 2012' %>
|
10
|
+
def render_picture_gallery(name, options = {})
|
11
|
+
begin
|
12
|
+
options = {:preview_style => :thumb}.merge(options)
|
13
|
+
|
14
|
+
gallery = Ecm::Pictures::PictureGallery.where(:name => name.to_s).first
|
15
|
+
gallery_identifier = gallery.to_param rescue 'missing'
|
16
|
+
|
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
|
23
|
+
end
|
24
|
+
|
25
|
+
rescue Exception => e
|
26
|
+
return e.message
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# helper method to build link options for images inside a gallery.
|
31
|
+
def build_link_options_for_picture_in_gallery(gallery_identifier, picture)
|
32
|
+
link_options = {}
|
33
|
+
|
34
|
+
# Add gallery identifier for orange box
|
35
|
+
link_options[:rel] = "lightbox[#{gallery_identifier}]"
|
36
|
+
|
37
|
+
# Add thumbnail class for twitter bootstrap
|
38
|
+
link_options[:class] = "thumbnail"
|
39
|
+
|
40
|
+
# build the caption
|
41
|
+
caption = ""
|
42
|
+
caption << "<div class=\"caption-name\">#{picture.name}</div>" unless picture.name.blank?
|
43
|
+
caption << "<div class=\"caption-description\">#{picture.description}</div>" unless picture.description.blank?
|
44
|
+
link_options[:"data-ob_caption"] = caption if caption.size > 0
|
45
|
+
|
46
|
+
return link_options
|
47
|
+
end
|
48
|
+
|
49
|
+
# TODO: Implement this.
|
50
|
+
def render_picture(name, options = {})
|
51
|
+
begin
|
52
|
+
options = {:preview_style => :thumb}.merge(options)
|
53
|
+
|
54
|
+
picture = Ecm::Pictures::Picture.where(:name => name.to_s).first
|
55
|
+
# gallery_identifier = gallery.to_param rescue 'missing'
|
56
|
+
|
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))
|
60
|
+
end
|
61
|
+
else
|
62
|
+
content_tag(:div, :class => 'row') do
|
63
|
+
render picture
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
rescue Exception => e
|
68
|
+
return e.message
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|