Browse files

conflict solved with migrate folder

  • Loading branch information...
2 parents 379d3b7 + 573a139 commit 6ea9162f5443fd42b889cdeef48c8a0d0bd6a7bb ebarra committed Jul 12, 2011
Showing with 731 additions and 428 deletions.
  1. +9 −1 app/assets/javascripts/jquery.validate.js
  2. +2 −2 app/assets/javascripts/menu.js
  3. +1 −0 app/assets/stylesheets/base.css
  4. +1 −1 app/assets/stylesheets/fcbkComplete.css
  5. +2 −2 app/assets/stylesheets/header.css
  6. +9 −10 app/assets/stylesheets/menu.css
  7. +3 −3 app/assets/stylesheets/messages.css
  8. +9 −4 app/controllers/contacts_controller.rb
  9. +13 −0 app/controllers/groups_controller.rb
  10. +26 −12 app/controllers/invitations_controller.rb
  11. +69 −68 app/controllers/messages_controller.rb
  12. +17 −9 app/helpers/activities_helper.rb
  13. +10 −8 app/helpers/contacts_helper.rb
  14. +3 −2 app/helpers/notifications_helper.rb
  15. +9 −0 app/helpers/subjects_helper.rb
  16. +23 −22 app/helpers/toolbar_helper.rb
  17. +2 −0 app/mailers/invitation_mailer.rb
  18. +32 −7 app/models/activity.rb
  19. +11 −7 app/models/actor.rb
  20. +5 −0 app/models/comment.rb
  21. +4 −2 app/models/contact.rb
  22. +7 −2 app/models/profile.rb
  23. +1 −1 app/models/relation.rb
  24. +1 −1 app/views/activities/_index.html.erb
  25. +1 −1 app/views/activities/_options.html.erb
  26. +1 −1 app/views/activities/_walls.html.erb
  27. +2 −3 app/views/comments/_new.html.erb
  28. +3 −3 app/views/contacts/_contact.html.erb
  29. +1 −1 app/views/contacts/_index.html.erb
  30. +1 −13 app/views/contacts/_suggestions.html.erb
  31. +6 −0 app/views/contacts/destroy.js.erb
  32. +1 −1 app/views/conversations/_conversation.html.erb
  33. +1 −1 app/views/groups/_index.html.erb
  34. +1 −1 app/views/groups/show.html.erb
  35. +3 −2 app/views/home/index.html.erb
  36. +39 −11 app/views/invitation_mailer/send_invitation.html.erb
  37. +7 −2 app/views/invitation_mailer/send_invitation.text.erb
  38. +2 −4 app/views/invitations/_new.html.erb
  39. +4 −0 app/views/invitations/new.js.erb
  40. +10 −6 app/views/layouts/_representation.html.erb
  41. +1 −1 app/views/messages/_message.html.erb
  42. +1 −1 app/views/messages/new.html.erb
  43. +7 −3 app/views/notifications/_notification.html.erb
  44. +2 −2 app/views/objects/_new.html.erb
  45. +5 −9 app/views/profiles/edit.html.erb
  46. +9 −2 app/views/toolbar/_home.html.erb
  47. +0 −13 app/views/toolbar/_home_menu.html.erb
  48. +0 −41 app/views/toolbar/_home_menu_options.html.erb
  49. +0 −12 app/views/toolbar/_home_menu_options_subjects.html.erb
  50. +0 −3 app/views/toolbar/_invitations_menu.html.erb
  51. +0 −17 app/views/toolbar/_message_menu.html.erb
  52. +0 −3 app/views/toolbar/_notifications_menu.html.erb
  53. +15 −6 app/views/toolbar/_profile.html.erb
  54. +0 −15 app/views/toolbar/_profile_menu.html.erb
  55. +0 −5 app/views/toolbar/_profile_menu_basic_options.html.erb
  56. +0 −10 app/views/toolbar/_profile_menu_options.html.erb
  57. +0 −26 app/views/toolbar/_profile_menu_tie_options.html.erb
  58. +1 −1 app/views/users/_index.html.erb
  59. +1 −1 app/views/users/show.html.erb
  60. +3 −1 config/locales/en.yml
  61. +1 −5 config/routes.rb
  62. +17 −0 db/migrate/20110705103202_empty_ties_count.rb
  63. +4 −0 lib/generators/social_stream/base/install_generator.rb
  64. +4 −2 lib/generators/social_stream/base/templates/initializer.rb
  65. +4 −0 lib/generators/social_stream/base/templates/navigation.rb
  66. +1 −0 lib/social_stream-base.rb
  67. +17 −1 lib/social_stream/ability.rb
  68. +1 −1 lib/social_stream/base/version.rb
  69. +4 −0 lib/social_stream/models/object.rb
  70. +113 −0 lib/social_stream/toolbar_config.rb
  71. +5 −3 social_stream-base.gemspec
  72. +20 −6 spec/controllers/comments_controller_spec.rb
  73. +22 −0 spec/controllers/contacts_controller_spec.rb
  74. +3 −2 spec/controllers/groups_controller_spec.rb
  75. +3 −1 spec/controllers/home_controller_spec.rb
  76. +7 −0 spec/dummy/config/database.yml
  77. +1 −0 spec/dummy/db/migrate
  78. 0 spec/dummy/db/migrate/.gitkeep
  79. +5 −0 spec/factories/activity.rb
  80. +4 −0 spec/factories/contact.rb
  81. +20 −0 spec/models/activity_spec.rb
  82. +9 −0 spec/models/actor_spec.rb
  83. +11 −0 spec/models/contact_spec.rb
  84. +48 −12 spec/models/user_spec.rb
  85. +0 −3 spec/spec_helper.rb
  86. +10 −2 spec/support/db.rb
  87. +0 −4 spec/support/migrations.rb
View
10 app/assets/javascripts/jquery.validate.js
@@ -14,7 +14,7 @@
*/
/*
- * This have been modified: added telephone number validation
+ * This have been modified: added telephone number and emails validation
*/
(function($) {
@@ -242,6 +242,7 @@ $.extend($.validator, {
required: " This field is required.",
remote: " Please fix this field.",
email: " Please enter a valid email address.",
+ emails: " Please enter valid email addresses.",
url: " Please enter a valid URL.",
date: " Please enter a valid date.",
dateISO: " Please enter a valid date (ISO).",
@@ -717,6 +718,8 @@ $.extend($.validator, {
classRuleSettings: {
required: {required: true},
email: {email: true},
+ //ADDED
+ emails: {emails: true},
url: {url: true},
date: {date: true},
dateISO: {dateISO: true},
@@ -972,6 +975,11 @@ $.extend($.validator, {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
},
+ //ADDED
+ emails: function(value, element) {
+ // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
+ return this.optional(element) || /^((, *)*((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)+$/i.test(value);
+ },
// http://docs.jquery.com/Plugins/Validation/Methods/url
url: function(value, element) {
View
4 app/assets/javascripts/menu.js
@@ -1,6 +1,6 @@
function initMenu() {
- $('.menu ul').hide();
- $('.menu li a').click( function() {
+ $('.toolbar_menu ul li ul').hide();
+ $('.toolbar_menu li a').click( function() {
$(this).next().slideToggle('normal');
}
);
View
1 app/assets/stylesheets/base.css
@@ -48,6 +48,7 @@ input.other_blue{ background:#497FC1; border:0px; cursor:pointer; font-size:1.0
margin-right:4px; color:white; padding:1px;}
textarea.new_contact_text_area{ width:100%; height: 100px; color: #2A3890;}
.colum_field_title{ text-align: center; }
+.needed{color:#D8000C;font-weight: normal;}
.select_relations select{ font-size: 12px; color: white; background-color:#1F4A75;}
/************ Forms - Buttons SECTION ***************************/
View
2 app/assets/stylesheets/fcbkComplete.css
@@ -1,5 +1,5 @@
/* TextboxList sample CSS */
-ul.holder { margin: 0; border: 1px solid #BDC7D8; overflow: hidden; height: auto !important; height: 1%; padding: 4px 5px 0; }
+ul.holder { margin: 0; border: 1px solid #BDC7D8; overflow: hidden; height: auto !important; height: 1%; padding: 5px; }
*:first-child+html ul.holder { padding-bottom: 2px; } * html ul.holder { padding-bottom: 2px; } /* ie7 and below */
ul.holder li { float: left; list-style-type: none; /*margin: 0 5px 4px 0;*/ white-space:nowrap;}
ul.holder li.bit-box, ul.holder li.bit-input input { font: 11px "Lucida Grande", "Verdana"; }
View
4 app/assets/stylesheets/header.css
@@ -52,7 +52,7 @@ li.btn_menu_browse{background: transparent url("btn/btn_browse.png") no-repeat l
#account, #representation_li,#current_user_info, #representations_menu, #account_menu, #settings_menu {display:inline-block;vertical-align: top; height:22px; color:#FFF;}
#representation_li{margin-left:10px;}
-
+#representation_text{display:inline;margin-left:2px;color:#FFF;}
li.btn_menu_representation{}
#menu_home ul li.pipe,#menu_account ul li.pipe{padding:0px 3px 0px 3px; margin:0px;}
.menu_white{display:inline-block; color:#fff;}
@@ -79,7 +79,7 @@ li.btn_menu_representation{}
.sf-menu ul {
position: absolute;
top: -999em;
- width: 10em; /* left offset of submenus need to match (see below) */
+ width: 17em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width: 100%;
View
19 app/assets/stylesheets/menu.css
@@ -1,15 +1,14 @@
/**************MENU***********/
-ul.menu {list-style-type:none; margin: 0; padding: 0; width: 15em; border-bottom: thin solid #D4E4EA; }
-ul.menu ul {list-style-type:none; margin: 0; padding: 0; width: 15em; }
-ul.menu a { display: block; text-decoration: none; }
-ul.menu li { border-top: thin solid #D4E4EA; padding-left:0px; }
-ul.menu li a, ul.menu ul.menu li a { background: #fff; color: #2A3890; padding: 0.3em; padding:5px 0px 5px 0px; }
-ul.menu li a:hover, ul.menu ul.menu li a:hover { background: #DEEFF8; color: #2A3890; text-decoration:none; }
-ul.menu li ul li a, ul.menu ul.menu li ul li a { background: #fff; border-left: 5px #2A3890 solid;
+.toolbar_menu {list-style-type:none; margin: 0; padding: 0; width: 15em; border-bottom: thin solid #D4E4EA; }
+.toolbar_menu ul {list-style-type:none; margin: 0; padding: 0; width: 15em; }
+.toolbar_menu a { display: block; text-decoration: none; }
+.toolbar_menu li { border-top: thin solid #D4E4EA; padding-left:0px; }
+.toolbar_menu li a, ul.menu ul.menu li a { background: #fff; color: #2A3890; padding: 0.3em; padding:5px 0px 5px 0px; }
+.toolbar_menu li a:hover, ul.menu ul.menu li a:hover { background: #DEEFF8; color: #2A3890; text-decoration:none; }
+.toolbar_menu li ul li a, ul.menu ul.menu li ul li a { background: #fff; border-left: 5px #2A3890 solid;
color: #2A3890; padding-left: 10px;}
-ul.menu li ul li a:hover { background: #DEEFF8; border-left: 5px #2A3890 solid; padding-left: 15px;}
-
-
+.toolbar_menu li ul li a:hover { background: #DEEFF8; border-left: 5px #2A3890 solid; padding-left: 15px;}
+.toolbar_menu img { vertical-align: middle; padding-bottom: 3px; padding-right: 3px; padding-left: 3px; display: inline-block;}
/*
div.panel { border: 1px #2A3890 solid; padding: 5px; margin-top: 0px;}
ul.menu li ul li a:hover, ul.menu ul.menu li ul li a:hover { background: #DEEFF8; border-left: 5px #2A3890 solid;
View
6 app/assets/stylesheets/messages.css
@@ -91,13 +91,13 @@
}
.conversations .conversation .content_left {
float:left;
- width:20%;
- padding: 7px 0px 0px 0px;
+ width:25%;
+ padding: 0px;
}
.conversations .conversation .content_right {
float:left;
width:55%;
- padding: 7px 0px 0px 0px;
+ padding: 0px;
}
.conversations .conversation .sender_photo {
float:left;
View
13 app/controllers/contacts_controller.rb
@@ -13,7 +13,7 @@ def index
respond_to do |format|
format.html { @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
format.js { @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
- format.json { render :text => @contacts.map{ |c| { 'key' => c.actor_id.to_s, 'value' => c.name } }.to_json }
+ format.json { render :text => @contacts.map{ |c| { 'key' => c.actor_id.to_s, 'value' => self.class.helpers.truncate_name(c.name) } }.to_json }
end
end
@@ -36,8 +36,13 @@ def update
end
end
- def suggestion
- @contact = current_subject.suggestion
- render :layout => false
+ def destroy
+ @contact = current_subject.sent_contacts.find params[:id]
+
+ @contact.relation_ids = [current_subject.relation_public.id]
+
+ respond_to do |format|
+ format.js
+ end
end
end
View
13 app/controllers/groups_controller.rb
@@ -1,4 +1,8 @@
class GroupsController < InheritedResources::Base
+ # Set group founder to current_subject
+ # Must do before authorization
+ before_filter :set_founder, :only => :new
+
load_and_authorize_resource
respond_to :html, :js
@@ -32,4 +36,13 @@ def create
def resource
@group ||= end_of_association_chain.find_by_slug!(params[:id])
end
+
+ private
+
+ def set_founder
+ return unless user_signed_in?
+
+ params[:group] ||= {}
+ params[:group][:_founder] ||= current_subject.slug
+ end
end
View
38 app/controllers/invitations_controller.rb
@@ -1,20 +1,34 @@
class InvitationsController < ApplicationController
-
- def new
-
+ def new
+
end
-
+
def create
-
+
if params[:mails].present?
- receivers = params[:mails].split(",")
- receivers.each do |receiver|
- InvitationMailer.send_invitation(receiver, current_subject, params[:message]).deliver
+ receivers = params[:mails].split(/, */)
+ if are_valid_emails?(receivers)
+ receivers.each do |receiver|
+ InvitationMailer.send_invitation(receiver, current_subject, params[:message]).deliver
+ end
+ redirect_to new_invitation_path, :flash => { :success => t('invitation.success')}
+ return
end
- redirect_to new_invitation_path, :flash => { :success => t('invitation.success')}
- else
- redirect_to new_invitation_path, :flash => { :error => t('invitation.error')}
end
-
+ redirect_to new_invitation_path, :flash => { :error => t('invitation.error')}
+
end
+
+ private
+
+ def are_valid_emails?(emails)
+ email_regex= /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/
+ emails.each do |email|
+ if !(email_regex.match(email))
+ return false
+ end
+ end
+ return true
+ end
+
end
View
137 app/controllers/messages_controller.rb
@@ -1,86 +1,87 @@
class MessagesController < ApplicationController
before_filter :authenticate_user!
- before_filter :get_mailbox, :get_box, :get_actor
-
- def index
- redirect_to conversations_path(:box => @box)
- end
- # GET /messages/1
- # GET /messages/1.xml
- def show
- if @message = Message.find_by_id(params[:id]) and @conversation = @message.conversation
- if @conversation.is_participant?(@actor)
- redirect_to conversation_path(@conversation, :box => @box, :anchor => "message_" + @message.id.to_s)
- return
- end
- end
- end
+ before_filter :get_mailbox, :get_box, :get_actor
+ def index
+ redirect_to conversations_path(:box => @box)
+ end
- # GET /messages/new
- # GET /messages/new.xml
- def new
- if params[:receiver].present?
- @recipient = Actor.find_by_slug(params[:receiver])
- return if @recipient.nil?
- @recipient = nil if Actor.normalize(@recipient)==Actor.normalize(current_subject)
- end
- end
+ # GET /messages/1
+ # GET /messages/1.xml
+ def show
+ if @message = Message.find_by_id(params[:id]) and @conversation = @message.conversation
+ if @conversation.is_participant?(@actor)
+ redirect_to conversation_path(@conversation, :box => @box, :anchor => "message_" + @message.id.to_s)
+ return
+ end
+ end
+ redirect_to conversations_path(:box => @box)
+ end
- # GET /messages/1/edit
- def edit
+ # GET /messages/new
+ # GET /messages/new.xml
+ def new
+ if params[:receiver].present?
+ @recipient = Actor.find_by_slug(params[:receiver])
+ return if @recipient.nil?
+ @recipient = nil if Actor.normalize(@recipient)==Actor.normalize(current_subject)
+ end
+ end
- end
+ # GET /messages/1/edit
+ def edit
- # POST /messages
- # POST /messages.xml
- def create
- @recipients = Array.new
- if params[:_recipients].present?
- params[:_recipients].each do |recp_id|
- recp = Actor.find_by_id(recp_id)
- next if recp.nil?
- @recipients << recp
- end
- end
- @receipt = @actor.send_message(@recipients, params[:body], params[:subject])
- if (@receipt.errors.blank?)
- @conversation = @receipt.conversation
+ end
+
+ # POST /messages
+ # POST /messages.xml
+ def create
+ @recipients = Array.new
+ if params[:_recipients].present?
+ params[:_recipients].each do |recp_id|
+ recp = Actor.find_by_id(recp_id)
+ next if recp.nil?
+ @recipients << recp
+ end
+ end
+ @receipt = @actor.send_message(@recipients, params[:body], params[:subject])
+ if (@receipt.errors.blank?)
+ @conversation = @receipt.conversation
flash[:success]="Your message was sent"
- redirect_to conversation_path(@conversation, :box => :sentbox)
- else
- render :action => :new
- end
- end
+ redirect_to conversation_path(@conversation, :box => :sentbox)
+ else
+ render :action => :new
+ end
+ end
- # PUT /messages/1
- # PUT /messages/1.xml
- def update
+ # PUT /messages/1
+ # PUT /messages/1.xml
+ def update
- end
+ end
- # DELETE /messages/1
- # DELETE /messages/1.xml
- def destroy
+ # DELETE /messages/1
+ # DELETE /messages/1.xml
+ def destroy
- end
+ end
- private
+ private
- def get_mailbox
- @mailbox = current_subject.mailbox
- end
+ def get_mailbox
+ @mailbox = current_subject.mailbox
+ end
- def get_actor
- @actor = Actor.normalize(current_subject)
- end
+ def get_actor
+ @actor = Actor.normalize(current_subject)
+ end
- def get_box
- if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
- @box = "inbox"
- return
- end
- @box = params[:box]
- end
+ def get_box
+ if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
+ @box = "inbox"
+ return
+ end
+ @box = params[:box]
+ end
end
View
26 app/helpers/activities_helper.rb
@@ -1,20 +1,28 @@
module ActivitiesHelper
-
# Link to 'like' or 'unlike' depending on the like status of the activity to current_subject
- #
+ #
# @param [Object]
# @return [String]
def link_like(object)
+ params = link_like_params(object)
+ link_to params[0],params[1],params[2]
+ end
+
+ def link_like_params(object)
+ params = Array.new
if !user_signed_in?
- link_to image_tag("btn/nolike.png", :class => "menu_icon")+
- t('activity.like'),new_user_session_path
+ params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like')
+ params << new_user_session_path
+ params << {:class => "verb_like",:id => "like_" + dom_id(object)}
else
if (object.liked_by?(current_subject))
- link_to image_tag("btn/like.png", :class => "menu_icon")+
- t('activity.unlike'), [object, :like], :method => :delete, :remote => true
+ params << image_tag("btn/like.png", :class => "menu_icon")+t('activity.unlike')
+ params << [object, :like]
+ params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :delete, :remote => true}
else
- link_to image_tag("btn/nolike.png", :class => "menu_icon")+
- t('activity.like'), [object, :like], :method => :post, :remote => true
+ params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like')
+ params << [object, :like]
+ params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :post, :remote => true}
end
end
end
@@ -24,6 +32,6 @@ def new_activity(receiver)
return Activity.new unless user_signed_in?
Activity.new :contact_id => current_subject.contact_to!(receiver).id,
- :relation_ids => receiver.activity_relations(current_subject, :from => :receiver).map(&:id)
+ :relation_ids => current_subject.activity_relations(receiver, :from => :receiver).map(&:id)
end
end
View
18 app/helpers/contacts_helper.rb
@@ -7,16 +7,18 @@ def contact_brief(contact)
# to create new ties to actor
def contact_to(a)
if user_signed_in?
- if current_subject.ties_to?(a)
- current_subject.ties_to(a).map(&:relation_name).join(", ")
- else
- link_to t("contact.new.link"),
- edit_contact_path(current_subject.contact_to!(a)),
- :title => t("contact.new.title",
- :name => a.name)
- end
+ link_to contact_status(a),
+ edit_contact_path(current_subject.contact_to!(a)),
+ :title => t("contact.new.title",
+ :name => a.name)
else
link_to t("contact.new.link"), new_user_session_path
end
end
+
+ def contact_status(a)
+ current_subject.ties_to?(a) ?
+ current_subject.ties_to(a).map(&:relation_name).join(", ") :
+ t("contact.new.link")
+ end
end
View
5 app/helpers/notifications_helper.rb
@@ -1,8 +1,9 @@
module NotificationsHelper
+ include SubjectsHelper, ActionView::Helpers::TextHelper
def decode_notification notification_text, activity
return if activity.nil?
- notification_text = notification_text.gsub(/\%\{sender\}/, link_to(activity.sender.name, activity.sender.subject))
- notification_text = notification_text.gsub(/\%\{sender.name\}/,activity.sender.name)
+ notification_text = notification_text.gsub(/\%\{sender\}/, link_to(truncate_name(activity.sender.name), activity.sender.subject))
+ notification_text = notification_text.gsub(/\%\{sender.name\}/,truncate_name(activity.sender.name))
if activity.direct_object.present?
object = activity.direct_object
View
9 app/helpers/subjects_helper.rb
@@ -1,6 +1,15 @@
module SubjectsHelper
+
+ NAME_MAX_LENGHT = 30
+
# Return a link to this subject with the name
def link_name(subject, options = {})
link_to subject.name, subject, options
end
+
+ # Return the truncated name
+ def truncate_name(name, options={})
+ options = {:length => NAME_MAX_LENGHT, :separator => ' '}.merge options
+ truncate(name,options)
+ end
end
View
45 app/helpers/toolbar_helper.rb
@@ -38,12 +38,7 @@ module ToolbarHelper
#
# <% toolbar :profile => @group, :option => :contacts %>
#
-
def toolbar(options = {}, &block)
- old_toolbar(options,&block)
- end
-
- def old_toolbar(options = {}, &block)
if options[:option] && block_given?
menu_options[options[:option]] = capture(&block)
end
@@ -67,14 +62,14 @@ def old_toolbar(options = {}, &block)
response.html_safe
else
- content_for(:toolbar) do
- content
- end
- content_for(:javascript) do
- <<-EOJ
- expandSubMenu('#{ options[:option] }');
- EOJ
- end
+ content_for(:toolbar) do
+ content
+ end
+ content_for(:javascript) do
+ <<-EOJ
+ expandSubMenu('#{ options[:option] }');
+ EOJ
+ end
end
end
@@ -84,18 +79,24 @@ def old_toolbar(options = {}, &block)
def menu_options #:nodoc:
@menu_options ||= {}
end
-
- def default_toolbar_menu
- items = [{:key => :notifications,
- :name => image_tag("btn/btn_notification.png", :class => "menu_icon")+t('notification.other')+' ('+ current_subject.mailbox.notifications.not_trashed.unread.count.to_s+')',
- :url => notifications_path}]
-
- return render_items items
+
+ #Prints the home toolbar menu.
+ def home_toolbar_menu
+ default_home_toolbar_menu
end
-
+
+ #Prints the home profile menu.
+ def profile_toolbar_menu(subject=current_subject)
+ default_profile_toolbar_menu(subject)
+ end
+
+
+ #Renders array of navigation items with simple_navigation
def render_items(items)
menu = render_navigation :items => items
- menu = menu.gsub(/\<ul\>/,'<ul class="menu">')
return raw menu
end
+
+
+ include SocialStream::ToolbarConfig
end
View
2 app/mailers/invitation_mailer.rb
@@ -1,5 +1,7 @@
class InvitationMailer < ActionMailer::Base
+ default :from => Mailboxer.default_from
+
def send_invitation(receiver, sender, message)
@sender= sender
@message= message
View
39 app/models/activity.rb
@@ -80,7 +80,7 @@ class Activity < ActiveRecord::Base
}
after_create :increment_like_count
- after_destroy :decrement_like_count
+ after_destroy :decrement_like_count, :delete_notifications
#For now, it should be the last one
@@ -209,23 +209,39 @@ def allow?(subject, action)
case action
when 'create'
- return contact.sender_id == Actor.normalize_id(subject) &&
- relation_ids.any? &&
- Relation.
- allow(subject, action, 'activity', :in => relation_ids).all.size == relation_ids.size
+ return false if contact.sender_id != Actor.normalize_id(subject)
+
+ rels = Relation.normalize(relation_ids)
+
+ foreign_rels = rels.select{ |r| r.actor_id != contact.sender_id }
+
+ # Only posting to own relations
+ return true if foreign_rels.blank?
+
+ return Relation.
+ allow(subject, action, 'activity', :in => foreign_rels).all.size == foreign_rels.size
when 'read'
return true if [contact.sender_id, contact.receiver_id].include?(Actor.normalize_id(subject)) || relations.select{ |r| r.is_a?(Relation::Public) }.any?
when 'update'
return true if contact.sender_id == Actor.normalize_id(subject)
when 'destroy'
- return true if [contact.sender_id, contact.receiver_id].include?(Actor.normalize_id(subject))
+ # We only allow destroying to sender and receiver by now
+ return [contact.sender_id, contact.receiver_id].include?(Actor.normalize_id(subject))
end
Relation.
allow(subject, action, 'activity').
where('relations.id' => relation_ids).
any?
- end
+ end
+
+ # Can subject delete the object of this activity?
+ def delete_object_by?(subject)
+ subject.present? &&
+ direct_object.present? &&
+ ! direct_object.is_a?(Actor) &&
+ allow?(subject, 'destroy')
+ end
private
@@ -251,4 +267,13 @@ def decrement_like_count
direct_activity_object.decrement!(:like_count)
end
+
+ # after_destroy callback
+ #
+ # Destroy any Notification linked with the activity
+ def delete_notifications
+ Notification.find_by_object(self).each do |notification|
+ notification.destroy
+ end
+ end
end
View
18 app/models/actor.rb
@@ -161,10 +161,12 @@ def relation_public
# Options:
# * type: Filter by the class of the contacts.
# * direction: sent or received
- # * relations: Restrict the relations of considered ties
+ # * relations: Restrict the relations of considered ties. Defaults to {Relation::Custom subject's custom relations}
# * include_self: False by default, don't include this actor as subject even they have ties with themselves.
#
def contact_actors(options = {})
+ options[:relations] ||= relation_customs.to_a
+
subject_types = Array(options[:type] || self.class.subtypes)
subject_classes = subject_types.map{ |s| s.to_s.classify }
@@ -186,9 +188,7 @@ def contact_actors(options = {})
as = as.where("actors.id != ?", self.id)
end
- if options[:relations].present?
- as = as.joins(:ties).merge(Tie.related_by(options[:relations]))
- end
+ as = as.joins(:received_ties).merge(Tie.related_by(options[:relations]))
as
end
@@ -241,7 +241,7 @@ def suggestion(options = {})
# Candidates are all the instance of "type" minus all the subjects
# that are receiving any tie from this actor
candidates = candidates_classes.inject([]) do |cs, klass|
- cs += klass.all - contact_subjects(:type => klass.to_s.underscore, :direction => :sent)
+ cs += klass.all - contact_subjects(:type => klass.to_s.underscore, :direction => :sent, :relations => relations.to_a)
cs -= Array(subject) if subject.is_a?(klass)
cs
end
@@ -250,7 +250,7 @@ def suggestion(options = {})
return nil unless candidate.present?
- Contact.new :sender => self, :receiver => candidate.actor
+ contact_to!(candidate)
end
# Set of ties sent by this actor received by subject
@@ -353,7 +353,11 @@ def grouped_activity_relations(subject)
end
# Is this {Actor} allowed to create a comment on activity?
+ #
+ # We are allowing comments from everyone signed in by now
def can_comment?(activity)
+ return true
+
comment_relations(activity).any?
end
@@ -365,7 +369,7 @@ def comment_relations(activity)
# Build a new {Contact} from each that has not inverse
def pending_contacts
- received_contacts.pending.all.map do |c|
+ received_contacts.not_reflexive.pending.all.map do |c|
c.inverse ||
c.receiver.contact_to!(c.sender)
end
View
5 app/models/comment.rb
@@ -2,4 +2,9 @@ class Comment < ActiveRecord::Base
include SocialStream::Models::Object
validates_presence_of :text
+
+ def _activity_parent_id=(id)
+ self._relation_ids = Activity.find(id).relation_ids
+ @_activity_parent_id = id
+ end
end
View
6 app/models/contact.rb
@@ -50,6 +50,8 @@ class Contact < ActiveRecord::Base
scope :active, where(arel_table[:ties_count].gt(0))
+ scope :not_reflexive, where(arel_table[:sender_id].not_eq(arel_table[:receiver_id]))
+
validates_presence_of :sender_id, :receiver_id
validates_uniqueness_of :sender_id, :scope => :receiver_id
validates_uniqueness_of :receiver_id, :scope => :sender_id
@@ -126,11 +128,11 @@ def remove_follower(ids)
end
end
end
-
+
# Send a message to the contact receiver
def send_message
if message.present?
- sender.send_message(receiver, message, I18n.t("activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message", :name => sender.name))
+ sender.send_message(receiver, message, I18n.t("activity.verb.#{ verb }.#{ receiver.subject_type }.message", :name => sender.name))
end
end
View
9 app/models/profile.rb
@@ -17,18 +17,23 @@ class Profile < ActiveRecord::Base
validate :validate_birthday
- def birthday=(value)
+ def birthday=(value)
+
+ puts "He entrado en el metodo birthday con un :" + value.class.to_s
+
if value.blank?
@birthday_formatted_invalid = false
super value
else
begin
- super Date.parse(value)
+ #super Date.parse(value)
+ super value
@birthday_formatted_invalid = false
rescue
@birthday_formatted_invalid = true
end
end
+
end
def age
View
2 app/models/relation.rb
@@ -57,7 +57,7 @@ def normalize(r, options = {})
when Array
r.map{ |e| Relation.normalize(e, options) }
else
- raise "Unable to normalize relation #{ r.inspect }"
+ raise "Unable to normalize relation #{ r.class }: #{ r.inspect }"
end
end
View
2 app/views/activities/_index.html.erb
@@ -23,4 +23,4 @@
<%= render activities %>
<%= paginate activities %>
</div>
-</div>
+</div>
View
2 app/views/activities/_options.html.erb
@@ -5,7 +5,7 @@
<li><div class="verb_comment"> · <%= link_to t('activity.to_comment'), "#", :class => "to_comment" %> </div></li>
<% end %>
<li><div class="verb_like" id="like_<%= dom_id(activity) %>"> · <%= link_like(activity)%></div></li>
- <% if activity.direct_object.present? && !activity.direct_object.is_a?(Actor) %>
+ <% if activity.delete_object_by?(current_subject) %>
<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>
<% end %>
</ul>
View
2 app/views/activities/_walls.html.erb
@@ -9,7 +9,7 @@
<div id="tabs" class="block">
<ul class="activity_tabs">
- <li><%= link_to "<span>#{ h owner.name }</span>".html_safe, "#wall-profile" %></li>
+ <li><%= link_to "<span>#{ h truncate_name owner.name }</span>".html_safe, "#wall-profile" %></li>
<% owner.relation_customs.sort.each do |r| %>
<li><%= link_to "<span>#{ h r.name }</span>".html_safe,
View
5 app/views/comments/_new.html.erb
@@ -7,9 +7,8 @@
),
:html => { :class => "new_comment", :id => "new_comment"+dom_id(activity) },
:remote => true do |f| %>
- <% current_subject.comment_relations(activity).each do |r| %>
- <%= f.hidden_field "_relation_ids][", :id => "comment__relation_ids_#{ r.id }", :value => r.id %>
- <% end %>
+
+ <%= f.hidden_field :_contact_id %>
<%= f.hidden_field :_activity_parent_id %>
<%= f.text_field :text, :class =>"input_new_comments" , :id => "comment_text_"+dom_id(activity) %>
View
6 app/views/contacts/_contact.html.erb
@@ -1,4 +1,4 @@
-<div id="contact_<%=dom_id(contact.receiver_subject)%>" class="row contact">
+<%= div_for contact, :class => 'row' do %>
<div class="logo">
<%= link_to(image_tag(contact.receiver.logo.url(:contact)),
contact.receiver_subject) %>
@@ -14,7 +14,7 @@
<%= contact_to(contact.receiver) %>
</div>
</div>
- <div class="close"><%=link_to('X','#')%></div>
+ <div class="close"><%= link_to 'X', contact, :method => :delete, :remote => true %></div>
<div class="space_center">
</div>
-</div>
+<% end %>
View
2 app/views/contacts/_index.html.erb
@@ -13,7 +13,7 @@
</div>
<div class="sub-block">
<div class="name black" >
- <%=link_to(contact.name, contact)%>
+ <%=link_to(truncate_name(contact.name), contact)%>
</div>
<div class="link">
<%= contact_to(contact) %>
View
14 app/views/contacts/_suggestions.html.erb
@@ -1,16 +1,4 @@
<% if current_subject.suggestion.present? %>
- <% content_for :javascript do %>
-
- $(".suggestions .close").livequery("click",function(){
- temp = $(this);
- $.get("<%=suggestion_contacts_path%>", function(data) {
- temp.parents(".contact").replaceWith(data);
- });
-
- });
-
- <% end %>
-
<div class="block">
<div class="header">
<%= image_tag('btn/notifications.png', :class => "header_icon") %>
@@ -21,7 +9,7 @@
<div class="content">
<div class="suggestions">
<% if (sgs = current_subject.suggestions(2)).present? %>
- <%= render :partial => 'contacts/contact', :collection => sgs %>
+ <%= render sgs %>
<%end%>
</div>
</div>
View
6 app/views/contacts/destroy.js.erb
@@ -0,0 +1,6 @@
+<%
+ new_contact = @contact.pending? ? current_subject.pending_contacts.last : current_subject.suggestion
+ render_string = new_contact.present? ? render(new_contact) : ""
+%>
+
+$('#<%= dom_id(@contact) %>').replaceWith("<%= escape_javascript render_string %>");
View
2 app/views/conversations/_conversation.html.erb
@@ -8,7 +8,7 @@
</div>
<div class="content_left">
<div class="sender_name">
- <%= link_to conversation.last_sender.name, conversation.last_sender.subject %>
+ <%= link_to truncate_name(conversation.last_sender.name), conversation.last_sender.subject %>
</div>
<div class="date">
<%= t('time.ago', :time => time_ago_in_words(conversation.updated_at)) %>
View
2 app/views/groups/_index.html.erb
@@ -10,7 +10,7 @@
</div>
<div class="sub-block">
<div class="name black" >
- <%= link_to group.name, group %>
+ <%= link_to truncate_name(group.name), group %>
</div>
<div class="brief">
<%= t 'follower.n', :count => group.follower_count %>,
View
2 app/views/groups/show.html.erb
@@ -16,7 +16,7 @@
<% end %>
<%= location(link_to(image_tag("btn/btn_group.png", :class => "btn_config")+t('group.one')+": "+
- content_tag(:span, ( sanitize @group.name), :class=>"name_group")))%>
+ content_tag(:span, ( truncate_name sanitize @group.name), :class=>"name_group")))%>
<% toolbar :profile => @group %>
View
5 app/views/home/index.html.erb
@@ -11,8 +11,9 @@
<div class="space_center">
</div>
-<div id="media_wall">
-</div>
+<% if SocialStream.activity_forms.include? :document %>
+ <%= render :partial => '/documents/mediawall' %>
+<% end %>
<% if current_subject.respond_to?(:recent_groups) %>
<div id="my_groups">
View
50 app/views/invitation_mailer/send_invitation.html.erb
@@ -1,38 +1,66 @@
<div>
- <div><%= @sender.name %> has invited you to <%= link_to( t('socialstream'), new_user_registration_path)%>
- <div><%= @message%></div>
+ <div>
+ <span id="name" style="font-weight: bold;"><%= @sender.name %></span> has invited you to <%= link_to( t('socialstream'), new_user_registration_url)%>
+ <br/>
+ <div style="position: absolute;padding: 5px; border: #2A3890 solid 2px; background-color: #E1EEF5; margin:10px; min-height: 125px; width: 500px;">
+ <div style="float:left; margin-right:7px; border: thin solid #D4E4EA; background-color: white; max-height: 119px;">
+ <img src="http://<%= ActionMailer::Base.default_url_options[:host] +@sender.logo.url(:profile)%>" alt="<%=@sender.name%>">
+ </div>
+ <div style=" margin: 5px 5px 5px 5px;">
+ <p style="font-weight: bold; "><%= @sender.name %>
+ <% if @sender.profile.organization? %>
+ <br/><span style="color: #6C6D6F; font-weight: normal;"><%= @sender.profile.organization%></span>
+ <% end %>
+ </p>
+ <% if @message.blank? %>
+ <p style="text-align: justify;"><%= t('invitation.join_me')%></p>
+ <%else%>
+ <p style="text-align: justify; font-style: italic;">"<%= @message%>"</p>
+ <%end%>
+ </div>
+ </div>
</div>
<div>
<div>
- <%= t('frontpage.share.default')%>
+ <%= t('frontpage.share.default')%>:
</div>
<div>
<ul>
- <li><%= t('frontpage.share.sentence1') %></li>
- <li><%= t('frontpage.share.sentence2') %></li>
+ <li>
+ <%= t('frontpage.share.sentence1') %>
+ </li>
+ <li>
+ <%= t('frontpage.share.sentence2') %>
+ </li>
</ul>
</div>
</div>
-
+
<div>
<div>
- <%= t('frontpage.meet.default')%>
+ <%= t('frontpage.meet.default')%>:
</div>
<div>
<ul>
- <li><%= t('frontpage.meet.sentence1') %></li>
+ <li>
+ <%= t('frontpage.meet.sentence1') %>
+ </li>
</ul>
</div>
</div>
<div>
<div>
- <%= t('frontpage.collaborate.default')%>
+ <%= t('frontpage.collaborate.default')%>:
</div>
<div>
<ul>
- <li><%= t('frontpage.collaborate.sentence1') %></li>
- <li><%= t('frontpage.collaborate.sentence2') %></li>
+ <li>
+ <%= t('frontpage.collaborate.sentence1') %>
+ </li>
+ <li>
+ <%= t('frontpage.collaborate.sentence2') %>
+ </li>
</ul>
</div>
</div>
View
9 app/views/invitation_mailer/send_invitation.text.erb
@@ -1,5 +1,10 @@
-<%= @sender.name %> has invited you to <%= link_to( t('socialstream'), new_user_registration_path)%>
-"<%= @message%>"
+<%= @sender.name %> has invited you to <%= t('socialstream')%>: <%= new_user_registration_url%>
+
+<% if @message.blank? %>
+ <%= t('invitation.join_me')%>
+<%else%>
+ "<%= @message%>"
+<%end%>
<%= t('frontpage.main_title') %>
View
6 app/views/invitations/_new.html.erb
@@ -4,13 +4,11 @@
});
<% end %>
-<br class="clearfloat" />
-<div class="space_center"></div>
<div class="space_center"></div>
<h2><%=t('invitation.other')%></h2>
-<%= form_tag invitations_path, :method=> :post, :class => "invitation_form" do %>
+<%= form_tag invitations_path, :method=> :post, :class => "invitation_form", :remote => true do %>
<div class="block">
<h3 class= "form_row"><%=t('invitation.join')%></h3>
<div class="form_row form_label ">
@@ -19,7 +17,7 @@
</div>
<div class="form_row">
- <%= text_field_tag 'mails', nil, :class => "required form_tag" %>
+ <%= text_field_tag 'mails', nil, :class => "required emails form_tag" %>
</div>
<div class="form_row form_label">
<%=t('invitation.text')%>
View
4 app/views/invitations/new.js.erb
@@ -0,0 +1,4 @@
+$("#flash").empty();
+$("#flash").append("<%= escape_javascript(render :partial => "layouts/flash", :locals => {:flash => flash})%>");
+$("#content").empty();
+$("#content").append("<%= escape_javascript(render(:partial => 'new'))%>");
View
16 app/views/layouts/_representation.html.erb
@@ -4,24 +4,28 @@
<% else %>
<%= link_to(image_tag(current_user.logo.url(:representation), :width => 20, :height => 20, :class => 'menu_icon'), current_user) %>
<% end %>
- <%= link_to(current_user.name, current_user) %>
-
- <%= t('representation.action') %>
+ <%= link_to(truncate_name(current_user.name), current_user) %>
</div>
+
<% representations = current_user.represented.unshift(current_user) - [current_subject] %>
-<div id="representations_menu">
+<% if !representations.empty? %>
+
+<span id="representation_text"><%= t('representation.action') %></span>
+
+<div id="representations_menu">
<ul class="sf-menu" >
<li id="representation_li">
- <a href="#" class="sf-with-ul" id="current_subject_avatar_img" style="background: transparent url('<%= image_path current_subject.logo.url(:representation)%>') no-repeat left top;"><%= current_subject.name %><span class="sf-sub-indicator"> »</span></a>
+ <a href="#" class="sf-with-ul" id="current_subject_avatar_img" style="background: transparent url('<%= image_path current_subject.logo.url(:representation)%>') no-repeat left top;"><%= truncate_name current_subject.name %><span class="sf-sub-indicator"> »</span></a>
<ul>
<% representations.each do |representation| %>
<li>
- <%= link_to representation.name, { :s => representation.slug }, { :style => "background: transparent url('#{ image_path representation.logo.url(:representation)}') no-repeat left center;margin-left:2px;" } %>
+ <%= link_to truncate_name(representation.name), { :s => representation.slug }, { :style => "background: transparent url('#{ image_path representation.logo.url(:representation)}') no-repeat left center;margin-left:2px;" } %>
</li>
<% end %>
</ul>
</li>
</ul>
</div>
+<% end %>
View
2 app/views/messages/_message.html.erb
@@ -8,7 +8,7 @@
<div class="header">
<div class="content_left">
<div class="sender_name">
- <%= link_to message.sender.name, message.sender.subject %>
+ <%= link_to truncate_name(message.sender.name), message.sender.subject %>
</div>
<div class="date">
<%= t('time.ago', :time => time_ago_in_words(message.updated_at)) %>
View
2 app/views/messages/new.html.erb
@@ -46,7 +46,7 @@
<% unless @recipient.nil? %>
- $("#_recipients").trigger("addItem",[{"title": "<%= @recipient.name %>", "value": "<%= @recipient.id %>"}]);
+ $("#_recipients").trigger("addItem",[{"title": "<%= truncate_name @recipient.name %>", "value": "<%= @recipient.id %>"}]);
<% end %>
$(".new_message").validate();
View
10 app/views/notifications/_notification.html.erb
@@ -2,9 +2,13 @@
<div class="notification"></div>
<div class="sender_photo">
- <%= link_to image_tag(notification.object.sender.logo.url(:actor),
- :title => notification.object.sender.name, :alt => notification.object.sender.name),
- notification.object.sender.subject %>
+ <%if notification.object.nil? %>
+ <%= image_tag('logos/actor/user.png',:title => "unknown", :alt => "unknown")%>
+ <%else%>
+ <%= link_to image_tag(notification.object.sender.logo.url(:actor),
+ :title => notification.object.sender.name, :alt => notification.object.sender.name),
+ notification.object.sender.subject %>
+ <%end%>
</div>
<div class="content_left">
<div class="date">
View
4 app/views/objects/_new.html.erb
@@ -7,8 +7,8 @@
<%= render :partial => object.class.to_s.tableize+'/fields' , :locals => {:f => f} %>
<% if current_subject != receiver %>
- <% receiver.activity_relations(current_subject, :from => :receiver).each do |r| %>
+ <% current_subject.activity_relations(receiver, :from => :receiver).each do |r| %>
<%= f.hidden_field "_relation_ids][", :value => r.id %>
<% end %>
<% end %>
-<% end %>
+<% end %>
View
14 app/views/profiles/edit.html.erb
@@ -80,12 +80,6 @@ end %>
<% end %>
<% if !params[:section].present? or params[:section].eql?("about_me") %>
- <% content_for :javascript do %>
- $(function () {
- $( "#profile_birthday" ).datepicker({ yearRange: '1900:<%= Time.now.utc.to_date.year%>',
- changeYear: true, maxDate: '+0d', defaultDate: '-30y'});
- });
- <% end %>
<div class="row">
<div class="form_row">
<h2><%=t('profile.' + current_subject.class.to_s.downcase + '.info')%></h2>
@@ -94,10 +88,10 @@ end %>
<%= f.fields_for :actor do |actor_form| %>
<div class="form_row">
<div class="form_label">
- <%= f.label t('actor.name') %>
+ <%= f.label t('actor.name') %><span class="needed"> (*)</span>
</div>
<div class="form_field">
- <%= actor_form.text_field :name, :class => "required form_tag" %>
+ <%= actor_form.text_field :name, :class => "required form_tag"%>
</div>
</div>
<%end%>
@@ -118,7 +112,7 @@ end %>
<%= f.label t('profile.' + current_subject.class.to_s.downcase + '.birthday')%>
</div>
<div class="form_field">
- <%= f.text_field( :birthday , :class => "date form_tag") %>
+ <%= date_select "profile", "birthday", :order => [:day, :month, :year], :end_year=> Date.today.year, :start_year=> (Date.today.year - 100) %>
</div>
</div>
@@ -146,6 +140,7 @@ end %>
<div class="form_row">
<%= f.text_area :description, :maxlength => 200, :rows => 10, :class => "form_tag_long" %>
</div>
+ <div class="form_row needed"><%=t('required')%></div>
<% end %>
<% if !params[:section].present? or params[:section].eql?("contact_info") %>
<div class="form_row">
@@ -205,6 +200,7 @@ end %>
<% if params[:section].present? %>
<%= hidden_field_tag("section", params[:section]) %>
<% end %>
+
<div class="form_row space_center">
<%= f.submit t('button.update'), :class => "button" %>&nbsp;
<button class="button" onclick="window.location.href='<%= polymorphic_path(current_subject) %>';">
View
11 app/views/toolbar/_home.html.erb
@@ -1,9 +1,16 @@
-<%= render :partial => 'toolbar/logo', :locals => { :subject => current_subject, } %>
+<% content_for :headers do %>
+<%= stylesheet_link_tag "menu", :media => "screen, projection" %>
+<%= javascript_include_tag 'menu' %>
+<% end %>
+
+<%= render :partial => 'toolbar/logo', :locals => {:subject => current_subject} %>
<div class="block space_center">
</div>
-<%= render :partial => 'toolbar/home_menu' %>
+<div id="menu_lateral" class="toolbar_menu">
+ <%= yield(:toolbar_menu).empty? ? home_toolbar_menu : yield(:toolbar_menu)%>
+</div>
<div class="block space_center">
</div>
View
13 app/views/toolbar/_home_menu.html.erb
@@ -1,13 +0,0 @@
-<% content_for :headers do %>
- <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
- <%= javascript_include_tag 'menu' %>
-<% end %>
-
-<div id="menu_lateral">
- <%= render :partial => "toolbar/home_menu_options" %>
- <hr>
- Testing SimpleNavigation<br>Please move along
- <hr>
- <%= yield(:toolbar_menu).empty? ? default_toolbar_menu : yield(:toolbar_menu)%>
-</div>
-
View
41 app/views/toolbar/_home_menu_options.html.erb
@@ -1,41 +0,0 @@
-<ul class="menu">
-
-<%= menu_options[:notifications] || capture do %>
- <%= render :partial =>'toolbar/notifications_menu'%>
-<% end %>
-
-
-<%= menu_options[:messages] || capture do %>
- <%= render :partial =>'toolbar/message_menu'%>
-<% end %>
-
-<%= menu_options[:contacts] || capture do %>
- <li>
- <%= link_to( image_tag("btn/btn_friend.png", :class => "menu_icon")+t('contact.other'), '#', :id => "contacts_menu") %>
- <ul>
- <%= menu_options[:invitations] || capture do %>
- <%= render :partial =>'toolbar/invitations_menu'%>
- <% end %>
- <% current_subject.relation_customs.sort.each do |r| %>
- <li>
- <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") + r.name , contacts_path(:relation => r.id) %>
- </li>
- <% end %>
- </ul>
- </li>
-<% end %>
-
-<%= menu_options[:subjects] || capture do %>
- <%= render :partial => 'toolbar/home_menu_options_subjects' %>
-<% end %>
-
-<% if SocialStream.activity_forms.include? :document %>
- <%= menu_options[:uploads] || capture do %>
- <%= render :partial =>'toolbar/uploads_menu'%>
- <% end %>
-<% end %>
-
-
-
-</ul>
-
View
12 app/views/toolbar/_home_menu_options_subjects.html.erb
@@ -1,12 +0,0 @@
-<%= menu_options[:groups] || capture do %>
- <li>
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.other'), '#', :id => "groups_menu") %>
- <ul>
- <li>
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.new.action'), new_group_path('group' => { '_founder' => current_subject.slug })) %>
- </li>
- </ul>
- </li>
-
-<% end %>
-
View
3 app/views/toolbar/_invitations_menu.html.erb
@@ -1,3 +0,0 @@
-<li>
- <%= link_to( image_tag("btn/btn_invitation.png", :class => "menu_icon")+t('invitation.other'), new_invitation_path) %>
-</li>
View
17 app/views/toolbar/_message_menu.html.erb
@@ -1,17 +0,0 @@
-<li>
- <%= link_to( image_tag("btn/new.png", :class => "menu_icon")+t('message.other')+" (" + current_subject.mailbox.inbox(:unread => true).count.to_s + ")", '#', :id => "messages_menu") %>
- <ul>
- <li>
- <%= link_to( image_tag("btn/message_new.png", :class => "menu_icon")+ t('message.new'), new_message_path) %>
- </li>
- <li>
- <%= link_to( image_tag("btn/message_inbox.png", :class => "menu_icon")+t('message.inbox')+" (" + current_subject.mailbox.inbox(:unread => true).count.to_s + ")", conversations_path, :remote => true) %>
- </li>
- <li>
- <%= link_to( image_tag("btn/message_sentbox.png", :class => "menu_icon")+t('message.sentbox'), conversations_path(:box => :sentbox), :remote => true) %>
- </li>
- <li>
- <%= link_to( image_tag("btn/message_trash.png", :class => "menu_icon")+t('message.trash'), conversations_path(:box => :trash), :remote => true) %>
- </li>
- </ul>
-</li>
View
3 app/views/toolbar/_notifications_menu.html.erb
@@ -1,3 +0,0 @@
-<li>
- <%= link_to( image_tag("btn/btn_notification.png", :class => "menu_icon")+t('notification.other')+' ('+ current_subject.mailbox.notifications.not_trashed.unread.count.to_s+')', notifications_path) %>
-</li>
View
21 app/views/toolbar/_profile.html.erb
@@ -1,13 +1,22 @@
-<%= render :partial => 'toolbar/logo', :locals => { :subject => subject } %>
+<% content_for :headers do %>
+<%= stylesheet_link_tag "menu", :media => "screen, projection" %>
+<%= javascript_include_tag 'menu' %>
+<% end %>
-<div class="block space_center"></div>
+<%= render :partial => 'toolbar/logo', :locals => { :subject => subject } %>
-<%= render :partial => 'toolbar/profile_menu', :locals => { :subject => subject } %>
+<div class="block space_center">
+</div>
-<div class="block space_center"></div>
+<div id="menu_lateral" class="toolbar_menu">
+ <%= yield(:toolbar_menu).empty? ? profile_toolbar_menu(subject) : yield(:toolbar_menu) %>
+</div>
+<div class="block space_center">
+</div>
<%= render :partial => 'subjects/contacts', :locals => { :subject => subject } %>
-<div class="block space_center"></div>
-<div class="block space_center"></div>
+<div class="block space_center">
+</div>
+
View
15 app/views/toolbar/_profile_menu.html.erb
@@ -1,15 +0,0 @@
-<% content_for :headers do %>
- <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
- <%= javascript_include_tag 'menu' %>
-<% end %>
-
-<div id="menu_lateral">
- <ul class="menu">
- <% unless subject == current_subject %>
- <%= render :partial => "toolbar/profile_menu_tie_options", :locals => { :subject => subject } %>
- <% end %>
-
- <%= render :partial => "toolbar/profile_menu_basic_options", :locals => { :subject => subject } %>
- </ul>
-</div>
-<div class="space_center"></div>
View
5 app/views/toolbar/_profile_menu_basic_options.html.erb
@@ -1,5 +0,0 @@
-<%= menu_options[:profile] || capture do %>
- <li>
- <%= link_to( image_tag("btn/btn_edit.png", :class => "menu_icon")+t('menu.information'), [subject, :profile]) %>
- </li>
-<% end %>
View
10 app/views/toolbar/_profile_menu_options.html.erb
@@ -1,10 +0,0 @@
-<%= menu_options[:profile] || capture do %>
- <li>
- <%= link_to( image_tag("btn/btn_edit.png", :class => "menu_icon")+t('menu.information'), [subject, :profile]) %>
- </li>
-<% end %>
-
-<%= menu_options[:uploads] || capture do %>
- <%= render :partial =>'toolbar/home_menu_uploads'%>
-<% end %>
-
View
26 app/views/toolbar/_profile_menu_tie_options.html.erb
@@ -1,26 +0,0 @@
-<%= menu_options[:like] || capture do %>
- <li>
- <div class="verb_like" id="like_<%= dom_id(subject) %>">
- <%= link_like(subject)%>
- </div>
- </li>
-<% end %>
-
-<%= menu_options[:contacts] || capture do %>
- <!-- TODO: create helper -->
- <% if user_signed_in? %>
- <li >
- <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") +
- current_subject.ties_to(subject).map(&:relation_name).join(", "),
- edit_contact_path(current_subject.contact_to!(subject)) %>
- </li>
- <% end %>
-<% end %>
-
-<%= menu_options[:messages] || capture do %>
- <% if user_signed_in? %>
- <li >
- <%= link_to(image_tag("btn/btn_send.png", :class => "menu_icon")+t('message.send'), new_message_path(:receiver => subject.slug)) %>
- </li>
- <% end %>
-<% end %>
View
2 app/views/users/_index.html.erb
@@ -13,7 +13,7 @@
</div>
<div class="sub-block">
<div class="name black" >
- <%=link_to(user.name, user)%>
+ <%=link_to(truncate_name(user.name), user)%>
</div>
<div class="link">
<%= contact_to(user) %>
View
2 app/views/users/show.html.erb
@@ -17,7 +17,7 @@
<% end %>
<%= location(link_to(image_tag("btn/btn_profile.png", :class => "btn_config")+t('profile.one')+": "+
- content_tag(:span, ( sanitize @user.name), :class=>"name_group")))%>
+ content_tag(:span, ( truncate_name sanitize @user.name), :class=>"name_group")))%>
<% toolbar :profile => @user %>
View
4 config/locales/en.yml
@@ -162,6 +162,7 @@ en:
error: "Your request was unprocessable"
invited: " has invited you to SocialStream!"
join: "Invite other people to join SocialStream!"
+ join_me: "Join me at SocialStream!"
one: "Invitation"
other: "Invitations"
success: "Your invitations have successfully been sent"
@@ -236,7 +237,7 @@ en:
public:
other: "Everybody"
representation:
- action: "representing"
+ action: "as"
change: "Change"
service:
one: "Service"
@@ -300,6 +301,7 @@ en:
new: "+ New level"
relation_public:
name: "Public"
+ required: "* These fields are required"
settings:
error: "Some errors raised when saving your changes"
for: "Settings for"
View
6 config/routes.rb
@@ -27,11 +27,7 @@
end
end
- resources :contacts do
- collection do
- get 'suggestion'
- end
- end
+ resources :contacts
resources :spheres
namespace "relation" do
View
17 db/migrate/20110705103202_empty_ties_count.rb
@@ -0,0 +1,17 @@
+class EmptyTiesCount < ActiveRecord::Migration
+ def up
+ change_column :contacts, :ties_count, :integer, :default => 0
+
+ ts_status = Contact.record_timestamps
+ Contact.record_timestamps = false
+
+ Contact.all.each do |c|
+ c.update_attribute(:ties_count, 0) if c.ties_count.nil?
+ end
+
+ Contact.record_timestamps = ts_status
+ end
+
+ def down
+ end
+end
View
4 lib/generators/social_stream/base/install_generator.rb
@@ -40,6 +40,10 @@ def create_application_layout
'app/views/layouts/application.html.erb'
end
+ def create_navigation_config
+ copy_file 'navigation.rb', 'config/navigation.rb'
+ end
+
def create_migration_file
require 'rake'
Rails.application.load_tasks
View
6 lib/generators/social_stream/base/templates/initializer.rb
@@ -16,6 +16,8 @@
#
# config.objects = [ :post, :comment ]
- # Form modules to be loaded
- # config.activity_forms = [ :document, :other_module, :foo, :bar ]
+ # Form for activity objects to be loaded
+ # You can write your own activity objects
+ #
+ # config.activity_forms = [ :post, :document, :foo, :bar ]
end
View
4 lib/generators/social_stream/base/templates/navigation.rb
@@ -0,0 +1,4 @@
+# Configures your navigation
+SimpleNavigation::Configuration.run do |navigation|
+
+end
View
1 lib/social_stream-base.rb
@@ -40,6 +40,7 @@ module SocialStream
autoload :Populate, 'social_stream/populate'
autoload :Relations, 'social_stream/relations'
autoload :TestHelpers, 'social_stream/test_helpers'
+ autoload :ToolbarConfig, 'social_stream/toolbar_config'
module Controllers
autoload :Helpers, 'social_stream/controllers/helpers'
View
18 lib/social_stream/ability.rb
@@ -9,7 +9,7 @@ def initialize(subject)
alias_action :download, :to => :show
# Activity Objects
- (SocialStream.objects - [ :actor ]).map{ |obj|
+ (SocialStream.objects - [ :actor, :comment ]).map{ |obj|
obj.to_s.classify.constantize
}.each do |klass|
can :create, klass do |k| # can :create, Post do |post|
@@ -29,6 +29,22 @@ def initialize(subject)
end
end
+ can :create, Comment do |c|
+ c._activity_parent.allow?(subject, 'read')
+ end
+
+ can :read, Comment do |c|
+ c.post_activity.allow?(subject, 'read')
+ end
+
+ can :update, Comment do |c|
+ c.post_activity.allow?(subject, 'update')
+ end
+
+ can :destroy, Comment do |c|
+ c.post_activity.allow?(subject, 'destroy')
+ end
+
# Activities
can :create, Activity do |a|
a.allow?(subject, 'create')
View
2 lib/social_stream/base/version.rb
@@ -1,5 +1,5 @@
module SocialStream
module Base
- VERSION = "0.6.0".freeze
+ VERSION = "0.6.3".freeze
end
end
View
4 lib/social_stream/models/object.rb
@@ -61,6 +61,10 @@ def _contact
@_contact ||= Contact.find(_contact_id)
end
+ def _activity_parent
+ @_activity_parent ||= Activity.find(_activity_parent_id)
+ end
+
private
def create_post_activity
View
113 lib/social_stream/toolbar_config.rb
@@ -0,0 +1,113 @@
+module SocialStream