social_stream 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/Rakefile +0 -12
  2. data/app/controllers/activities_controller.rb +17 -1
  3. data/app/controllers/api_controller.rb +2 -2
  4. data/app/controllers/avatars_controller.rb +44 -0
  5. data/app/controllers/contacts_controller.rb +13 -21
  6. data/app/controllers/conversations_controller.rb +107 -0
  7. data/app/controllers/groups_controller.rb +7 -11
  8. data/app/controllers/messages_controller.rb +21 -88
  9. data/app/controllers/profiles_controller.rb +3 -1
  10. data/app/controllers/pshb_controller.rb +37 -1
  11. data/app/controllers/ties_controller.rb +7 -8
  12. data/app/controllers/users_controller.rb +19 -43
  13. data/app/helpers/location_helper.rb +34 -0
  14. data/app/helpers/subjects_helper.rb +18 -1
  15. data/app/models/activity.rb +67 -27
  16. data/app/models/activity_verb.rb +1 -1
  17. data/app/models/actor.rb +85 -37
  18. data/app/models/avatar.rb +90 -0
  19. data/app/models/group.rb +2 -2
  20. data/app/models/profile.rb +8 -0
  21. data/app/models/tie.rb +20 -22
  22. data/app/models/user.rb +2 -8
  23. data/app/views/activities/_index.html.erb +22 -0
  24. data/app/views/activities/_options.html.erb +3 -1
  25. data/app/views/activities/_root.html.erb +4 -2
  26. data/app/views/activities/_walls.html.erb +34 -0
  27. data/app/views/activities/index.js.erb +1 -0
  28. data/app/views/avatars/_form.html.erb +23 -0
  29. data/app/views/{logos → avatars}/_precrop.html.erb +23 -15
  30. data/app/views/avatars/edit.html.erb +6 -0
  31. data/app/views/avatars/index.html.erb +42 -0
  32. data/app/views/{logos → avatars}/new.html.erb +7 -11
  33. data/app/views/avatars/show.html.erb +5 -0
  34. data/app/views/contacts/_index.html.erb +33 -0
  35. data/app/views/contacts/index.html.erb +35 -2
  36. data/app/views/contacts/index.js.erb +1 -0
  37. data/app/views/conversations/_conversation.html.erb +37 -0
  38. data/app/views/conversations/_conversation_full.html.erb +52 -0
  39. data/app/views/{messages → conversations}/_conversations.html.erb +2 -1
  40. data/app/views/conversations/_index.html.erb +23 -0
  41. data/app/views/{messages → conversations}/_menu_options.html.erb +2 -2
  42. data/app/views/conversations/_show.html.erb +21 -0
  43. data/app/views/{messages → conversations}/edit.html.erb +0 -0
  44. data/app/views/{messages → conversations}/index.html.erb +1 -3
  45. data/app/views/conversations/index.js.erb +7 -0
  46. data/app/views/conversations/show.html.erb +47 -0
  47. data/app/views/conversations/show.js.erb +39 -0
  48. data/app/views/frontpage/_header.html.erb +5 -1
  49. data/app/views/groups/_new.html.erb +50 -48
  50. data/app/views/groups/_sidebar_show.html.erb +1 -1
  51. data/app/views/groups/index.html.erb +1 -1
  52. data/app/views/groups/new.html.erb +6 -1
  53. data/app/views/groups/show.html.erb +1 -3
  54. data/app/views/home/_menu.html.erb +46 -0
  55. data/app/views/home/_sidebar.html.erb +12 -0
  56. data/app/views/home/index.html.erb +3 -3
  57. data/app/views/layouts/application.html.erb +1 -1
  58. data/app/views/layouts/test.html +58 -41
  59. data/app/views/location/_location.html.erb +3 -0
  60. data/app/views/messages/_form.html.erb +5 -52
  61. data/app/views/messages/_message.html.erb +31 -0
  62. data/app/views/messages/_new.html.erb +10 -16
  63. data/app/views/messages/new.html.erb +48 -3
  64. data/app/views/messages/new.js.erb +38 -1
  65. data/app/views/profiles/_profile.html.erb +194 -0
  66. data/app/views/profiles/edit.html.erb +168 -0
  67. data/app/views/profiles/show.html.erb +2 -175
  68. data/app/views/{users → profiles}/update.js.erb +12 -15
  69. data/app/views/subjects/_contacts.html.erb +2 -3
  70. data/app/views/subjects/_toolbar_home.html.erb +1 -1
  71. data/app/views/subjects/_toolbar_home_menu.html.erb +4 -1
  72. data/app/views/subjects/_toolbar_home_menu_options.html.erb +4 -7
  73. data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +0 -3
  74. data/app/views/subjects/_toolbar_logo.html.erb +1 -1
  75. data/app/views/subjects/_toolbar_message_menu.html.erb +17 -0
  76. data/app/views/subjects/_toolbar_profile.html.erb +4 -12
  77. data/app/views/subjects/_toolbar_profile_menu.html.erb +9 -10
  78. data/app/views/subjects/_toolbar_profile_menu_basic_options.html.erb +6 -5
  79. data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +13 -13
  80. data/app/views/ties/_new.html.erb +30 -25
  81. data/app/views/ties/_suggestions.html.erb +1 -0
  82. data/app/views/ties/new.js.erb +2 -0
  83. data/app/views/users/_index.html.erb +1 -1
  84. data/app/views/users/index.html.erb +1 -3
  85. data/app/views/users/show.html.erb +4 -3
  86. data/config/locales/en.yml +79 -24
  87. data/config/routes.rb +8 -2
  88. data/lib/generators/social_stream/install_generator.rb +1 -1
  89. data/lib/generators/social_stream/templates/migration.rb +17 -11
  90. data/lib/generators/social_stream/templates/public/images/btn/message_conversation.png +0 -0
  91. data/lib/generators/social_stream/templates/public/images/btn/message_inbox.png +0 -0
  92. data/lib/generators/social_stream/templates/public/images/btn/message_new.png +0 -0
  93. data/lib/generators/social_stream/templates/public/images/btn/message_sentbox.png +0 -0
  94. data/lib/generators/social_stream/templates/public/images/btn/message_trash.png +0 -0
  95. data/lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js +1 -1
  96. data/lib/generators/social_stream/templates/public/javascripts/menu.js +9 -99
  97. data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +14 -5
  98. data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -0
  99. data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +13 -10
  100. data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +5 -11
  101. data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +96 -20
  102. data/lib/generators/social_stream/templates/relations.yml +1 -0
  103. data/lib/paperclip/social_stream.rb +1 -1
  104. data/lib/social_stream/ability.rb +1 -0
  105. data/lib/social_stream/controllers/helpers.rb +20 -0
  106. data/lib/social_stream/models/subject.rb +13 -12
  107. data/lib/social_stream/rails.rb +4 -1
  108. data/lib/social_stream/version.rb +1 -1
  109. data/lib/tasks/db/populate.rake +14 -4
  110. data/social_stream.gemspec +31 -5
  111. data/spec/controllers/contacts_controller_spec.rb +6 -0
  112. data/spec/controllers/profiles_controller_spec.rb +3 -4
  113. data/spec/dummy/config/initializers/devise.rb +4 -1
  114. data/spec/dummy/config/relations.yml +1 -0
  115. data/spec/models/activity_spec.rb +24 -0
  116. metadata +91 -89
  117. data/app/controllers/logos_controller.rb +0 -37
  118. data/app/models/logo.rb +0 -88
  119. data/app/views/activities/_activities.html.erb +0 -46
  120. data/app/views/groups/_profile.html.erb +0 -142
  121. data/app/views/groups/edit.html.erb +0 -135
  122. data/app/views/groups/update.js.erb +0 -39
  123. data/app/views/logos/_form.html.erb +0 -33
  124. data/app/views/logos/edit.html.erb +0 -6
  125. data/app/views/logos/index.html.erb +0 -27
  126. data/app/views/logos/show.html.erb +0 -5
  127. data/app/views/menu/_group.html.erb +0 -15
  128. data/app/views/menu/_home_user.html.erb +0 -0
  129. data/app/views/menu/_optionsGroups.html.erb +0 -11
  130. data/app/views/menu/_optionsUser.html.erb +0 -11
  131. data/app/views/menu/_services.html.erb +0 -11
  132. data/app/views/menu/_tiesGroup.html.erb +0 -14
  133. data/app/views/menu/_tiesUser.html.erb +0 -11
  134. data/app/views/menu/_user.html.erb +0 -15
  135. data/app/views/messages/_conversation.html.erb +0 -34
  136. data/app/views/messages/_conversation_full.html.erb +0 -65
  137. data/app/views/messages/_index.html.erb +0 -19
  138. data/app/views/messages/_location.html.erb +0 -3
  139. data/app/views/messages/_show.html.erb +0 -22
  140. data/app/views/messages/index.js.erb +0 -1
  141. data/app/views/messages/show.html.erb +0 -10
  142. data/app/views/messages/show.js.erb +0 -1
  143. data/app/views/users/_profile.html.erb +0 -171
  144. data/app/views/users/_sidebar_show.html.erb +0 -1
  145. data/app/views/users/edit.html.erb +0 -194
@@ -0,0 +1,90 @@
1
+ require 'RMagick'
2
+
3
+ class Avatar < ActiveRecord::Base
4
+ has_attached_file :logo,
5
+ :styles => { :tie => "30x30>",
6
+ :actor => '35x35>',
7
+ :profile => '94x94' },
8
+ :default_url => "/images/logos/:style/:subtype_class.png"
9
+
10
+ before_post_process :process_precrop
11
+ attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :name,:updating_logo
12
+ validates_attachment_presence :logo, :if => :uploading_file?, :message => I18n.t('avatar.error.no_file')
13
+
14
+ after_validation :precrop_done
15
+
16
+ belongs_to :actor
17
+
18
+ scope :active, where(:active => true)
19
+
20
+ def uploading_file?
21
+ return @name.blank?
22
+ end
23
+
24
+ def precrop_done
25
+ return if @name.blank? || !@updating_logo.blank?
26
+
27
+ precrop_path = File.join(Avatar.images_tmp_path,@name)
28
+
29
+ make_precrop(precrop_path,@crop_x.to_i,@crop_y.to_i,@crop_w.to_i,@crop_h.to_i)
30
+ @avatar = Avatar.new :logo => File.open(precrop_path), :name => @name
31
+
32
+
33
+ self.logo = @avatar.logo
34
+
35
+ FileUtils.remove_file(precrop_path)
36
+ end
37
+
38
+ def self.images_tmp_path
39
+ images_path = File.join(RAILS_ROOT, "public", "images")
40
+ tmp_path = FileUtils.mkdir_p(File.join(images_path, "tmp"))
41
+ end
42
+
43
+ def self.copy_to_temp_file(path)
44
+ FileUtils.cp(path,Avatar.images_tmp_path)
45
+ end
46
+
47
+
48
+ def self.get_image_dimensions(name)
49
+ img_orig = Magick::Image.read(name).first
50
+ dimensions = {}
51
+ dimensions[:width] = img_orig.columns
52
+ dimensions[:height] = img_orig.rows
53
+ dimensions
54
+ end
55
+
56
+ def process_precrop
57
+
58
+ if @name.blank? && ( logo.content_type.present? && !logo.content_type.start_with?("image/"))
59
+ logo.errors['invalidType'] = I18n.t('avatar.error.no_image_file')
60
+ return false
61
+ end
62
+
63
+ return if !@name.blank?
64
+ logo.errors['precrop'] = "You have to make precrop"
65
+ resize_image(logo.queued_for_write[:original].path,500,500)
66
+ Avatar.copy_to_temp_file(logo.queued_for_write[:original].path)
67
+ end
68
+
69
+ def resize_image(path,width,height)
70
+ img_orig = Magick::Image.read(path).first
71
+ img_orig = img_orig.resize_to_fit(width, height)
72
+ img_orig.write(path)
73
+ end
74
+
75
+ def make_precrop(path,x,y,width,height)
76
+ img_orig = Magick::Image.read(path).first
77
+ dimensions = Avatar.get_image_dimensions(path)
78
+
79
+ unless (width == 0) || (height == 0)
80
+ crop_args = [x,y,width,height]
81
+ img_orig = img_orig.crop(*crop_args)
82
+ end
83
+
84
+ img_orig = img_orig.resize_to_fill(500,500)
85
+
86
+
87
+ img_orig.write(path)
88
+ end
89
+ end
90
+
data/app/models/group.rb CHANGED
@@ -12,11 +12,11 @@ class Group < ActiveRecord::Base
12
12
  end
13
13
 
14
14
  def followers
15
- subjects(:subject_type => :user, :direction => :senders)
15
+ contacts(:subject_type => :user, :direction => :received)
16
16
  end
17
17
 
18
18
  def recent_groups
19
- subjects(:subject_type => :group, :direction => :receivers) do |q|
19
+ contacts(:type => :group, :direction => :sent) do |q|
20
20
  q.select("ties.created_at").
21
21
  merge(Tie.recent)
22
22
  end
@@ -1,6 +1,8 @@
1
1
  class Profile < ActiveRecord::Base
2
2
  belongs_to :actor
3
3
 
4
+ accepts_nested_attributes_for :actor
5
+
4
6
  validates_presence_of :actor_id
5
7
 
6
8
  validates_format_of :mobile, :phone, :fax,
@@ -29,6 +31,12 @@ class Profile < ActiveRecord::Base
29
31
  end
30
32
  end
31
33
 
34
+ def age
35
+ return nil if self.birthday.blank?
36
+ now = Time.now.utc.to_date
37
+ now.year - self.birthday.year - (self.birthday.to_date.change(:year => now.year) > now ? 1 : 0)
38
+ end
39
+
32
40
  # The subject of this profile
33
41
  def subject
34
42
  actor.try(:subject)
data/app/models/tie.rb CHANGED
@@ -81,7 +81,9 @@ class Tie < ActiveRecord::Base
81
81
  }
82
82
 
83
83
  scope :related_by, lambda { |r|
84
- where(:relation_id => Relation.normalize_id(r))
84
+ if r.present?
85
+ where(:relation_id => Relation.normalize_id(r))
86
+ end
85
87
  }
86
88
 
87
89
  scope :replied, lambda {
@@ -100,7 +102,7 @@ class Tie < ActiveRecord::Base
100
102
  before_validation :find_relation
101
103
 
102
104
  after_create :complete_weak_set
103
- after_create :create_activity_after_add_contact
105
+ after_create :create_activity
104
106
  after_create :send_message
105
107
 
106
108
  def relation_name
@@ -125,6 +127,11 @@ class Tie < ActiveRecord::Base
125
127
  sender_id == receiver_id
126
128
  end
127
129
 
130
+ # Is there any tie from receiver to sender?
131
+ def replied?
132
+ receiver.ties_to?(sender)
133
+ end
134
+
128
135
  # The set of ties between sender and receiver
129
136
  #
130
137
  # Options::
@@ -252,29 +259,20 @@ class Tie < ActiveRecord::Base
252
259
  end
253
260
  end
254
261
 
255
-
256
- def create_activity_after_add_contact
257
- if self.original
258
- p = Post.create :text =>
259
- (I18n.t "tie.activity.add_contact", :active=>self.sender.name , :pasive=>self.receiver.name),
260
- :_activity_tie_id => self.id
261
- end
262
+ def create_activity
263
+ return if ! original? || reflexive?
264
+
265
+ Activity.create! :_tie => self, :activity_verb => ActivityVerb[contact_verb]
262
266
  end
263
-
264
-
265
- # Values of "receiver.subject_type": "User", "Group"
267
+
268
+ # Send a message to the receiver of the tie
266
269
  def send_message
267
- if self.original
268
- if((message!=nil)&&(message!="")&&(receiver.subject_type=="User"))
269
- sender.send_message(receiver, get_private_message(message))
270
- end
270
+ if original? && message.present?
271
+ sender.send_message(receiver, message, I18n.t("activity.verb.#{ contact_verb }.message", :name => sender.name))
271
272
  end
272
273
  end
273
-
274
-
275
- def get_private_message(message)
276
- return (I18n.t "tie.private_messages.add_contact", :name=>sender.name) + ".\n" + message
274
+
275
+ def contact_verb
276
+ replied? ? "make-friend" : "follow"
277
277
  end
278
-
279
-
280
278
  end
data/app/models/user.rb CHANGED
@@ -18,14 +18,8 @@ class User < ActiveRecord::Base
18
18
  v.validates_length_of :password, :within => Devise.password_length, :allow_blank => true
19
19
  end
20
20
 
21
- def age
22
- return nil if profile.birthday.blank?
23
- now = Time.now.utc.to_date
24
- now.year - profile.birthday.year - (profile.birthday.to_date.change(:year => now.year) > now ? 1 : 0)
25
- end
26
-
27
21
  def recent_groups
28
- subjects(:subject_type => :group, :direction => :receivers) do |q|
22
+ contacts(:type => :group, :direction => :sent) do |q|
29
23
  q.select("ties.created_at").
30
24
  merge(Tie.recent)
31
25
  end
@@ -33,7 +27,7 @@ class User < ActiveRecord::Base
33
27
 
34
28
  # Subjects this user can acts as
35
29
  def represented
36
- subjects(:direction => :senders) do |q|
30
+ contacts(:direction => :received) do |q|
37
31
  q.joins(:sent_ties => { :relation => :permissions }).merge(Permission.represent)
38
32
  end
39
33
  end
@@ -0,0 +1,22 @@
1
+ <% content_for :headers do %>
2
+ <%= stylesheet_link_tag "activities", :media => "screen, projection" %>
3
+ <%= stylesheet_link_tag "jquery-ui", :media => "screen, projection" %>
4
+ <% end %>
5
+
6
+ <% content_for :javascript do %>
7
+ <%= render :partial => 'activities/jquery' %>
8
+ <% end -%>
9
+
10
+ <div id="wrapper_activities">
11
+ <div id="wrapper_activities_header">
12
+ <div id="activities_title" class="content_size">
13
+ <%= image_tag("btn/btn_activities.png") %> <%=t('activity.other')%>
14
+ </div>
15
+ <%= render :partial => 'activities/new', :locals => { :receiver => owner } %>
16
+ </div>
17
+
18
+ <div id="wall">
19
+ <%= render activities %>
20
+ <%= will_paginate activities %>
21
+ </div>
22
+ </div>
@@ -5,6 +5,8 @@
5
5
  <li><div class="verb_comment"> · <%= link_to t('activity.to_comment'), "#", :class => "to_comment" %> </div></li>
6
6
  <% end %>
7
7
  <li><div class="verb_like" id="like_<%= dom_id(activity) %>"> · <%= link_like(activity)%></div></li>
8
- <li><div class="verb_delete"> · <%= link_to t('activity.delete'), activity.direct_object , :confirm => t('confirm_delete', :scope => activity.direct_object.class.to_s.underscore), :method => :delete, :remote => true %> </div></li>
8
+ <% if activity.direct_object.present? %>
9
+ <li><div class="verb_delete"> · <%= link_to t('activity.delete'), activity.direct_object , :confirm => t('confirm_delete', :scope => activity.direct_object.class.to_s.underscore), :method => :delete, :remote => true %> </div></li>
10
+ <% end %>
9
11
  </ul>
10
12
  </div>
@@ -1,4 +1,5 @@
1
1
  <%= div_for activity do %>
2
+
2
3
  <div class="actor_logo">
3
4
  <%= link_to image_tag(activity.sender_subject.logo.url(:actor),
4
5
  :alt => activity.sender_subject.name),
@@ -6,8 +7,9 @@
6
7
  </div>
7
8
 
8
9
  <div class="activity_content">
10
+
9
11
  <div class="actor_name">
10
- <%= link_to(activity.sender_subject.name, activity.sender_subject) %>
12
+ <%= activity.title(self) %>
11
13
  </div>
12
14
 
13
15
  <div class="activity_objects">
@@ -34,4 +36,4 @@
34
36
  <div class="space_center"></div>
35
37
  <%end%>
36
38
  </div>
37
- <% end %>
39
+ <% end %>
@@ -0,0 +1,34 @@
1
+ <% content_for :javascript do %>
2
+ $("#tabs").tabs({
3
+ ajaxOptions: {
4
+ dataType: "script",
5
+ success: function(data) { eval(data); }
6
+ }
7
+ });
8
+ <% end %>
9
+
10
+ <div id="tabs" class="block">
11
+ <ul class="activity_tabs">
12
+ <li><%= link_to "<span>#{ h owner.name }</span>".html_safe, "#wall-profile" %></li>
13
+
14
+ <% owner.relations.sort.each do |r| %>
15
+ <li><%= link_to "<span>#{ h r.name }</span>".html_safe,
16
+ polymorphic_path([ owner, Activity.new ], :section => r.id, :wall => true),
17
+ :title => "wall-#{ r.id }" %></li>
18
+ <% end %>
19
+ </ul>
20
+
21
+ <div id="wall-profile">
22
+ <%= render :partial => 'activities/index',
23
+ :locals => { :owner => owner,
24
+ :activities => owner.wall(:profile,
25
+ :for => current_subject).
26
+ paginate(:page => params[:page]) } %>
27
+ </div>
28
+
29
+ <% owner.relations.sort.each do |r| %>
30
+ <div id="wall-<%= r.id %>"></div>
31
+ <% end %>
32
+ </div>
33
+
34
+
@@ -0,0 +1 @@
1
+ $('#wall-<%= params[:section] || "profile" %>').html("<%= escape_javascript render(:partial => 'index', :locals => { :owner => parent, :activities => @activities }) %>");
@@ -0,0 +1,23 @@
1
+ <div class= "block">
2
+ <div class = "content">
3
+ <%= form_for :logo, @avatar,:url => avatars_path, :html => { :multipart => true, :id=>'new_logo_form' }, :remote => false do |f| %>
4
+ <% if @avatar.errors.any? %>
5
+ <div id="error_explanation">
6
+ <h2><%= pluralize(@avatar.errors.count, "error") %> prohibited this logo from being saved:</h2>
7
+ <ul>
8
+ <% @avatar.errors.each do |msg| %><!--.full_messages -->
9
+ <li>
10
+ <%= msg[1] %>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ </div>
15
+ <% end %>
16
+ <%= f.file_field :logo %>
17
+ <div class="actions">
18
+ <%= f.submit t('avatar.upload') %>
19
+ </div>
20
+ <div id= "prueba">
21
+ </div>
22
+ <% end %>
23
+ </div></div>
@@ -1,18 +1,18 @@
1
- Crop your image:
1
+ <% my_file_name = File.basename(@avatar.logo.queued_for_write[:original].path) %>
2
2
 
3
3
 
4
- <% my_file_name = File.basename(@logo.logo.queued_for_write[:original].path) %>
5
- <%# my_file_name = params[:name] %>
6
- <div style="width:100px;height:100px;overflow:hidden;margin-left:5px;">
7
- <%= image_tag "tmp/#{my_file_name}",:id=>"preview" %>
8
- </div>
9
- <div id="precropDiv">
4
+ <div id="precropDiv" class = "block title content" style="width:500px;display:inline-block;padding: 5px 4px 5px 4px;">
10
5
  <%= image_tag "tmp/#{my_file_name}",:id=>"cropImage" %>
11
6
  </div>
12
7
 
13
- <% precrop_dimensions = @logo.image_dimensions(my_file_name) %>
8
+ <div class = "block logo" style = "vertical-align:top;display:inline-block;padding: 5px 4px 5px 4px;" ><%= t('avatar.preview') %></br>
9
+ <div style="width:100px;height:100px;overflow:hidden;margin-left:5px;" >
10
+ <%= image_tag "tmp/#{my_file_name}",:id=>"preview" %>
11
+ </div>
12
+ </div>
14
13
 
15
14
  <% content_for :javascript do %>
15
+ $("#sidebar").remove();
16
16
  jQuery('#cropImage').Jcrop({
17
17
  bgColor: 'clear',
18
18
  bgOpacity: .6,
@@ -25,13 +25,22 @@ Crop your image:
25
25
  function update_crop(coords) {
26
26
  var rx = 100/coords.w;
27
27
  var ry = 100/coords.h;
28
+
29
+ if((coords.w == 0) || (coords.h == 0)){
30
+ rx = 100/$("#cropImage").width();
31
+ ry = 100/$("#cropImage").height();
32
+ coords.x = 0;
33
+ coords.y = 0;
34
+ }
35
+
36
+
28
37
  $('#preview').css({
29
- width: Math.round(rx * <%= precrop_dimensions[:width] %>) + 'px',
30
- height: Math.round(ry * <%= precrop_dimensions[:height] %>) + 'px',
38
+ width: Math.round(rx * $("#cropImage").width()) + 'px',
39
+ height: Math.round(ry * $("#cropImage").height()) + 'px',
31
40
  marginLeft: '-' + Math.round(rx * coords.x) + 'px',
32
41
  marginTop: '-' + Math.round(ry * coords.y) + 'px'
33
42
  });
34
- var ratio = 1;//<% precrop_dimensions[:width] %> / <%= precrop_dimensions[:height] %>
43
+ var ratio = 1;
35
44
  $("#crop_x").val(Math.round(coords.x * ratio));
36
45
  $("#crop_y").val(Math.round(coords.y * ratio));
37
46
  $("#crop_w").val(Math.round(coords.w * ratio));
@@ -39,13 +48,12 @@ function update_crop(coords) {
39
48
  }
40
49
  <% end %>
41
50
 
42
- <%= form_for :logo, @logo,:url => logos_path, :html => { :multipart => true } do |f| %>
51
+ <%= form_for :logo, @avatar,:url => avatars_path, :html => { :multipart => true } do |f| %>
43
52
 
44
53
  <% for attribute in [:crop_x, :crop_y, :crop_w, :crop_h] %>
45
54
  <%= f.hidden_field attribute, :id => attribute %>
46
55
  <% end %>
47
56
  <%= f.hidden_field :name, :value => my_file_name %>
48
-
49
- <p><%= f.submit "Crop" %></p>
57
+ <br>
58
+ <p><%= f.submit t('avatar.crop_submit') %></p>
50
59
  <% end %>
51
-
@@ -0,0 +1,6 @@
1
+ <h1>Editing logo</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @avatar %> |
6
+ <%= link_to 'Back', avatars_path %>
@@ -0,0 +1,42 @@
1
+ <% toolbar :profile => current_subject %>
2
+
3
+ <h1><%= t('avatar.list') %></h1>
4
+
5
+ <table>
6
+ <tr>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% current_subject.avatars.each do |avatar| %>
13
+ <% unless avatar.id.blank? && (current_subject.avatars.size == 1) %>
14
+ <% unless avatar.id.blank? %>
15
+ <tr>
16
+ <td style="margin-left: 5px;">
17
+ <% if avatar.active%>
18
+ <%= image_tag avatar.logo.url(:profile), :style => "border: 7px solid #e0eef5" %></image_tag>
19
+ <td><%= link_to image_tag("btn/close.png", :class => "menu_icon"), avatar, :confirm => t('avatar.destroy_sure'), :method => :delete %></td>
20
+ <td></td>
21
+ <% else %>
22
+ <%= image_tag avatar.logo.url(:profile), :style => "margin: 7px" %></image_tag>
23
+ <td><%= link_to image_tag("btn/close.png"), avatar, :confirm => t('avatar.destroy_sure'), :method => :delete %></td>
24
+ <td><%= link_to t('avatar.set_default'), avatar, :confirm => t('avatar.set_default_sure'), :method => :put %></td>
25
+ <% end %>
26
+ </td>
27
+ </tr>
28
+ <%end%>
29
+ <%else%>
30
+ <tr>
31
+ <td>
32
+ <%= t('avatar.no_avatars') %>
33
+ </td>
34
+ </tr>
35
+
36
+ <% end %>
37
+ <% end %>
38
+ </table>
39
+
40
+ <br />
41
+
42
+ <%= link_to t('avatar.new_short'), new_avatar_path %>