qtousart-sortable_pictures 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -0
- data/README +42 -0
- data/init.rb +1 -0
- data/lib/picture.rb +9 -0
- data/lib/sortable_picture.rb +4 -0
- data/lib/sortable_pictures.rb +19 -0
- data/lib/tasks/update_thumbnails.rake +15 -0
- data/sortable_pictures.gemspec +45 -0
- metadata +90 -0
data/LICENSE
ADDED
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
sortable_pictures
|
2
|
+
|
3
|
+
You can manage & sort pictures
|
4
|
+
|
5
|
+
== Model
|
6
|
+
class Model < ActiveRecord::Base
|
7
|
+
sortable_pictures
|
8
|
+
end
|
9
|
+
|
10
|
+
== Controller
|
11
|
+
def create
|
12
|
+
@model = Model.find params[:id]
|
13
|
+
picture = Picture.new params[:picture]
|
14
|
+
if picture.save
|
15
|
+
sortable_pictures = picture.sortable_pictures.new
|
16
|
+
sortable_picture.picturable = @model
|
17
|
+
sortable_picture.save
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
== View
|
22
|
+
<% @model.pictures.each do |picture| %>
|
23
|
+
<%= image_tag(picture.public_filename :thumb) %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
== initializers
|
27
|
+
in RAILS_ROOT + config/initializers/sortable_pictures.rb
|
28
|
+
|
29
|
+
module SortablePictures
|
30
|
+
def self.options
|
31
|
+
{ :storage => :file_system,
|
32
|
+
:file_system_path => 'public/images/sortable_pictures',
|
33
|
+
:content_type => 'image',
|
34
|
+
:thumbnails => {
|
35
|
+
:big => '500x500',
|
36
|
+
:normal => '200x200',
|
37
|
+
:small => '100x100',
|
38
|
+
:thumb => '50x50'
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'sortable_pictures'
|
data/lib/picture.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#SortablePictures
|
2
|
+
module Webpulser
|
3
|
+
module SortablePictures #:nodoc:
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def sortable_pictures
|
11
|
+
has_many :sortable_pictures, :dependent => :destroy, :order => 'position', :as => :picturable
|
12
|
+
has_many :pictures, :through => :sortable_pictures, :readonly => true, :order => 'sortable_pictures.position'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveRecord::Base.send(:include, Webpulser::SortablePictures)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :sortable_pictures do
|
2
|
+
desc 'update pictures from modified or added thumbnails formats'
|
3
|
+
task :update_thumbnails => :environment do
|
4
|
+
Picture.find_all_by_parent_id(nil).each do |picture|
|
5
|
+
puts "Fixing #{picture.filename}"
|
6
|
+
temp_file = picture.create_temp_file
|
7
|
+
|
8
|
+
picture.attachment_options[:thumbnails].each { |suffix, size|
|
9
|
+
picture.create_or_update_thumbnail(temp_file, suffix, *size)
|
10
|
+
puts " #{suffix}"
|
11
|
+
}
|
12
|
+
sleep 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{sortable_pictures}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Cyril LEPAGNOT"]
|
9
|
+
s.date = %q{2009-05-11}
|
10
|
+
s.description = %q{With sortables pictures Rails plugin you can have pictures with tags, comments and ordering.}
|
11
|
+
s.email = %q{cyril.lepagnot@webpulser.com}
|
12
|
+
s.files = ["LICENSE",
|
13
|
+
"README",
|
14
|
+
"sortable_pictures.gemspec",
|
15
|
+
"init.rb",
|
16
|
+
"lib/sortable_pictures.rb",
|
17
|
+
"lib/picture.rb",
|
18
|
+
"lib/sortable_picture.rb",
|
19
|
+
"lib/tasks/update_thumbnails.rake"]
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.homepage = "http://github.com/qtousart/sortable_pictures"
|
22
|
+
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
23
|
+
s.rubyforge_project = %q{sortable_pictures}
|
24
|
+
s.rubygems_version = %q{1.3.0}
|
25
|
+
s.summary = %q{Polymorphic and sortables pictures Rails plugin.}
|
26
|
+
|
27
|
+
if s.respond_to? :specification_version then
|
28
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
29
|
+
s.specification_version = 2
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
|
+
s.add_runtime_dependency(%q<mime-types>, [">= 1.15"])
|
33
|
+
s.add_runtime_dependency(%q<mbleigh-acts-as-taggable-on>, [">= 1.0.5"])
|
34
|
+
s.add_runtime_dependency(%q<jimiray-acts_as_commentable>, [">= 1.0.0"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<mime-types>, [">= 1.15"])
|
37
|
+
s.add_dependency(%q<mbleigh-acts-as-taggable-on>, [">= 1.0.5"])
|
38
|
+
s.add_dependency(%q<jimiray-acts_as_commentable>, [">= 1.0.0"])
|
39
|
+
end
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<mime-types>, [">= 1.15"])
|
42
|
+
s.add_dependency(%q<mbleigh-acts-as-taggable-on>, [">= 1.0.5"])
|
43
|
+
s.add_dependency(%q<jimiray-acts_as_commentable>, [">= 1.0.0"])
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qtousart-sortable_pictures
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cyril LEPAGNOT
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-11 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mime-types
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.15"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mbleigh-acts-as-taggable-on
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.5
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jimiray-acts_as_commentable
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0
|
44
|
+
version:
|
45
|
+
description: With sortables pictures Rails plugin you can have pictures with tags, comments and ordering.
|
46
|
+
email: cyril.lepagnot@webpulser.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
files:
|
54
|
+
- LICENSE
|
55
|
+
- README
|
56
|
+
- sortable_pictures.gemspec
|
57
|
+
- init.rb
|
58
|
+
- lib/sortable_pictures.rb
|
59
|
+
- lib/picture.rb
|
60
|
+
- lib/sortable_picture.rb
|
61
|
+
- lib/tasks/update_thumbnails.rake
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://github.com/qtousart/sortable_pictures
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --inline-source
|
67
|
+
- --charset=UTF-8
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: sortable_pictures
|
85
|
+
rubygems_version: 1.2.0
|
86
|
+
signing_key:
|
87
|
+
specification_version: 2
|
88
|
+
summary: Polymorphic and sortables pictures Rails plugin.
|
89
|
+
test_files: []
|
90
|
+
|