avatars_for_rails 0.0.7 → 0.0.8
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.
- data/Gemfile.lock +1 -1
- data/app/controllers/avatars_controller.rb +14 -28
- data/app/models/avatar.rb +11 -16
- data/app/views/avatars/_new.html.erb +0 -10
- data/avatars_for_rails.gemspec +1 -1
- data/lib/avatars_for_rails.rb +1 -0
- data/lib/generators/avatars_for_rails/templates/initializer.rb +1 -0
- data/spec/dummy/config/initializers/avatars_for_rails.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,26 +1,24 @@
|
|
1
|
-
#class AvatarsController < InheritedResources::Base
|
2
1
|
class AvatarsController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :apply_existing_filters
|
4
|
+
|
3
5
|
def index
|
4
|
-
#@avatars = Avatar.all
|
5
|
-
#@avatars = Avatar.where({(AvatarsForRails.avatarable_model.to_s + "_id").to_sym => current_avatarable_object.id})
|
6
6
|
@avatars = current_avatarable_object.avatars
|
7
7
|
|
8
8
|
respond_to do |format|
|
9
9
|
format.html # index.html.erb
|
10
|
-
#format.xml { render :xml => @gastos }
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
13
|
def new
|
15
14
|
@avatars = Avatar.all
|
16
15
|
@avatar = Avatar.create(params[:avatar])
|
17
|
-
|
16
|
+
|
18
17
|
if params[:drag_name].blank?
|
19
18
|
respond_to do |format|
|
20
19
|
format.html # new.html.erb
|
21
20
|
end
|
22
21
|
else
|
23
|
-
#debugger
|
24
22
|
if Avatar.check_image_tmp_valid(params[:drag_name].to_s)
|
25
23
|
render :partial => 'precrop'
|
26
24
|
else
|
@@ -32,7 +30,7 @@ class AvatarsController < ApplicationController
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def update
|
35
|
-
|
33
|
+
|
36
34
|
if !current_avatarable_object.avatars.blank?
|
37
35
|
|
38
36
|
new_logo = Avatar.find(params[:id])
|
@@ -56,38 +54,22 @@ class AvatarsController < ApplicationController
|
|
56
54
|
respond_to do |format|
|
57
55
|
format.js { render :layout=>false , :locals=>{:new_id => params[:id],:old_id => old_logo_id}}
|
58
56
|
end
|
59
|
-
|
57
|
+
|
60
58
|
end
|
61
59
|
end
|
62
|
-
|
63
|
-
# redirect_to avatars_path
|
64
60
|
end
|
65
61
|
|
66
62
|
def create
|
67
63
|
@avatar = current_avatarable_object.avatars.create(params[:avatar])
|
68
|
-
|
64
|
+
|
69
65
|
if @avatar.new_record?
|
70
|
-
#debugger
|
71
66
|
if (params[:avatar].blank? || params[:avatar][:drag].nil?)
|
72
67
|
render :new, :layout => false
|
73
68
|
else
|
74
69
|
render :json => {:name => File.basename(@avatar.logo.queued_for_write[:original].path) }
|
75
70
|
end
|
76
71
|
else
|
77
|
-
#debugger
|
78
|
-
#@avatar.updating_logo = true
|
79
|
-
#@avatar.avatarable.id = current_avatarable_object.id
|
80
|
-
# unless current_avatarable_object.avatars.blank?
|
81
|
-
# current_avatarable_object.avatars.each do |old_logo|
|
82
|
-
# old_logo.active = false
|
83
|
-
# old_logo.save
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
#debugger
|
87
|
-
#@avatar.active = true
|
88
|
-
#@avatar.save
|
89
72
|
redirect_to avatars_path
|
90
|
-
|
91
73
|
end
|
92
74
|
end
|
93
75
|
|
@@ -100,12 +82,16 @@ class AvatarsController < ApplicationController
|
|
100
82
|
format.js { render :layout=>false , :locals=>{:deleted_id => params[:id]}}
|
101
83
|
end
|
102
84
|
end
|
103
|
-
#redirect_to avatars_path
|
104
85
|
end
|
105
86
|
|
106
87
|
def current_avatarable_object
|
107
88
|
__send__ AvatarsForRails.current_avatarable_object
|
108
|
-
#return Actor.find(:all).first
|
109
89
|
end
|
110
|
-
|
90
|
+
|
91
|
+
def apply_existing_filters
|
92
|
+
AvatarsForRails.avatarable_filters.each do |filter|
|
93
|
+
__send__ filter
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
111
97
|
end
|
data/app/models/avatar.rb
CHANGED
@@ -17,27 +17,22 @@ class Avatar < ActiveRecord::Base
|
|
17
17
|
belongs_to AvatarsForRails.avatarable_model
|
18
18
|
|
19
19
|
scope :active, where(:active => true)
|
20
|
-
|
20
|
+
|
21
21
|
before_create :make_active
|
22
22
|
after_create :disable_old
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def make_active
|
24
|
+
self.updating_logo = true
|
25
|
+
self.active = true
|
26
|
+
end
|
27
|
+
|
29
28
|
def disable_old
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
#end
|
29
|
+
self.avatarable.avatars.where("id != ?", self.id).each do |old_logo|
|
30
|
+
old_logo.update_attribute :active, false
|
31
|
+
end
|
35
32
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
|
39
34
|
def avatarable
|
40
|
-
__send__ AvatarsForRails.avatarable_model
|
35
|
+
__send__ AvatarsForRails.avatarable_model
|
41
36
|
end
|
42
37
|
|
43
38
|
def uploading_file?
|
@@ -1,17 +1,7 @@
|
|
1
1
|
<% if !@avatar.logo.errors['precrop'].blank? %>
|
2
|
-
<!--<h2><%= t('avatar.crop_image') %></h2>
|
3
|
-
<br class="clearfloat" />
|
4
|
-
<div class="space_center"></div>
|
5
|
-
-->
|
6
2
|
<%= render :partial => 'precrop' %>
|
7
3
|
<% elsif !@avatar.errors.blank? %>
|
8
4
|
<%= render :partial => 'errors' %>
|
9
5
|
<% else %>
|
10
|
-
<!-- <br class="clearfloat" />
|
11
|
-
<div class="space_center"></div>
|
12
|
-
<div class="space_center"></div>
|
13
|
-
<div id="content_logo">
|
14
|
-
<%= render :partial => 'form' %>
|
15
|
-
-->
|
16
6
|
<% end %>
|
17
7
|
|
data/avatars_for_rails.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# project in your rails apps through git.
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "avatars_for_rails"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.8"
|
6
6
|
s.authors = ["Jaime Castro Montero"]
|
7
7
|
s.summary = "Avatar manager for rails apps."
|
8
8
|
s.description = "A Rails engine that allows any model to act as avatarable, permitting it to have a complete avatar manager with a few options."
|
data/lib/avatars_for_rails.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avatars_for_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jaime Castro Montero
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: foreigner
|