social_stream 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +5 -1
- data/README.rdoc +2 -2
- data/app/controllers/api_controller.rb +2 -1
- data/app/controllers/contacts_controller.rb +25 -2
- data/app/controllers/groups_controller.rb +12 -2
- data/app/controllers/notifications_controller.rb +72 -0
- data/app/controllers/permissions_controller.rb +10 -0
- data/app/controllers/relation/customs_controller.rb +8 -0
- data/app/controllers/spheres_controller.rb +12 -0
- data/app/helpers/contacts_helper.rb +24 -0
- data/app/helpers/location_helper.rb +26 -12
- data/app/helpers/notifications_helper.rb +23 -0
- data/app/helpers/permissions_helper.rb +16 -0
- data/app/helpers/profiles_helper.rb +31 -0
- data/app/helpers/subjects_helper.rb +0 -83
- data/app/helpers/toolbar_helper.rb +83 -0
- data/app/models/activity.rb +43 -36
- data/app/models/actor.rb +71 -14
- data/app/models/contact.rb +121 -0
- data/app/models/group.rb +3 -3
- data/app/models/permission.rb +33 -2
- data/app/models/relation.rb +1 -1
- data/app/models/relation/custom.rb +12 -1
- data/app/models/relation/public.rb +1 -1
- data/app/models/sphere.rb +3 -1
- data/app/models/tie.rb +35 -18
- data/app/views/activities/_walls.html.erb +2 -2
- data/app/views/api/activity_atom_feed.atom.builder +38 -38
- data/app/views/avatars/index.html.erb +12 -40
- data/app/views/comments/_new.html.erb +9 -8
- data/app/views/contacts/_contact.html.erb +20 -0
- data/app/views/contacts/_edit.html.erb +76 -0
- data/app/views/contacts/_form.html.erb +72 -0
- data/app/views/contacts/_index.html.erb +1 -1
- data/app/views/{ties → contacts}/_pendings.html.erb +3 -3
- data/app/views/{ties → contacts}/_suggestions.html.erb +5 -5
- data/app/views/contacts/_suggestions_and_pendings.html.erb +6 -0
- data/app/views/contacts/edit.html.erb +5 -0
- data/app/views/contacts/index.html.erb +1 -1
- data/app/views/contacts/new.html.erb +5 -0
- data/app/views/conversations/_conversation.html.erb +1 -1
- data/app/views/conversations/_index.html.erb +0 -5
- data/app/views/conversations/_show.html.erb +1 -2
- data/app/views/conversations/index.html.erb +4 -0
- data/app/views/conversations/index.js.erb +1 -0
- data/app/views/frontpage/index.html.erb +2 -3
- data/app/views/groups/_index.html.erb +5 -1
- data/app/views/groups/_new.html.erb +4 -3
- data/app/views/groups/_sidebar_index.html.erb +3 -10
- data/app/views/groups/_sidebar_show.html.erb +1 -9
- data/app/views/groups/index.html.erb +6 -8
- data/app/views/groups/show.html.erb +11 -4
- data/app/views/home/_sidebar.html.erb +1 -15
- data/app/views/home/index.html.erb +3 -2
- data/app/views/layouts/_account.html.erb +1 -1
- data/app/views/layouts/_flash.html.erb +5 -0
- data/app/views/layouts/_footer.html.erb +5 -4
- data/app/views/layouts/_representation.html.erb +5 -12
- data/app/views/layouts/application.html.erb +23 -20
- data/app/views/layouts/frontpage.html.erb +22 -10
- data/app/views/location/_location.html.erb +1 -1
- data/app/views/messages/_new.html.erb +0 -2
- data/app/views/notification_mailer/new_notification_email.html.erb +21 -0
- data/app/views/notification_mailer/new_notification_email.text.erb +11 -0
- data/app/views/notifications/_index.html.erb +21 -0
- data/app/views/notifications/_notification.html.erb +47 -0
- data/app/views/notifications/_show.html.erb +3 -0
- data/app/views/notifications/activities/_follow_body.html.erb +2 -0
- data/app/views/notifications/activities/_follow_subject.html.erb +2 -0
- data/app/views/notifications/activities/_like_body.html.erb +5 -0
- data/app/views/notifications/activities/_like_object_body.html.erb +2 -0
- data/app/views/notifications/activities/_like_object_subject.html.erb +2 -0
- data/app/views/notifications/activities/_like_subject.html.erb +5 -0
- data/app/views/notifications/activities/_like_subject_body.html.erb +1 -0
- data/app/views/notifications/activities/_like_subject_subject.html.erb +2 -0
- data/app/views/notifications/activities/_make-friend_body.html.erb +3 -0
- data/app/views/notifications/activities/_make-friend_subject.html.erb +2 -0
- data/app/views/notifications/activities/_post_body.html.erb +2 -0
- data/app/views/notifications/activities/_post_subject.html.erb +1 -0
- data/app/views/notifications/activities/_update_body.html.erb +1 -0
- data/app/views/notifications/activities/_update_subject.html.erb +1 -0
- data/app/views/notifications/index.html.erb +19 -0
- data/app/views/notifications/index.js.erb +8 -0
- data/app/views/notifications/show.html.erb +5 -0
- data/app/views/permissions/_index.html.erb +39 -0
- data/app/views/permissions/index.js.erb +10 -0
- data/app/views/profiles/_contact.html.erb +81 -0
- data/app/views/profiles/_experience.html.erb +22 -0
- data/app/views/profiles/_personal.html.erb +74 -0
- data/app/views/profiles/_profile.html.erb +12 -181
- data/app/views/profiles/_tags.html.erb +22 -0
- data/app/views/profiles/edit.html.erb +0 -14
- data/app/views/profiles/show.html.erb +14 -0
- data/app/views/profiles/update.js.erb +2 -28
- data/app/views/relation/customs/_form.html.erb +29 -0
- data/app/views/relation/customs/_index.html.erb +30 -0
- data/app/views/relation/customs/_list.html.erb +36 -0
- data/app/views/relation/customs/create.js.erb +20 -0
- data/app/views/relation/customs/index.js.erb +2 -0
- data/app/views/relation/customs/update.js.erb +6 -0
- data/app/views/spheres/_form.html.erb +28 -0
- data/app/views/spheres/_jquery.erb +130 -0
- data/app/views/spheres/_list.html.erb +19 -0
- data/app/views/spheres/create.js.erb +20 -0
- data/app/views/spheres/index.html.erb +74 -0
- data/app/views/ties/_edit.html.erb +1 -33
- data/app/views/toolbar/_home.html.erb +9 -0
- data/app/views/{subjects/_toolbar_home_menu.html.erb → toolbar/_home_menu.html.erb} +1 -1
- data/app/views/{subjects/_toolbar_home_menu_options.html.erb → toolbar/_home_menu_options.html.erb} +7 -3
- data/app/views/{subjects/_toolbar_home_menu_options_subjects.html.erb → toolbar/_home_menu_options_subjects.html.erb} +0 -0
- data/app/views/{subjects/_toolbar_logo.html.erb → toolbar/_logo.html.erb} +1 -1
- data/app/views/{subjects/_toolbar_message_menu.html.erb → toolbar/_message_menu.html.erb} +0 -0
- data/app/views/toolbar/_notifications_menu.html.erb +3 -0
- data/app/views/{subjects/_toolbar_profile.html.erb → toolbar/_profile.html.erb} +2 -2
- data/app/views/toolbar/_profile_menu.html.erb +15 -0
- data/app/views/toolbar/_profile_menu_basic_options.html.erb +5 -0
- data/app/views/toolbar/_profile_menu_tie_options.html.erb +35 -0
- data/app/views/users/_index.html.erb +1 -1
- data/app/views/users/_sidebar_index.html.erb +1 -6
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +12 -2
- data/config/locales/en.yml +106 -79
- data/config/routes.rb +19 -5
- data/lib/generators/social_stream/templates/initializer.rb +2 -2
- data/lib/generators/social_stream/templates/migration.rb +3 -1
- data/lib/generators/social_stream/templates/public/images/HTML5.png +0 -0
- data/lib/generators/social_stream/templates/public/images/HTML5_Semantics.png +0 -0
- data/lib/generators/social_stream/templates/public/images/HTML5_Styling.png +0 -0
- data/lib/generators/social_stream/templates/public/images/Jcrop.gif +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/btn_notification.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/btn_notification_delete.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/error.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/info.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/success.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/warning.png +0 -0
- data/lib/generators/social_stream/templates/public/images/cancel.png +0 -0
- data/lib/generators/social_stream/templates/public/images/html5-badge-h-css3-semantics.png +0 -0
- data/lib/generators/social_stream/templates/public/images/icon_checkbox.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/actor/remote_subject.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/actor/remote_user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/representation/group.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/representation/user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/pbar-ani.gif +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.fileupload-ui.js +259 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.fileupload.js +475 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.form.js +815 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.ui.mouse.js +156 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.ui.slider.js +684 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.ui.widget.js +236 -0
- data/lib/generators/social_stream/templates/public/javascripts/ui.checkbox.js +309 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +13 -12
- data/lib/generators/social_stream/templates/public/stylesheets/default/contacts.css +88 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/footer.css +1 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +5 -3
- data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -1
- data/lib/generators/social_stream/templates/public/stylesheets/default/images/loading.gif +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.fileupload-ui.css +73 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.ui.slider.css +24 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.ui.slidertheme.css +32 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +4 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/spheres.css +226 -0
- data/lib/generators/social_stream/templates/relations.yml +12 -12
- data/lib/social_stream.rb +2 -1
- data/lib/social_stream/ability.rb +5 -4
- data/lib/social_stream/controllers/helpers.rb +19 -0
- data/lib/social_stream/models/object.rb +3 -1
- data/lib/social_stream/models/subject.rb +19 -6
- data/lib/social_stream/rails.rb +23 -1
- data/lib/social_stream/test_helpers/controllers.rb +1 -1
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +6 -9
- data/social_stream.gemspec +7 -4
- data/spec/controllers/comments_controller_spec.rb +1 -1
- data/spec/controllers/contacts_controller_spec.rb +23 -0
- data/spec/controllers/groups_controller_spec.rb +12 -1
- data/spec/controllers/permissions_controller_spec.rb +48 -0
- data/spec/controllers/posts_controller_spec.rb +4 -4
- data/spec/controllers/relation_customs_controller_spec.rb +130 -0
- data/spec/controllers/representations_spec.rb +74 -0
- data/spec/controllers/spheres_controller_spec.rb +108 -0
- data/spec/dummy/config/initializers/mailboxer.rb +8 -0
- data/spec/dummy/config/initializers/social_stream.rb +2 -2
- data/spec/dummy/config/relations.yml +12 -12
- data/spec/factories/relation_custom.rb +4 -0
- data/spec/factories/sphere.rb +5 -0
- data/spec/factories/tie.rb +4 -4
- data/spec/models/activity_spec.rb +58 -38
- data/spec/models/actor_spec.rb +1 -1
- data/spec/models/group_spec.rb +12 -0
- data/spec/models/like_spec.rb +68 -0
- data/spec/models/profile_spec.rb +2 -1
- data/spec/models/relation_custom_spec.rb +14 -0
- data/spec/models/tie_spec.rb +26 -2
- metadata +195 -94
- data/app/controllers/avatars_controller.rb +0 -51
- data/app/controllers/representations_controller.rb +0 -19
- data/app/controllers/ties_controller.rb +0 -22
- data/app/helpers/ties_helper.rb +0 -37
- data/app/models/avatar.rb +0 -91
- data/app/models/representation.rb +0 -35
- data/app/views/avatars/_form.html.erb +0 -12
- data/app/views/avatars/_precrop.html.erb +0 -66
- data/app/views/avatars/edit.html.erb +0 -6
- data/app/views/avatars/new.html.erb +0 -32
- data/app/views/avatars/show.html.erb +0 -5
- data/app/views/groups/_location.html.erb +0 -3
- data/app/views/groups/_logo.html.erb +0 -5
- data/app/views/home/_location.html.erb +0 -3
- data/app/views/subjects/_toolbar_home.html.erb +0 -9
- data/app/views/subjects/_toolbar_profile_menu.html.erb +0 -12
- data/app/views/subjects/_toolbar_profile_menu_basic_options.html.erb +0 -13
- data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +0 -41
- data/app/views/ties/_new.html.erb +0 -64
- data/app/views/ties/_tie.html.erb +0 -23
- data/app/views/ties/new.html.erb +0 -1
- data/app/views/users/_location.html.erb +0 -3
- data/lib/generators/social_stream/templates/public/images/w3c_css.png +0 -0
- data/lib/generators/social_stream/templates/public/images/w3c_xhtml.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/addContact.js +0 -100
- data/lib/generators/social_stream/templates/public/stylesheets/default/addContact.css +0 -29
- data/spec/controllers/representations_controller_spec.rb +0 -51
- data/spec/controllers/ties_controller_spec.rb +0 -19
- data/spec/models/representation_spec.rb +0 -16
@@ -1,51 +0,0 @@
|
|
1
|
-
class AvatarsController < InheritedResources::Base
|
2
|
-
|
3
|
-
before_filter :authenticate_user!
|
4
|
-
def update
|
5
|
-
|
6
|
-
if !current_subject.avatars.blank?
|
7
|
-
|
8
|
-
new_logo = Avatar.find(params[:id])
|
9
|
-
|
10
|
-
if (new_logo.actor == current_subject.actor)
|
11
|
-
|
12
|
-
actual_logo = current_subject.avatars.active.first
|
13
|
-
if !actual_logo.blank?
|
14
|
-
actual_logo.active = false
|
15
|
-
actual_logo.save
|
16
|
-
end
|
17
|
-
|
18
|
-
new_logo.active = true
|
19
|
-
new_logo.save
|
20
|
-
end
|
21
|
-
end
|
22
|
-
redirect_to avatars_path
|
23
|
-
end
|
24
|
-
|
25
|
-
def create
|
26
|
-
@avatar = Avatar.create(params[:avatar])
|
27
|
-
|
28
|
-
if @avatar.new_record?
|
29
|
-
render :new
|
30
|
-
else
|
31
|
-
@avatar.updating_logo = true
|
32
|
-
@avatar.actor_id = current_subject.actor.id
|
33
|
-
if !current_subject.avatars.blank?
|
34
|
-
actual_logo = current_subject.avatars.active.first
|
35
|
-
actual_logo.active = false
|
36
|
-
actual_logo.save
|
37
|
-
end
|
38
|
-
@avatar.active = true
|
39
|
-
@avatar.save
|
40
|
-
redirect_to avatars_path
|
41
|
-
#redirect_to [current_subject, :profile]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
protected
|
46
|
-
|
47
|
-
def begin_of_association_chain
|
48
|
-
current_subject
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Changes context for users to represent other subjects
|
2
|
-
class RepresentationsController < ApplicationController
|
3
|
-
before_filter :load_representation
|
4
|
-
|
5
|
-
authorize_resource
|
6
|
-
|
7
|
-
def create
|
8
|
-
self.current_subject = @representation.subject
|
9
|
-
|
10
|
-
redirect_to(request.referer || home_path)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# Build representation from params
|
16
|
-
def load_representation
|
17
|
-
@representation = Representation.new(params[:representation])
|
18
|
-
end
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class TiesController < InheritedResources::Base
|
2
|
-
respond_to :html, :xml, :js
|
3
|
-
|
4
|
-
before_filter :authenticate_user!
|
5
|
-
|
6
|
-
def create
|
7
|
-
create! do |format|
|
8
|
-
format.html { redirect_to resource.receiver_subject }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def update
|
13
|
-
update do |format|
|
14
|
-
format.html { redirect_to resource.receiver_subject }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def suggestion
|
19
|
-
@tie = current_subject.suggestion
|
20
|
-
render :layout => false
|
21
|
-
end
|
22
|
-
end
|
data/app/helpers/ties_helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module TiesHelper
|
2
|
-
def tie_brief(tie)
|
3
|
-
"N contacts in common"
|
4
|
-
end
|
5
|
-
|
6
|
-
# Show current ties from current user to actor, if they exist, or provide a link
|
7
|
-
# to create a new tie to actor
|
8
|
-
def ties_to(a)
|
9
|
-
if user_signed_in?
|
10
|
-
if current_subject.ties_to(a).present?
|
11
|
-
current_subject.ties_to(a).first.relation_name
|
12
|
-
else
|
13
|
-
new_tie_link(current_subject.sent_ties.build :receiver_id => Actor.normalize_id(a))
|
14
|
-
end
|
15
|
-
else
|
16
|
-
link_to t("contact.new.link"), new_user_session_path
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def new_tie_link(tie)
|
21
|
-
link_to t("contact.new.link"),
|
22
|
-
new_tie_path("tie[sender_id]" => tie.sender.id,
|
23
|
-
"tie[receiver_id]" => tie.receiver.id),
|
24
|
-
:title => t("contact.new.title",
|
25
|
-
:name => tie.receiver_subject.name)
|
26
|
-
end
|
27
|
-
|
28
|
-
def link_follow_state
|
29
|
-
link_to("Unfollow", home_path)
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def get_permission_id(action,object,function)
|
34
|
-
return Permission.find_by_action_and_function_and_object(action,object,function).id
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/app/models/avatar.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'RMagick'
|
2
|
-
|
3
|
-
class Avatar < ActiveRecord::Base
|
4
|
-
has_attached_file :logo,
|
5
|
-
:styles => { :representation => "20x20>",
|
6
|
-
:tie => "30x30>",
|
7
|
-
:actor => '35x35>',
|
8
|
-
:profile => '94x94' },
|
9
|
-
:default_url => "/images/logos/:style/:subtype_class.png"
|
10
|
-
|
11
|
-
before_post_process :process_precrop
|
12
|
-
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :name,:updating_logo
|
13
|
-
validates_attachment_presence :logo, :if => :uploading_file?, :message => I18n.t('avatar.error.no_file')
|
14
|
-
|
15
|
-
after_validation :precrop_done
|
16
|
-
|
17
|
-
belongs_to :actor
|
18
|
-
|
19
|
-
scope :active, where(:active => true)
|
20
|
-
|
21
|
-
def uploading_file?
|
22
|
-
return @name.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
def precrop_done
|
26
|
-
return if @name.blank? || !@updating_logo.blank?
|
27
|
-
|
28
|
-
precrop_path = File.join(Avatar.images_tmp_path,@name)
|
29
|
-
|
30
|
-
make_precrop(precrop_path,@crop_x.to_i,@crop_y.to_i,@crop_w.to_i,@crop_h.to_i)
|
31
|
-
@avatar = Avatar.new :logo => File.open(precrop_path), :name => @name
|
32
|
-
|
33
|
-
|
34
|
-
self.logo = @avatar.logo
|
35
|
-
|
36
|
-
FileUtils.remove_file(precrop_path)
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.images_tmp_path
|
40
|
-
images_path = File.join(RAILS_ROOT, "public", "images")
|
41
|
-
tmp_path = FileUtils.mkdir_p(File.join(images_path, "tmp"))
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.copy_to_temp_file(path)
|
45
|
-
FileUtils.cp(path,Avatar.images_tmp_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def self.get_image_dimensions(name)
|
50
|
-
img_orig = Magick::Image.read(name).first
|
51
|
-
dimensions = {}
|
52
|
-
dimensions[:width] = img_orig.columns
|
53
|
-
dimensions[:height] = img_orig.rows
|
54
|
-
dimensions
|
55
|
-
end
|
56
|
-
|
57
|
-
def process_precrop
|
58
|
-
|
59
|
-
if @name.blank? && ( logo.content_type.present? && !logo.content_type.start_with?("image/"))
|
60
|
-
logo.errors['invalidType'] = I18n.t('avatar.error.no_image_file')
|
61
|
-
return false
|
62
|
-
end
|
63
|
-
|
64
|
-
return if !@name.blank?
|
65
|
-
logo.errors['precrop'] = "You have to make precrop"
|
66
|
-
resize_image(logo.queued_for_write[:original].path,500,500)
|
67
|
-
Avatar.copy_to_temp_file(logo.queued_for_write[:original].path)
|
68
|
-
end
|
69
|
-
|
70
|
-
def resize_image(path,width,height)
|
71
|
-
img_orig = Magick::Image.read(path).first
|
72
|
-
img_orig = img_orig.resize_to_fit(width, height)
|
73
|
-
img_orig.write(path)
|
74
|
-
end
|
75
|
-
|
76
|
-
def make_precrop(path,x,y,width,height)
|
77
|
-
img_orig = Magick::Image.read(path).first
|
78
|
-
dimensions = Avatar.get_image_dimensions(path)
|
79
|
-
|
80
|
-
unless (width == 0) || (height == 0)
|
81
|
-
crop_args = [x,y,width,height]
|
82
|
-
img_orig = img_orig.crop(*crop_args)
|
83
|
-
end
|
84
|
-
|
85
|
-
img_orig = img_orig.resize_to_fill(500,500)
|
86
|
-
|
87
|
-
|
88
|
-
img_orig.write(path)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Users can represent other subjects in the application, acting as them
|
2
|
-
# through the browser, posting new activities, establishing new ties, etc.
|
3
|
-
class Representation
|
4
|
-
extend ActiveModel::Naming
|
5
|
-
include ActionController::RecordIdentifier
|
6
|
-
|
7
|
-
attr_reader :subject
|
8
|
-
|
9
|
-
# Sets up new representation
|
10
|
-
#
|
11
|
-
# params[:subject] must contain the dom_id of the represented subject
|
12
|
-
def initialize arg
|
13
|
-
@subject =
|
14
|
-
case arg
|
15
|
-
when Hash
|
16
|
-
arg[:subject_dom_id] =~ /(.*)_(\d*)$/
|
17
|
-
|
18
|
-
subject_type = $1.classify.constantize
|
19
|
-
subject_id = $2.to_i
|
20
|
-
|
21
|
-
subject_type.find subject_id
|
22
|
-
else
|
23
|
-
arg
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def subject_dom_id
|
28
|
-
dom_id(subject)
|
29
|
-
end
|
30
|
-
|
31
|
-
# ActiveRecord compatibility
|
32
|
-
def to_key #:nodoc:
|
33
|
-
nil
|
34
|
-
end
|
35
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<div class= "block">
|
2
|
-
<div class = "content">
|
3
|
-
<%= form_for Avatar.new,:html => { :multipart => true} do |f| %>
|
4
|
-
<div class="form_row">
|
5
|
-
<%= f.file_field :logo %>
|
6
|
-
|
7
|
-
<%= f.submit t('avatar.upload'), :class => "button" %>
|
8
|
-
</div>
|
9
|
-
<div id= "prueba">
|
10
|
-
</div>
|
11
|
-
<% end %>
|
12
|
-
</div></div>
|
@@ -1,66 +0,0 @@
|
|
1
|
-
<% my_file_name = File.basename(@avatar.logo.queued_for_write[:original].path) %>
|
2
|
-
|
3
|
-
<div class = "block">
|
4
|
-
<div id="precropPrev" >
|
5
|
-
<div class="form_row">
|
6
|
-
<%= t('avatar.preview') %>
|
7
|
-
</div>
|
8
|
-
<div id="precropPrevImg" class="logo">
|
9
|
-
<%= image_tag "tmp/#{my_file_name}",:id=>"preview" %>
|
10
|
-
</div>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
<div class="form_row">
|
14
|
-
<%= t('avatar.original') %>
|
15
|
-
</div>
|
16
|
-
|
17
|
-
<div id="precropDiv" class = "block title content">
|
18
|
-
<%= image_tag "tmp/#{my_file_name}",:id=>"cropImage" %>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
<% content_for :javascript do %>
|
22
|
-
jQuery('#cropImage').Jcrop({
|
23
|
-
bgColor: 'clear',
|
24
|
-
bgOpacity: .6,
|
25
|
-
setSelect: [ 0, 0, 200, 200 ],
|
26
|
-
aspectRatio: 1 ,
|
27
|
-
onChange: update_crop,
|
28
|
-
onSelect: update_crop
|
29
|
-
});
|
30
|
-
|
31
|
-
function update_crop(coords) {
|
32
|
-
var rx = 100/coords.w;
|
33
|
-
var ry = 100/coords.h;
|
34
|
-
|
35
|
-
if((coords.w == 0) || (coords.h == 0)){
|
36
|
-
rx = 100/$("#cropImage").width();
|
37
|
-
ry = 100/$("#cropImage").height();
|
38
|
-
coords.x = 0;
|
39
|
-
coords.y = 0;
|
40
|
-
}
|
41
|
-
|
42
|
-
$('#preview').css({
|
43
|
-
width: Math.round(rx * $("#cropImage").width()) + 'px',
|
44
|
-
height: Math.round(ry * $("#cropImage").height()) + 'px',
|
45
|
-
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
46
|
-
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
47
|
-
});
|
48
|
-
var ratio = 1;
|
49
|
-
$("#crop_x").val(Math.round(coords.x * ratio));
|
50
|
-
$("#crop_y").val(Math.round(coords.y * ratio));
|
51
|
-
$("#crop_w").val(Math.round(coords.w * ratio));
|
52
|
-
$("#crop_h").val(Math.round(coords.h * ratio));
|
53
|
-
}
|
54
|
-
<% end %>
|
55
|
-
|
56
|
-
<%= form_for @avatar, :html => { :multipart => true } do |f| %>
|
57
|
-
<div class= "block">
|
58
|
-
<% for attribute in [:crop_x, :crop_y, :crop_w, :crop_h] %>
|
59
|
-
<%= f.hidden_field attribute, :id => attribute %>
|
60
|
-
<% end %>
|
61
|
-
<%= f.hidden_field :name, :value => my_file_name %>
|
62
|
-
<div class="form_row center">
|
63
|
-
<%= f.submit t('avatar.crop_submit'), :class => "button" %>
|
64
|
-
</div>
|
65
|
-
</div>
|
66
|
-
<% end %>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<% content_for :headers do %>
|
2
|
-
<%= javascript_include_tag 'jquery.Jcrop.min' %>
|
3
|
-
<%= stylesheet_link_tag "jquery.Jcrop", :media => "screen, projection" %>
|
4
|
-
<%= stylesheet_link_tag "avatars", :media => "screen, projection" %>
|
5
|
-
<%end%>
|
6
|
-
|
7
|
-
<% toolbar :profile => current_subject %>
|
8
|
-
|
9
|
-
<% content_for :sidebar do %>
|
10
|
-
<%= render :partial => 'home/sidebar' %>
|
11
|
-
<% end %>
|
12
|
-
|
13
|
-
<%= location(
|
14
|
-
link_to(image_tag("btn/btn_edit.png", :class => "menu_icon")+t('profile.one'), [current_subject,:profile]),
|
15
|
-
link_to(image_tag("btn/edit.png", :class => "menu_icon")+t('avatar.other'), avatars_path)
|
16
|
-
) %>
|
17
|
-
|
18
|
-
<br class="clearfloat" />
|
19
|
-
<div class="space_center"></div>
|
20
|
-
<div class="space_center"></div>
|
21
|
-
<div id="content_logo">
|
22
|
-
<% if !@avatar.logo.errors['precrop'].blank? %>
|
23
|
-
<h2><%= t('avatar.crop_image') %></h2>
|
24
|
-
<br class="clearfloat" />
|
25
|
-
<div class="space_center"></div>
|
26
|
-
<%= render :partial => 'precrop' %>
|
27
|
-
<% else %>
|
28
|
-
<h2><%= t('avatar.new') %></h2>
|
29
|
-
<%= render :partial => 'form' %>
|
30
|
-
<% end %>
|
31
|
-
</div>
|
32
|
-
<% link_to 'Back', avatars_path %>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<% content_for :headers do %>
|
2
|
-
<%= stylesheet_link_tag "menu", :media => "screen, projection" %>
|
3
|
-
<%= javascript_include_tag 'menu' %>
|
4
|
-
<% end %>
|
5
|
-
|
6
|
-
<div id="menu_lateral">
|
7
|
-
<ul class="menu">
|
8
|
-
<%= render :partial => "subjects/toolbar_profile_menu_tie_options", :locals => { :subject => subject } %>
|
9
|
-
<%= render :partial => "subjects/toolbar_profile_menu_basic_options", :locals => { :subject => subject } %>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<div class="space_center"></div>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<%= menu_options[:messages] || capture do %>
|
2
|
-
<% if user_signed_in? %>
|
3
|
-
<li >
|
4
|
-
<%= link_to(image_tag("btn/btn_send.png", :class => "menu_icon")+t('message.send'), new_message_path(:receiver => subject.slug)) %>
|
5
|
-
</li>
|
6
|
-
<% end %>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<%= menu_options[:profile] || capture do %>
|
10
|
-
<li>
|
11
|
-
<%= link_to( image_tag("btn/btn_edit.png", :class => "menu_icon")+t('menu.information'), [subject, :profile]) %>
|
12
|
-
</li>
|
13
|
-
<% end %>
|