webpulser-sortable_pictures 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,2 @@
1
+ RailsCommerce comes with two licenses: the LGPL (see COPYING.LESSER)
2
+ and the GPL (see COPYING) ones.
data/README.textile ADDED
@@ -0,0 +1,57 @@
1
+ h1. Sortable pictures
2
+
3
+ You can manage & sort pictures
4
+
5
+ h1. How to use ?
6
+
7
+ h2. Model
8
+
9
+ <pre>
10
+ <code>
11
+ class Model < ActiveRecord::Base
12
+ sortable_pictures
13
+ end
14
+ </code>
15
+ </pre>
16
+
17
+ h2. Controller
18
+
19
+ <pre>
20
+ <code>
21
+ def create
22
+ @model = Model.find params[:id]
23
+ picture = Picture.new params[:picture]
24
+ if picture.save
25
+ sortable_pictures = picture.sortable_pictures.new
26
+ sortable_picture.picturable = @model
27
+ sortable_picture.save
28
+ end
29
+ end
30
+ </code>
31
+ </pre>
32
+
33
+ h2. View
34
+
35
+ <pre>
36
+ <code>
37
+ <% @model.pictures.each do |picture| %>
38
+ <%= image_tag(picture.public_filename :thumb) %>
39
+ <% end %>
40
+ </code>
41
+ </pre>
42
+
43
+ h1. Configuration file
44
+
45
+ in RAILS_ROOT + config/sortable_pictures.yml
46
+ <pre>
47
+ <code>
48
+ storage: :file_system
49
+ file_system_path: 'public/images/sortable_pictures'
50
+ content_type: 'image'
51
+ thumbnails:
52
+ :big: '500x500',
53
+ :normal: '200x200'
54
+ :small: '100x100'
55
+ :thumb: '50x50'
56
+ </code>
57
+ </pre>
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'sortable_pictures'
data/lib/picture.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Picture < ActiveRecord::Base
2
+
3
+ acts_as_commentable
4
+ acts_as_taggable
5
+ has_attachment YAML.load_file(File.join(RAILS_ROOT, 'config', 'sortable_pictures.yml')).symbolize_keys
6
+ validates_presence_of :content_type
7
+
8
+ has_many :sortable_pictures, :dependent => :destroy
9
+ end
@@ -0,0 +1,4 @@
1
+ class SortablePicture < ActiveRecord::Base
2
+ belongs_to :picture
3
+ belongs_to :picturable, :polymorphic => true
4
+ end
@@ -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
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webpulser-sortable_pictures
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.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.textile
56
+ - init.rb
57
+ - lib/sortable_pictures.rb
58
+ - lib/picture.rb
59
+ - lib/sortable_picture.rb
60
+ - lib/tasks/update_thumbnails.rake
61
+ has_rdoc: true
62
+ homepage: http://github.com/webpulser/sortable_pictures
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --inline-source
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: sortable_pictures
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: Polymorphic and sortables pictures Rails plugin.
88
+ test_files: []
89
+