diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 595d963a846a65534cadf4eea7303415e1fbd96c..9f1432300b889132d68ba737e3e90870b422a140 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,8 @@ # the COPYRIGHT file. class ApplicationController < ActionController::Base + clear_helpers + helper :layout, :error_messages has_mobile_fu protect_from_forgery :except => :receive diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 6da08ba72b5cb8779af81609945d1a1eae820d04..15c01772e2b33d0ec8c181122ad5c5dbac7adccf 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class AspectsController < ApplicationController + helper :comments, :aspect_memberships before_filter :authenticate_user! before_filter :save_sort_order, :only => :index before_filter :ensure_page, :only => :index diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index a567fc8387374b463db33db8a884c2ec04590e21..7bf52414348c870013580d25b97b9e09ac0fb41b 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class ContactsController < ApplicationController + helper :aspect_memberships before_filter :authenticate_user! def new diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 97f0b7b8a8db70db2c4458bc8434c54aa0405c49..33a5fe97180a1a6abd5cdb0bc36304808f02dc7b 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class PeopleController < ApplicationController + helper :comments before_filter :authenticate_user!, :except => [:show] before_filter :ensure_page, :only => :show diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 94f40d72889545e6b8f51e874e424bda9f118863..ba33f6a993f21eb28416d99f41dc76cc6e23db01 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class PhotosController < ApplicationController + helper :comments before_filter :authenticate_user! respond_to :html, :json diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 114b4874164cf4a641014aa8d474fc63cdc5c6ed..943795f0632ef74afbd0e561eb4d2bc8c86345a0 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -6,8 +6,6 @@ require File.join(Rails.root, 'lib/webfinger') class RequestsController < ApplicationController before_filter :authenticate_user! - include RequestsHelper - respond_to :html def destroy diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index 7ed70b1cb908b95387a09d135be358a30ee7c84a..913ead739686a6541eb19586ead0fedbe356f5aa 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class SocketsController < ApplicationController + helper :comments include ApplicationHelper include SocketsHelper include Rails.application.routes.url_helpers diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 1eae9744878fc2628c842d7946fc221bf52b7210..2b0e89ace70fb32405cadb4b81ef4603a580c665 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class StatusMessagesController < ApplicationController + helper :comments before_filter :authenticate_user! respond_to :html @@ -25,7 +26,7 @@ class StatusMessagesController < ApplicationController end end - def bookmarklet + def bookmarklet @aspects = current_user.aspects @selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq @aspect_ids = @aspects.map{|x| x.id} diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 444c5627b6bad8ac6bebdcdea38587e73fb771fb..1a52eddb4111e3f814460f732e2a795eff2f21e9 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. class TagsController < ApplicationController + helper :comments skip_before_filter :count_requests skip_before_filter :set_invites skip_before_filter :which_action_and_user @@ -54,7 +55,7 @@ class TagsController < ApplicationController @posts = @posts.tagged_with(params[:name]) max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now - @posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time)) + @posts = @posts.where(StatusMessage.arel_table[:created_at].lteq(max_time)) @posts = @posts.includes(:comments, :photos).order('posts.created_at DESC').limit(15) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 431259e5181346369081d0cf76a4eac29400e808..343bc64fbd28d440a0df0b9dfab1651d584e4fec 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,6 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. class UsersController < ApplicationController + helper :language require File.join(Rails.root, 'lib/diaspora/ostatus_builder') require File.join(Rails.root, 'lib/diaspora/exporter') require File.join(Rails.root, 'lib/collect_user_photos') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f3c65d9a48914c9d9f83eba1f2fcc30c4a30a93a..a1b1a8b6baff044093fcd94d43e65460e533d584 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,13 +5,6 @@ module ApplicationHelper @@youtube_title_cache = Hash.new("no-title") - def next_page_path - if @controller.instance_of?(TagsController) - tag_path(@tag, :max_time => @posts.last.send(session[:sort_order].to_sym).to_i) - else - aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids]) - end - end def timeago(time, options = {}) options[:class] ||= "timeago" content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time @@ -86,8 +79,19 @@ module ApplicationHelper </li>".html_safe end + def link_for_aspect(aspect, opts={}) + opts[:params] ||= {} + params ||= {} + opts[:params] = opts[:params].merge("a_ids[]" => aspect.id, :created_at => params[:created_at]) + opts[:class] ||= "" + opts[:class] << " hard_aspect_link" + opts['data-guid'] = aspect.id + + link_to aspect.name, aspects_path( opts[:params] ), opts + end + def current_aspect?(aspect) - !@aspect.nil? && !@aspect.is_a?(Symbol) && @aspect.id == aspect.id + !@aspect.nil? && !@aspect.instance_of?(Symbol) && @aspect.id == aspect.id end def aspect_or_all_path aspect diff --git a/app/helpers/aspect_memberships_helper.rb b/app/helpers/aspect_memberships_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..8949f6e6e603868afafc6539026fcfc3126a5215 --- /dev/null +++ b/app/helpers/aspect_memberships_helper.rb @@ -0,0 +1,36 @@ +module AspectMembershipsHelper + def add_to_aspect_button(aspect_id, person_id, kontroller) + link_to image_tag('icons/monotone_plus_add_round.png'), + {:controller => kontroller, + :action => 'create', + :aspect_id => aspect_id, + :person_id => person_id}, + :remote => true, + :method => 'post', + :class => 'add button' + end + + def remove_from_aspect_button(aspect_id, person_id) + link_to image_tag('icons/monotone_check_yes.png'), + {:controller => "aspect_memberships", + :action => 'destroy', + :id => 42, + :aspect_id => aspect_id, + :person_id => person_id}, + :remote => true, + :method => 'delete', + :class => 'added button' + end + + def aspect_membership_button(aspect, contact, person) + if contact.nil? || !aspect.contacts.include?(contact) + add_to_aspect_button(aspect.id, person.id, contact_or_membership(contact)) + else + remove_from_aspect_button(aspect.id, person.id) + end + end + + def contact_or_membership(contact) + (contact.persisted?) ? 'aspect_memberships' : 'contacts' + end +end diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index bcab3a14d04be8596d66af2f1d5f4eda7c580d78..9c1a4e67838ce0fae650827faf226e3979ff05f9 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -3,15 +3,8 @@ # the COPYRIGHT file. module AspectsHelper - def link_for_aspect(aspect, opts={}) - opts[:params] ||= {} - params ||= {} - opts[:params] = opts[:params].merge("a_ids[]" => aspect.id, :created_at => params[:created_at]) - opts[:class] ||= "" - opts[:class] << " hard_aspect_link" - opts['data-guid'] = aspect.id - - link_to aspect.name, aspects_path( opts[:params] ), opts + def next_page_path + aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids], :class => 'paginate') end def remove_link(aspect) @@ -22,38 +15,9 @@ module AspectsHelper end end - def add_to_aspect_button(aspect_id, person_id, kontroller) - link_to image_tag('icons/monotone_plus_add_round.png'), - {:controller => kontroller, - :action => 'create', - :aspect_id => aspect_id, - :person_id => person_id}, - :remote => true, - :method => 'post', - :class => 'add button' - end - - def remove_from_aspect_button(aspect_id, person_id) - link_to image_tag('icons/monotone_check_yes.png'), - {:controller => "aspect_memberships", - :action => 'destroy', - :id => 42, - :aspect_id => aspect_id, - :person_id => person_id}, - :remote => true, - :method => 'delete', - :class => 'added button' - end - - def contact_or_membership(contact) - (contact.persisted?) ? 'aspect_memberships' : 'contacts' - end - - def aspect_membership_button(aspect, contact, person) - if contact.nil? || !aspect.contacts.include?(contact) - add_to_aspect_button(aspect.id, person.id, contact_or_membership(contact)) - else - remove_from_aspect_button(aspect.id, person.id) + def new_request_link(request_count) + if request_count > 0 + link_to t('requests.helper.new_requests', :count => @request_count), manage_aspects_path end end end diff --git a/app/helpers/stream_helper.rb b/app/helpers/comments_helper.rb similarity index 97% rename from app/helpers/stream_helper.rb rename to app/helpers/comments_helper.rb index 3fdb1c680468ab7be4ea9ba200a95190ed18870f..0df7ee28f1ccc6ba277b2417d82ee4f6fd46aa9e 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/comments_helper.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -module StreamHelper +module CommentsHelper GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM" def comment_toggle(count, commenting_disabled=false) if count <= 3 diff --git a/app/helpers/conversations_helper.rb b/app/helpers/conversations_helper.rb deleted file mode 100644 index e9370a658d2dfd61780692f6de1b1f73d304bd0c..0000000000000000000000000000000000000000 --- a/app/helpers/conversations_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module ConversationsHelper - def new_message_text(count) - t('conversations.helper.new_messages', :count => count) - end -end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 166e6b25489f101871ff126f72e6a3e6d1522e58..e8707e4122590bb23e57ab71b914720be11bb045 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -23,4 +23,12 @@ module LayoutHelper def javascript(*args) content_for(:head) { javascript_include_tag(*args) } end + + def new_notification_text(count) + t('notifications.helper.new_notifications', :count => count) + end + + def new_message_text(count) + t('conversations.helper.new_messages', :count => count) + end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index a49f1578cf9ae2200454d394365d0f0318a18cc2..e722797bf62fb8e4a74db8b330708258a58bcb5d 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -33,9 +33,6 @@ module NotificationsHelper t("notifications.#{target_type}", :post_author => post_author) end - def new_notification_text(count) - t('notifications.helper.new_notifications', :count => count) - end def new_notification_link(count) if count > 0 diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index b149abca8675bf0208ff11e62d32d2237599ec71..a8b16b44acfd7f50dfe8ab97d5c6a63ffc759f71 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -27,4 +27,8 @@ module PeopleHelper I18n.l bday, :format => I18n.t('date.formats.birthday_with_year') end end + + def next_page_path + person_path(@person, :max_time => @posts.last.created_at.to_i, :class => 'paginate') + end end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb deleted file mode 100644 index d54a29de2c5727bd827703386df2caa1d234dc34..0000000000000000000000000000000000000000 --- a/app/helpers/requests_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - -module RequestsHelper - - def new_request?(request_count) - 'new_requests' if request_count > 0 - end - - def new_request_link(request_count) - if request_count > 0 - link_to t('requests.helper.new_requests', :count => @request_count), manage_aspects_path - end - end -end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..9511f624e6f3b3d044f9b8acfb4de47e7b21f825 --- /dev/null +++ b/app/helpers/tags_helper.rb @@ -0,0 +1,9 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module TagsHelper + def next_page_path + tag_path(@tag, :max_time => @posts.last.created_at.to_i, :class => 'paginate') + end +end diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index f8870beba4e06ac9dbb3f73e4549d065f3732249..20e7f6b9edeef1f52b6491747f99563e51b4a1e2 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -82,7 +82,7 @@ #main_stream.stream = render 'shared/stream', :posts => @posts, :commenting_disabled => @commenting_disabled #pagination - =link_to(t('more'), person_path(@person, :page => next_page), :class => 'paginate') + =link_to(t('more'), next_page_path) - else #stream diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/comments_helper_spec.rb similarity index 95% rename from spec/helpers/stream_helper_spec.rb rename to spec/helpers/comments_helper_spec.rb index 1b2d96b49a46e4c6d03b89bbe60d7feec6712dab..7880ab4df8209458a6ee8949b3c58d3bf5ccd9b5 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/comments_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe StreamHelper do +describe CommentsHelper do before do @user = alice @aspect = @user.aspects.first