Revert to including all helpers everywhere, because the rest of the team prefers it that way
This commit is contained in:
parent
efd5c4f500
commit
71e77d59b3
18 changed files with 51 additions and 41 deletions
|
|
@ -3,8 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
clear_helpers
|
|
||||||
helper :layout, :error_messages, :markdownify, :aspect_global
|
|
||||||
has_mobile_fu
|
has_mobile_fu
|
||||||
protect_from_forgery :except => :receive
|
protect_from_forgery :except => :receive
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class AspectsController < ApplicationController
|
class AspectsController < ApplicationController
|
||||||
helper :comments, :aspect_memberships, :likes
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :save_sort_order, :only => :index
|
before_filter :save_sort_order, :only => :index
|
||||||
before_filter :ensure_page, :only => :index
|
before_filter :ensure_page, :only => :index
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class ContactsController < ApplicationController
|
class ContactsController < ApplicationController
|
||||||
helper :aspect_memberships
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
class LikesController < ApplicationController
|
class LikesController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
helper :likes
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
respond_to :html, :mobile, :json
|
respond_to :html, :mobile, :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
target = current_user.find_visible_post_by_id params[:post_id]
|
target = current_user.find_visible_post_by_id params[:post_id]
|
||||||
positive = (params[:positive] == 'true') ? true : false
|
positive = (params[:positive] == 'true') ? true : false
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class PeopleController < ApplicationController
|
class PeopleController < ApplicationController
|
||||||
helper :comments, :likes
|
|
||||||
before_filter :authenticate_user!, :except => [:show]
|
before_filter :authenticate_user!, :except => [:show]
|
||||||
|
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class PhotosController < ApplicationController
|
class PhotosController < ApplicationController
|
||||||
helper :comments, :people
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
respond_to :html, :json
|
respond_to :html, :json
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file.
|
# licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file.
|
||||||
|
|
||||||
class ServicesController < ApplicationController
|
class ServicesController < ApplicationController
|
||||||
helper :aspect_memberships
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class SocketsController < ApplicationController
|
class SocketsController < ApplicationController
|
||||||
helper :comments, :likes
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include SocketsHelper
|
include SocketsHelper
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class StatusMessagesController < ApplicationController
|
class StatusMessagesController < ApplicationController
|
||||||
helper :comments, :likes
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
helper :comments, :likes
|
|
||||||
skip_before_filter :count_requests
|
skip_before_filter :count_requests
|
||||||
skip_before_filter :set_invites
|
skip_before_filter :set_invites
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
|
|
@ -41,6 +40,7 @@ class TagsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@aspect = :tag
|
||||||
if current_user
|
if current_user
|
||||||
@posts = StatusMessage.joins(:contacts).where(:pending => false).where(
|
@posts = StatusMessage.joins(:contacts).where(:pending => false).where(
|
||||||
Contact.arel_table[:user_id].eq(current_user.id).or(
|
Contact.arel_table[:user_id].eq(current_user.id).or(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
helper :language
|
|
||||||
require File.join(Rails.root, 'lib/diaspora/ostatus_builder')
|
require File.join(Rails.root, 'lib/diaspora/ostatus_builder')
|
||||||
require File.join(Rails.root, 'lib/diaspora/exporter')
|
require File.join(Rails.root, 'lib/diaspora/exporter')
|
||||||
require File.join(Rails.root, 'lib/collect_user_photos')
|
require File.join(Rails.root, 'lib/collect_user_photos')
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,6 @@ module ApplicationHelper
|
||||||
timeago(obj.created_at)
|
timeago(obj.created_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_for_sort(post)
|
|
||||||
post.created_at
|
|
||||||
end
|
|
||||||
|
|
||||||
def timeago(time, options={})
|
def timeago(time, options={})
|
||||||
options[:class] ||= "timeago"
|
options[:class] ||= "timeago"
|
||||||
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time
|
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
module AspectsHelper
|
module AspectsHelper
|
||||||
def next_page_path
|
|
||||||
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
|
|
||||||
end
|
|
||||||
|
|
||||||
def time_for_sort post
|
|
||||||
post.send(session[:sort_order].to_sym)
|
|
||||||
end
|
|
||||||
|
|
||||||
def remove_link(aspect)
|
def remove_link(aspect)
|
||||||
if aspect.contacts.size == 0
|
if aspect.contacts.size == 0
|
||||||
link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
|
link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,4 @@ module PeopleHelper
|
||||||
I18n.l bday, :format => I18n.t('date.formats.birthday_with_year')
|
I18n.l bday, :format => I18n.t('date.formats.birthday_with_year')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_page_path
|
|
||||||
person_path(@person, :max_time => @posts.last.created_at.to_i)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
23
app/helpers/stream_helper.rb
Normal file
23
app/helpers/stream_helper.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
module StreamHelper
|
||||||
|
def next_page_path
|
||||||
|
if controller.instance_of?(TagsController)
|
||||||
|
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
|
||||||
|
elsif controller.instance_of?(PeopleController)
|
||||||
|
person_path(@person, :max_time => @posts.last.created_at.to_i)
|
||||||
|
elsif controller.instance_of?(AspectsController)
|
||||||
|
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def time_for_sort post
|
||||||
|
if controller.instance_of?(AspectsController)
|
||||||
|
post.send(session[:sort_order].to_sym)
|
||||||
|
else
|
||||||
|
post.created_at
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -3,7 +3,4 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
module TagsHelper
|
module TagsHelper
|
||||||
def next_page_path
|
|
||||||
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,4 @@ describe ApplicationHelper do
|
||||||
person_link(@person).should_not include("<h1>")
|
person_link(@person).should_not include("<h1>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
describe "#time_for_sort" do
|
|
||||||
it "returns created_at" do
|
|
||||||
post = @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
|
||||||
time_for_sort(post).should == post.created_at
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
||||||
24
spec/helpers/stream_helper_spec.rb
Normal file
24
spec/helpers/stream_helper_spec.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Copyright (c) 2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe StreamHelper do
|
||||||
|
before do
|
||||||
|
@post = Factory(:status_message)
|
||||||
|
end
|
||||||
|
describe "#time_for_sort" do
|
||||||
|
it "returns sort_order for an aspectscontroller" do
|
||||||
|
sort_order = :stored_in_session
|
||||||
|
stub!(:controller).and_return(AspectsController.new)
|
||||||
|
stub!(:session).and_return({:sort_order => sort_order})
|
||||||
|
@post.should_receive(sort_order)
|
||||||
|
time_for_sort(@post)
|
||||||
|
end
|
||||||
|
it "returns post.created_at otherwise" do
|
||||||
|
stub!(:controller).and_return(mock())
|
||||||
|
time_for_sort(@post).should == @post.created_at
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue