diff --git a/Gemfile b/Gemfile index 0beeab037..45000d8fb 100644 --- a/Gemfile +++ b/Gemfile @@ -73,6 +73,7 @@ gem 'jammit', '0.6.5' gem 'json', '1.5.2' gem 'vanna', :git => 'git://github.com/MikeSofaer/vanna.git' +gem 'acts_as_api' # localization @@ -128,6 +129,8 @@ group :test do gem 'cucumber-api-steps', '0.6', :require => false gem 'database_cleaner', '0.7.0' gem 'diaspora-client', :git => 'git://github.com/diaspora/diaspora-client.git' + + gem 'timecop' #"0.1.0", #:path => '~/workspace/diaspora-client' gem 'factory_girl_rails' gem 'fixture_builder', '0.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index c121db9f4..57084b935 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,6 +85,10 @@ GEM activemodel (= 3.0.11) activesupport (= 3.0.11) activesupport (3.0.11) + acts_as_api (0.3.11) + activemodel (>= 3.0.0) + activesupport (>= 3.0.0) + rack (>= 1.1.0) addressable (2.2.4) archive-tar-minitar (0.5.2) arel (2.0.10) @@ -413,6 +417,7 @@ GEM rack (>= 1.0.0) thor (0.14.6) tilt (1.3.3) + timecop (0.3.5) treetop (1.4.10) polyglot polyglot (>= 0.3.1) @@ -450,6 +455,7 @@ DEPENDENCIES SystemTimer (= 1.2.3) activerecord-import acts-as-taggable-on! + acts_as_api addressable (= 2.2.4) bundler (>= 1.0.0) capistrano (~> 2.9.0) @@ -525,6 +531,7 @@ DEPENDENCIES sod! sqlite3 thin (~> 1.3.1) + timecop twitter (= 2.0.2) typhoeus vanna! diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index db300844f..3818ae6ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,8 +13,6 @@ class ApplicationController < ActionController::Base before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) before_filter :set_grammatical_gender - prepend_before_filter :clear_gc_stats - inflection_method :grammatical_gender => :gender helper_method :all_aspects, @@ -85,10 +83,6 @@ class ApplicationController < ActionController::Base end end - def clear_gc_stats - GC.clear_stats if GC.respond_to?(:clear_stats) - end - def redirect_unless_admin unless current_user.admin? redirect_to multi_url, :notice => 'you need to be an admin to do that' @@ -135,20 +129,19 @@ class ApplicationController < ActionController::Base @tags ||= current_user.followed_tags end - def save_sort_order - if params[:sort_order].present? - session[:sort_order] = (params[:sort_order] == 'created_at') ? 'created_at' : 'updated_at' - elsif session[:sort_order].blank? - session[:sort_order] = 'created_at' - else - session[:sort_order] = (session[:sort_order] == 'created_at') ? 'created_at' : 'updated_at' - end + # @param stream_klass [Constant] + # @return [String] JSON representation of posts given a [Stream] constant. + def stream_json(stream_klass) + render_for_api :backbone, :json => stream(stream_klass).stream_posts, :root => :posts + end + + def stream(stream_klass) + authenticate_user! + stream_klass.new(current_user, :max_time => max_time) end def default_stream_action(stream_klass) - authenticate_user! - save_sort_order - @stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order) + @stream = stream(stream_klass) if params[:only_posts] render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} @@ -157,10 +150,6 @@ class ApplicationController < ActionController::Base end end - def sort_order - is_mobile_device? ? 'created_at' : session[:sort_order] - end - def max_time params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index d9268c7e9..bc983571d 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -6,21 +6,29 @@ require File.join(Rails.root, "lib", 'stream', "aspect") class AspectsController < ApplicationController before_filter :authenticate_user! - before_filter :save_sort_order, :only => :index before_filter :save_selected_aspects, :only => :index before_filter :ensure_page, :only => :index - respond_to :html, :js - respond_to :json, :only => [:show, :create] + respond_to :html, + :js, + :json def index + @backbone = true + stream_klass = Stream::Aspect aspect_ids = (session[:a_ids] ? session[:a_ids] : []) @stream = Stream::Aspect.new(current_user, aspect_ids, - :order => sort_order, - :max_time => params[:max_time].to_i) + :max_time => params[:max_time].to_i) - if params[:only_posts] - render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} + respond_with do |format| + format.html do + if params[:only_posts] + render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} + else + render 'aspects/index' + end + end + format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts } end end diff --git a/app/controllers/blocks_controller.rb b/app/controllers/blocks_controller.rb index 1065bd103..7f7fa5891 100644 --- a/app/controllers/blocks_controller.rb +++ b/app/controllers/blocks_controller.rb @@ -1,6 +1,8 @@ class BlocksController < ApplicationController before_filter :authenticate_user! + respond_to :html, :json + def create block = current_user.blocks.new(params[:block]) @@ -10,7 +12,11 @@ class BlocksController < ApplicationController else notice = {:error => t('blocks.create.failure')} end - redirect_to :back, notice + + respond_with do |format| + format.html{ redirect_to :back, notice } + format.json{ render :nothing => true, :status => 204 } + end end def destroy @@ -19,7 +25,11 @@ class BlocksController < ApplicationController else notice = {:error => t('blocks.destroy.failure')} end - redirect_to :back, notice + + respond_with do |format| + format.html{ redirect_to :back, notice } + format.json{ render :nothing => true, :status => 204 } + end end protected diff --git a/app/controllers/comment_stream_controller.rb b/app/controllers/comment_stream_controller.rb index e35579087..d09524433 100644 --- a/app/controllers/comment_stream_controller.rb +++ b/app/controllers/comment_stream_controller.rb @@ -5,7 +5,16 @@ require File.join(Rails.root, 'lib','stream', 'comments') class CommentStreamController < ApplicationController + + respond_to :html, :json + def index - default_stream_action(Stream::Comments) + @backbone = true + stream_klass = Stream::Comments + + respond_with do |format| + format.html{ default_stream_action(stream_klass) } + format.json{ stream_json(stream_klass) } + end end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ac406e773..16b5a249a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -6,8 +6,9 @@ class CommentsController < ApplicationController include ApplicationHelper before_filter :authenticate_user!, :except => [:index] - respond_to :html, :mobile, :except => :show - respond_to :js, :only => [:index] + respond_to :html, + :mobile, + :json rescue_from ActiveRecord::RecordNotFound do render :nothing => true, :status => 404 @@ -26,7 +27,7 @@ class CommentsController < ApplicationController Postzord::Dispatcher.build(current_user, @comment).post respond_to do |format| - format.js{ render(:create, :status => 201)} + format.json{ render :json => @comment.as_api_response(:backbone), :status => 201 } format.html{ render :nothing => true, :status => 201 } format.mobile{ render :partial => 'comment', :locals => {:post => @comment.post, :comment => @comment} } end @@ -44,12 +45,14 @@ class CommentsController < ApplicationController current_user.retract(@comment) respond_to do |format| format.js { render :nothing => true, :status => 204 } + format.json { render :nothing => true, :status => 204 } format.mobile{ redirect_to @comment.post } end else respond_to do |format| format.mobile {redirect_to :back} format.js {render :nothing => true, :status => 403} + format.json { render :nothing => true, :status => 403 } end end end @@ -63,13 +66,11 @@ class CommentsController < ApplicationController if @post @comments = @post.comments.includes(:author => :profile).order('created_at ASC') - render :layout => false + respond_with do |format| + format.json { render :json => @post.comments.as_api_response(:backbone), :status => 200 } + end else raise ActiveRecord::RecordNotFound.new end end - - def new - render :layout => false - end end diff --git a/app/controllers/like_stream_controller.rb b/app/controllers/like_stream_controller.rb index f0434a74e..d79f26198 100644 --- a/app/controllers/like_stream_controller.rb +++ b/app/controllers/like_stream_controller.rb @@ -5,7 +5,16 @@ require File.join(Rails.root, 'lib','stream', 'likes') class LikeStreamController < ApplicationController + + respond_to :html, :json + def index - default_stream_action(Stream::Likes) + @backbone = true + stream_klass = Stream::Likes + + respond_with do |format| + format.html{ default_stream_action(stream_klass) } + format.json{ stream_json(stream_klass) } + end end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index deedb753a..005cf41a3 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -9,19 +9,17 @@ class LikesController < ApplicationController respond_to :html, :mobile, :json def create - positive = (params[:positive] == 'true') ? true : false if target - @like = current_user.build_like(:positive => positive, :target => target) + @like = current_user.build_like(:target => target) if @like.save - Rails.logger.info("event=create type=like user=#{current_user.diaspora_handle} status=success like=#{@like.id} positive=#{positive}") + Rails.logger.info("event=create type=like user=#{current_user.diaspora_handle} status=success like=#{@like.id}") Postzord::Dispatcher.build(current_user, @like).post respond_to do |format| - format.js { render 'likes/update', :status => 201 } format.html { render :nothing => true, :status => 201 } format.mobile { redirect_to post_path(@like.post_id) } - format.json { render :json => {"id" => @like.id}, :status => 201 } + format.json{ render :json => @like.parent.as_api_response(:backbone), :status => 201 } end else render :nothing => true, :status => 422 @@ -36,13 +34,11 @@ class LikesController < ApplicationController current_user.retract(@like) respond_to do |format| format.any { } - format.js { render 'likes/update' } - format.json { render :nothing => true, :status => :ok} + format.json{ render :json => @like.parent.as_api_response(:backbone), :status => 202 } end else respond_to do |format| format.mobile { redirect_to :back } - format.js { render :nothing => true, :status => 403 } format.json { render :nothing => true, :status => 403} end end @@ -52,12 +48,18 @@ class LikesController < ApplicationController if target @likes = target.likes.includes(:author => :profile) @people = @likes.map{|x| x.author} - render :layout => false + + respond_to do |format| + format.all{ render :layout => false } + format.json{ render :json => @likes.as_api_response(:backbone) } + end else render :nothing => true, :status => 404 end end + protected + def target @target ||= if params[:post_id] current_user.find_visible_shareable_by_id(Post, params[:post_id]) diff --git a/app/controllers/mentions_controller.rb b/app/controllers/mentions_controller.rb index 2efbebe3a..879637b2a 100644 --- a/app/controllers/mentions_controller.rb +++ b/app/controllers/mentions_controller.rb @@ -5,7 +5,16 @@ require File.join(Rails.root, 'lib','stream', 'mention') class MentionsController < ApplicationController + + respond_to :html, :json + def index - default_stream_action(Stream::Mention) + @backbone = true + stream_klass = Stream::Mention + + respond_with do |format| + format.html{ default_stream_action(stream_klass) } + format.json{ stream_json(stream_klass) } + end end end diff --git a/app/controllers/multis_controller.rb b/app/controllers/multis_controller.rb index 42f73f606..5ece83fad 100644 --- a/app/controllers/multis_controller.rb +++ b/app/controllers/multis_controller.rb @@ -5,7 +5,16 @@ require File.join(Rails.root, 'lib', 'stream', 'multi') class MultisController < ApplicationController + + respond_to :html, :json + def index - default_stream_action(Stream::Multi) + @backbone = true + stream_klass = Stream::Multi + + respond_with do |format| + format.html{ default_stream_action(stream_klass) } + format.json{ stream_json(stream_klass) } + end end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index ac9c708d2..c18b9b4ce 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -84,6 +84,8 @@ class PeopleController < ApplicationController end def show + @backbone = true + @person = Person.find_from_id_or_username(params) if remote_profile_with_no_user_session? @@ -124,16 +126,15 @@ class PeopleController < ApplicationController end if params[:only_posts] - render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} + respond_to do |format| + format.html{ render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} } + end else respond_to do |format| format.all { respond_with @person, :locals => {:post_type => :all} } - format.json { - render :json => @person.to_json(:includes => params[:includes]) - } + format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts } end end - end def retrieve_remote diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 9a3210d49..1a44a8f26 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -35,6 +35,7 @@ class PostsController < ApplicationController respond_to do |format| format.xml{ render :xml => @post.to_diaspora_xml } format.mobile{render 'posts/show.mobile.haml'} + format.json{ render :json => {:posts => @post.as_api_response(:backbone)}, :status => 201 } format.any{render 'posts/show.html.haml'} end @@ -52,6 +53,7 @@ class PostsController < ApplicationController current_user.retract(@post) respond_to do |format| format.js {render 'destroy'} + format.json { render :nothing => true, :status => 204 } format.all {redirect_to multi_path} end else diff --git a/app/controllers/reshares_controller.rb b/app/controllers/reshares_controller.rb index 3e5d5a73b..8b0ba88f3 100644 --- a/app/controllers/reshares_controller.rb +++ b/app/controllers/reshares_controller.rb @@ -1,6 +1,6 @@ class ResharesController < ApplicationController before_filter :authenticate_user! - respond_to :js, :json + respond_to :json def create @reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid]) @@ -9,6 +9,6 @@ class ResharesController < ApplicationController current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root.author) end - respond_with @reshare + render :json => @reshare.as_api_response(:backbone), :status => 201 end end diff --git a/app/controllers/share_visibilities_controller.rb b/app/controllers/share_visibilities_controller.rb index b7fca1386..1c6cb9a8e 100644 --- a/app/controllers/share_visibilities_controller.rb +++ b/app/controllers/share_visibilities_controller.rb @@ -20,7 +20,7 @@ class ShareVisibilitiesController < ApplicationController @vis.hidden = !@vis.hidden if @vis.save update_cache(@vis) - render 'update' + render :nothing => true, :status => 200 return end end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index b4151a935..3717cd472 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -4,11 +4,12 @@ class StatusMessagesController < ApplicationController before_filter :authenticate_user! - + before_filter :remove_getting_started, :only => [:create] - respond_to :html - respond_to :mobile + respond_to :html, + :mobile, + :json # Called when a user clicks "Mention" on a profile page # @param person_id [Integer] The id of the person to be mentioned @@ -40,8 +41,7 @@ class StatusMessagesController < ApplicationController end def create - params[:status_message][:aspect_ids] = params[:aspect_ids] - + params[:status_message][:aspect_ids] = [*params[:aspect_ids]] normalize_public_flag! @status_message = current_user.build_post(:status_message, params[:status_message]) @@ -69,9 +69,9 @@ class StatusMessagesController < ApplicationController end respond_to do |format| - format.js { render :create, :status => 201} format.html { redirect_to :back} format.mobile{ redirect_to multi_path} + format.json{ render :json => @status_message.as_api_response(:backbone), :status => 201 } end else unless photos.empty? @@ -79,11 +79,8 @@ class StatusMessagesController < ApplicationController end respond_to do |format| - format.js { - errors = @status_message.errors.full_messages.collect { |msg| msg.gsub(/^Text/, "") } - render :json =>{:errors => errors}, :status => 422 - } - format.html {redirect_to :back} + format.json { render :nothing, :status => 403 } + format.html { redirect_to :back } end end end diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 4a98720fb..b17ffd3d4 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -7,8 +7,16 @@ require File.join(Rails.root, 'lib', 'stream', 'followed_tag') class TagFollowingsController < ApplicationController before_filter :authenticate_user! + respond_to :html, :json + def index - default_stream_action(Stream::FollowedTag) + @backbone = true + stream_klass = Stream::FollowedTag + + respond_with do |format| + format.html{ default_stream_action(stream_klass) } + format.json{ stream_json(stream_klass) } + end end # POST /tag_followings diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6289469ce..17818b8c0 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -12,19 +12,17 @@ class TagsController < ApplicationController helper_method :tag_followed? respond_to :html, :only => [:show] - respond_to :json, :only => [:index] + respond_to :json, :only => [:index, :show] def index - if params[:q] && params[:q].length > 1 && request.format.json? + if params[:q] && params[:q].length > 1 params[:q].gsub!("#", "") params[:limit] = !params[:limit].blank? ? params[:limit].to_i : 10 @tags = ActsAsTaggableOn::Tag.autocomplete(params[:q]).limit(params[:limit] - 1) prep_tags_for_javascript respond_to do |format| - format.json{ - render(:json => @tags.to_json, :status => 200) - } + format.json{ render(:json => @tags.to_json, :status => 200) } end else respond_to do |format| @@ -35,11 +33,18 @@ class TagsController < ApplicationController end def show + @backbone = true + @stream = Stream::Tag.new(current_user, params[:name], :max_time => max_time, :page => params[:page]) - if params[:only_posts] - render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} - return + respond_with do |format| + format.html do + if params[:only_posts] + render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts} + return + end + end + format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts } end end diff --git a/app/controllers/vanna_controller.rb b/app/controllers/vanna_controller.rb index 8f75b31b3..3ae86330c 100644 --- a/app/controllers/vanna_controller.rb +++ b/app/controllers/vanna_controller.rb @@ -28,7 +28,6 @@ class VannaController < Vanna::Base before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) before_filter :which_action_and_user before_filter :all_aspects - prepend_before_filter :clear_gc_stats before_filter :set_grammatical_gender def ensure_http_referer_is_set @@ -82,10 +81,6 @@ class VannaController < Vanna::Base WillPaginate::ViewHelpers.pagination_options[:next_label] = "#{I18n.t('next')} »" end - def clear_gc_stats - GC.clear_stats if GC.respond_to?(:clear_stats) - end - def redirect_unless_admin unless current_user.admin? redirect_to multi_path, :notice => 'you need to be an admin to do that' diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 83561dfb6..0440f60a2 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -11,21 +11,21 @@ module StreamHelper elsif controller.instance_of?(PeopleController) local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(TagFollowingsController) - tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(CommunitySpotlightController) - spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(MentionsController) - mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(MultisController) - multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(PostsController) - public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(AspectsController) - aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order]) + aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids) elsif controller.instance_of?(LikeStreamController) - like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(CommentStreamController) - comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) else raise 'in order to use pagination for this new controller, update next_page_path in stream helper' end @@ -40,11 +40,7 @@ module StreamHelper end def time_for_sort(post) - if controller.instance_of?(AspectsController) - post.send(session[:sort_order].to_sym) - else - post.created_at - end + post.created_at end def comments_expanded diff --git a/app/models/aspect.rb b/app/models/aspect.rb index c87d60c93..a1241b5d6 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -11,7 +11,7 @@ class Aspect < ActiveRecord::Base has_many :aspect_visibilities has_many :posts, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Post' has_many :photos, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Photo' - + validates :name, :presence => true, :length => { :maximum => 20 } validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false diff --git a/app/models/comment.rb b/app/models/comment.rb index 21d42f091..f8de11dad 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -16,6 +16,16 @@ class Comment < ActiveRecord::Base extract_tags_from :text before_create :build_tags + # NOTE API V1 to be extracted + acts_as_api + api_accessible :backbone do |t| + t.add :id + t.add :guid + t.add :text + t.add :author + t.add :created_at + end + xml_attr :text xml_attr :diaspora_handle diff --git a/app/models/like.rb b/app/models/like.rb index 01a8b7d5b..5466bddd1 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -11,6 +11,15 @@ class Like < ActiveRecord::Base xml_attr :target_type include Diaspora::Relayable + # NOTE API V1 to be extracted + acts_as_api + api_accessible :backbone do |t| + t.add :id + t.add :guid + t.add :author + t.add :created_at + end + xml_attr :positive xml_attr :diaspora_handle diff --git a/app/models/person.rb b/app/models/person.rb index 86a4d4121..a9713901c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -10,13 +10,28 @@ class Person < ActiveRecord::Base include Encryptor::Public include Diaspora::Guid + # NOTE API V1 to be extracted + acts_as_api + api_accessible :backbone do |t| + t.add :id + t.add :name + t.add lambda { |person| + person.diaspora_handle + }, :as => :diaspora_id + t.add lambda { |person| + {:small => person.profile.image_url(:small), + :medium => person.profile.image_url(:medium), + :large => person.profile.image_url(:large) } + }, :as => :avatar + end + xml_attr :diaspora_handle xml_attr :url xml_attr :profile, :as => Profile xml_attr :exported_key has_one :profile, :dependent => :destroy - delegate :last_name, :to => :profile + delegate :last_name, :image_url, :to => :profile accepts_nested_attributes_for :profile before_validation :downcase_diaspora_handle @@ -59,7 +74,7 @@ class Person < ActiveRecord::Base scope :profile_tagged_with, lambda{|tag_name| joins(:profile => :tags).where(:profile => {:tags => {:name => tag_name}}).where('profiles.searchable IS TRUE') } - scope :who_have_reshared_a_users_posts, lambda{|user| + scope :who_have_reshared_a_users_posts, lambda{|user| joins(:posts).where(:posts => {:root_guid => StatusMessage.guids_for_author(user.person), :type => 'Reshare'} ) } @@ -274,7 +289,7 @@ class Person < ActiveRecord::Base def self.url_batch_update(people, url) people.each do |person| person.update_url(url) - end + end end # @param person [Person] diff --git a/app/models/photo.rb b/app/models/photo.rb index 759e12924..80d37327e 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -8,6 +8,20 @@ class Photo < ActiveRecord::Base include Diaspora::Commentable include Diaspora::Shareable + # NOTE API V1 to be extracted + acts_as_api + api_accessible :backbone do |t| + t.add :id + t.add :guid + t.add :created_at + t.add :author + t.add lambda { |photo| + { :small => photo.url(:thumb_small), + :medium => photo.url(:thumb_medium), + :large => photo.url(:scaled_full) } + }, :as => :sizes + end + mount_uploader :processed_image, ProcessedImage mount_uploader :unprocessed_image, UnprocessedImage diff --git a/app/models/post.rb b/app/models/post.rb index 109943797..82b952e5c 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -9,6 +9,41 @@ class Post < ActiveRecord::Base include Diaspora::Commentable include Diaspora::Shareable + attr_accessor :user_like + + # NOTE API V1 to be extracted + acts_as_api + api_accessible :backbone do |t| + t.add :id + t.add :guid + t.add lambda { |post| + post.raw_message + }, :as => :text + t.add :public + t.add :created_at + t.add :comments_count + t.add :likes_count + t.add :reshares_count + t.add :last_three_comments + t.add :provider_display_name + t.add :author + t.add :post_type + t.add :photos_count + t.add :image_url + t.add :object_url + t.add :root + t.add :o_embed_cache + t.add :user_like + t.add :mentioned_people + t.add lambda { |post| + if post.photos_count > 0 + post.photos + else + [] + end + }, :as => :photos + end + xml_attr :provider_display_name has_many :mentions, :dependent => :destroy @@ -23,6 +58,24 @@ class Post < ActiveRecord::Base #scopes scope :includes_for_a_stream, includes(:o_embed_cache, {:author => :profile}, :mentions => {:person => :profile}) #note should include root and photos, but i think those are both on status_message + def post_type + self.class.name + end + + def raw_message + "" + end + + def mentioned_people + [] + end + + # gives the last three comments on the post + def last_three_comments + return if self.comments_count == 0 + self.comments.includes(:author => :profile).last(3) + end + def self.excluding_blocks(user) people = user.blocks.includes(:person).map{|b| b.person} diff --git a/app/models/profile.rb b/app/models/profile.rb index 4978bc80a..f2dd39068 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -29,10 +29,10 @@ class Profile < ActiveRecord::Base before_save :strip_names after_validation :strip_names - + validates :first_name, :length => { :maximum => 32 } validates :last_name, :length => { :maximum => 32 } - + validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true validate :max_tags diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 7d945ff62..e7a0815d8 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -29,6 +29,10 @@ class Reshare < Post self.root.author.diaspora_handle end + def raw_message + self.root ? root.raw_message : "" + end + def receive(recipient, sender) local_reshare = Reshare.where(:guid => self.guid).first if local_reshare && local_reshare.root.author_id == recipient.person.id diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 6057f6c0f..f8a172425 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -40,6 +40,10 @@ class StatusMessage < Post joins(:likes).where(:likes => {:author_id => person.id}) } + def photos_count + self.photos.size + end + def self.guids_for_author(person) Post.connection.select_values(Post.where(:author_id => person.id).select('posts.guid').to_sql) end diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index bfd2cc43d..a2e7d0867 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -4,18 +4,20 @@ %ul#aspect_nav.left_nav %li.all_aspects - .root_element= link_to t('aspects.index.your_aspects'), aspects_path + .root_element + = link_to t('aspects.index.your_aspects'), aspects_path - %ul.sub_nav - - if defined?(stream) - %a.toggle_selector{:href => '#'} - = stream.for_all_aspects? ? t('.deselect_all') : t('.select_all') - - for aspect in all_aspects - %li{:data => {:aspect_id => aspect.id}, :class => ("active" if defined?(stream) && stream.aspect_ids.include?(aspect.id))} - .edit - = link_to image_tag("icons/pencil.png", :title => t('.edit_aspect', :name => aspect.name)), edit_aspect_path(aspect), :rel => "facebox" - %a.aspect_selector{:href => aspects_path("a_ids[]" => aspect.id), :class => "name", 'data-guid' => aspect.id} - = aspect + - if @stream.is_a?(Stream::Aspect) + %ul.sub_nav + - if defined?(stream) + %a.toggle_selector{:href => '#'} + = stream.for_all_aspects? ? t('.deselect_all') : t('.select_all') + - for aspect in all_aspects + %li{:data => {:aspect_id => aspect.id}, :class => ("active" if defined?(stream) && stream.aspect_ids.include?(aspect.id))} + .edit + = link_to image_tag("icons/pencil.png", :title => t('.edit_aspect', :name => aspect.name)), edit_aspect_path(aspect), :rel => "facebox" + %a.aspect_selector{:href => aspects_path("a_ids[]" => aspect.id), :class => "name", 'data-guid' => aspect.id} + = aspect - %li - = link_to t('.add_an_aspect'), new_aspect_path, :class => "new_aspect", :rel => "facebox" + %li + = link_to t('.add_an_aspect'), new_aspect_path, :class => "new_aspect", :rel => "facebox" diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index f33cdc13f..5ac91a4ff 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -3,13 +3,6 @@ -# the COPYRIGHT file. #aspect_stream_header - #sort_by - = t('streams.recently') - %span.controls - = link_to_if(session[:sort_order] == 'created_at', t('streams.commented_on'), stream.link(:sort_order => 'updated_at')) - · - = link_to_if(session[:sort_order] == 'updated_at', t('streams.posted'), stream.link(:sort_order => 'created_at' )) - %h3 = stream.title @@ -18,11 +11,13 @@ #gs-shim{:title => popover_with_close_html("3. #{t('.stay_updated')}"), 'data-content' => t('.stay_updated_explanation')} -#main_stream.stream{:data => {:guids => stream.aspect_ids.join(','), :time_for_scroll => time_for_scroll(stream.ajax_stream?, stream)}} - - if !stream.ajax_stream? && stream.stream_posts.length > 0 +#main_stream.stream{:data => {:guids => stream.aspect_ids.join(','), :time_for_scroll => (@backbone ? '' : time_for_scroll(stream.ajax_stream?, stream))}} + - if !@backbone && !stream.ajax_stream? && stream.stream_posts.length > 0 = render 'shared/stream', :posts => stream.stream_posts - #pagination - =link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate') + + - if !@backbone + #pagination + =link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate') - if current_user.contacts.size < 2 = render 'aspects/no_contacts_message' diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 52af3a682..278899a73 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -31,38 +31,35 @@ .section %ul.left_nav %li - %b - = link_to t("streams.multi.title"), multi_path, :class => 'home_selector' + = link_to t("streams.multi.title"), multi_path, :class => 'home_selector' - .section = render 'aspects/aspect_listings', :stream => @stream - .section %ul.left_nav %li - %b - = link_to t('streams.mentions.title'), mentions_path, :class => 'home_selector' + = link_to t('streams.mentions.title'), mentions_path, :class => 'home_selector' - .section %ul.left_nav %li - %b - = link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector' + = link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector' - .section %ul.left_nav %li - %b - = link_to t('streams.like_stream.title'), like_stream_path, :class => 'home_selector' + = link_to t('streams.like_stream.title'), like_stream_path, :class => 'home_selector' - .section#followed_tags_listing - = render 'tags/followed_tags_listings' + #followed_tags_listing + = render 'tags/followed_tags_listings' .span-13.append-1 #aspect_stream_container.stream_container = render 'aspects/aspect_stream', :stream => @stream .span-5.rightBar.last - = render 'aspects/selected_contacts', :stream => @stream + /= render 'aspects/selected_contacts', :stream => @stream + #selected_aspect_contacts.section + .title.no_icon + %h5 + = @stream.title + .content = render 'shared/right_sections' diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index e9840a2f2..8473159fe 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,7 @@ +App.stream.collection.get(<%= @comment.post.id %>); + +console.log(post); + ContentUpdater.addCommentToPost("<%= @comment.post.guid %>", "<%= @comment.guid%>", "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person, :post => @comment.post}))%>"); diff --git a/app/views/conversations/index.haml b/app/views/conversations/index.haml index 552719238..44ace12c2 100644 --- a/app/views/conversations/index.haml +++ b/app/views/conversations/index.haml @@ -20,18 +20,18 @@ = t('.inbox') #conversation_inbox - - if @conversations.count > 0 - .stream.conversations + .stream.conversations + - if @conversations.count > 0 = render :partial => 'conversations/conversation', :collection => @conversations, :locals => {:authors => @authors, :unread_counts => @unread_counts} + - else + %br + %br + %br + %br + %div{:style => 'text-align:center;'} + %i + = t('.no_messages') = will_paginate @conversations - - else - %br - %br - %br - %br - %div{:style => 'text-align:center;'} - %i - = t('.no_messages') .span-15.prepend-9.last diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index f1e3eb9d0..b5e7e0137 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -3,85 +3,10 @@ -# the COPYRIGHT file. .container{:style => "position:relative;"} + = link_to image_tag('logo_small.png', :height => "16px", :width => "161px", :style => 'position:relative;top:5px;'), root_path - - if current_user - = link_to image_tag('logo_small.png', :height => "16px", :width => "161px", :class => "diaspora_header_logo"), multi_path - - else - = link_to image_tag('logo_large.png', :height => "32px", :width => "321px", :class => "diaspora_header_logo"), root_path - - - if !current_user - .right - %ul#landing_nav - %li= link_to '@joindiaspora', "http://twitter.com/joindiaspora" - %li= link_to 'github', "https://github.com/diaspora/diaspora" - %li= link_to t('.blog'), 'http://blog.joindiaspora.com/' - %li= link_to t('.login'), new_user_session_path, :class => 'login' - - - elsif (current_user || !@landing_page) - #global_search - = form_tag(people_path, :method => 'get', :class => "search_form") do - = text_field_tag 'q', params[:q], :placeholder => t('find_people'), :type => 'search', :results => 5 - - #nav_badges - #home_badge.badge - = link_to multi_path, :title => t('_home') do - = image_tag 'icons/home_grey.png', :alt => t('_home') - - #notification_badge.badge - = link_to notifications_path, :title => new_notification_text(@notification_count) do - = image_tag 'icons/notifications_grey.png', :id => "notification-flag", :alt => new_notification_text(@notification_count) - .badge_count{:class => ("hidden" if @notification_count == 0)} - = @notification_count - - #message_inbox_badge.badge - = link_to conversations_path, :title => new_message_text(@unread_message_count) do - = image_tag 'icons/mail_grey.png', :alt => new_message_text(@unread_message_count) - .badge_count{:class => ("hidden" if @unread_message_count == 0)} - = @unread_message_count - - #notification_dropdown - .header - .right - = link_to t('notifications.index.mark_all_as_read'), read_all_notifications_path - \| - = link_to t('.view_all'), notifications_path, :id => "view_all_notifications" - %h4 - = t('.recent_notifications') - .notifications - .ajax_loader - = image_tag("ajax-loader.gif") - - #hovercard_container - #hovercard - %img.avatar - %h4 - %a.person - %p.handle - #hovercard_dropdown_container - - .hovercard_footer - .footer_container - .hashtags - - %ul#user_menu.dropdown - %li - .right - ▼ - .avatar - = owner_image_tag(:thumb_small) - = link_to current_user.name, '#', :title => current_user.diaspora_handle - %li= link_to t('.profile'), local_or_remote_person_path(current_user.person) - %li= link_to t('_contacts'), contacts_link - %li= link_to t('.settings'), edit_user_path - -if current_user.admin? - %li= link_to t('.admin'), user_search_path - %li= link_to t('.logout'), destroy_user_session_path - - #lightbox - #lightbox-content - = link_to "[x] close", '#', :id => 'lightbox-close-link' - %img#lightbox-image - #lightbox-imageset - - #lightbox-backdrop - + %ul#landing_nav + %li= link_to '@joindiaspora', "http://twitter.com/joindiaspora" + %li= link_to 'github', "https://github.com/diaspora/diaspora" + %li= link_to t('.blog'), 'http://blog.joindiaspora.com/' + %li= link_to t('.login'), new_user_session_path, :class => 'login' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8283cc228..824b39d00 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -17,6 +17,26 @@ %link{:rel => 'shortcut icon', :href => '/favicon.png'} %link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'} + :css + @-webkit-keyframes fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } + } + + @-webkit-keyframes spin { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } + } + + .loaded { + -webkit-animation: fade-in 0.16s linear; + } + + .loader { + -webkit-animation: spin 1s infinite ease-in-out, + fade-in 0.2s ease-in; + } + / Social Media Icons are by Paul Robert Lloyd @ http://paulrobertlloyd.com/2009/06/social_media_icons / bootstrap/blueprint switch @@ -44,9 +64,15 @@ Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}"); Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}"; + - if current_user + :javascript + app.user({ + current_user: _.extend(#{current_user.person.as_api_response(:backbone).to_json}, {notifications_count : #{@notification_count}, unread_messages_count : #{@unread_message_count}}) + }); + = yield(:head) - -unless Rails.env == "production" + -unless Rails.env == "production" :css .translation_missing { color: purple; @@ -64,14 +90,13 @@ .message = msg - - unless @landing_page - %a{:id=>"back-to-top", :title=>"Back to top", :href=>"#"} - ⇧ - #notifications - %header{:class=>('landing' unless current_user)} - = render 'layouts/header' + - unless current_user + %header + = render 'layouts/header' + + = render 'templates/templates' .container{:style=> "#{yield(:break_the_mold)}"} - if @aspsect == :getting_started || @page == :logged_out diff --git a/app/views/likes/update.js.erb b/app/views/likes/update.js.erb deleted file mode 100644 index 1eaa8dfe2..000000000 --- a/app/views/likes/update.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -var targetGuid = "<%=@like.target.guid%>"; -$(".like_action", "#"+targetGuid).first().html("<%= escape_javascript(like_action(@like.target))%>"); -ContentUpdater.addLikesToPost(targetGuid, "<%= escape_javascript(render("likes/likes_container", :target_id => @like.target_id, :likes_count => @like.target.reload.likes_count, :target_type => @like.target_type)) %>"); diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 5fcb79d02..02e3c94d8 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -27,14 +27,15 @@ = render 'people/sub_header', :person => @person, :contact => @contact / hackity hack until we get a photo stream - - if (@posts && @posts.length > 0) || (@stream && @stream.stream_posts.length > 0) + - if @backbone && (@posts && @posts.length > 0) || (@stream && @stream.stream_posts.length > 0) -if @post_type == :photos = render 'photos/index', :photos => @posts - else #main_stream.stream - = render 'shared/stream', :posts => @stream.stream_posts - #pagination - =link_to(t('more'), next_page_path, :class => 'paginate') + - if !@backbone + = render 'shared/stream', :posts => @stream.stream_posts + #pagination + =link_to(t('more'), next_page_path, :class => 'paginate') - else #main_stream diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 8988b30b9..ccfd73eab 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -72,10 +72,6 @@ if ( $('.publisher_photo').length == 0){ textarea.removeClass("with_attachments"); textarea.css('paddingBottom', ''); - - if( $('#status_message_text').attr("value") == ""){ - Publisher.close() - } } }); } diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index effc52129..9ecf343dc 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -5,10 +5,10 @@ .span-20.append-2.prepend-2.last #main_stream.stream.status_message_show - - if @post.is_a?(Photo) - = render 'posts/photo', :post => @post - - else - = render 'shared/stream_element', :post => @post, :commenting_disabled => commenting_disabled?(@post) + /- if @post.is_a?(Photo) + / = render 'posts/photo', :post => @post + /- else + / = render 'shared/stream_element', :post => @post, :commenting_disabled => commenting_disabled?(@post) %br %br %br diff --git a/app/views/reshares/create.js.erb b/app/views/reshares/create.js.erb deleted file mode 100644 index 402afd731..000000000 --- a/app/views/reshares/create.js.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% if @reshare.persisted? %> - $('.stream_element#<%=params[:root_guid]%>').addClass('reshared'); - ContentUpdater.addPostToStream( - "<%= escape_javascript(render(:partial => 'shared/stream_element', :locals => {:post => @reshare }))=%>" - ); - <% else %> - Diaspora.page.flashMessages.render({success:false, - notice: "<%= reshare_error_message(@reshare) %>"}); -<% end %> diff --git a/app/views/share_visibilities/update.js.erb b/app/views/share_visibilities/update.js.erb deleted file mode 100644 index f679cdb68..000000000 --- a/app/views/share_visibilities/update.js.erb +++ /dev/null @@ -1,10 +0,0 @@ -var target = $("#<%= @post.guid %>") -target.find(".sm_body").toggleClass("hidden"); -target.find(".undo_text").toggleClass("hidden"); -target.find(".hide_loader").toggleClass("hidden"); - -var hide_icon = target.find(".stream_element_delete") -if (target.find(".undo_text").hasClass("hidden")) { - hide_icon.toggleClass("hidden"); - target.find(".hide_loader").toggleClass("hidden"); -} diff --git a/app/views/shared/_publisher.html.haml b/app/views/shared/_publisher.html.haml index 3651113b9..1dc432cc7 100644 --- a/app/views/shared/_publisher.html.haml +++ b/app/views/shared/_publisher.html.haml @@ -2,29 +2,15 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -:javascript - $(function() { - $(".question_mark").twipsy({trigger: 'hover', placement: 'bottom'}); - $(".service_icon").twipsy({trigger: 'hover', placement: 'bottom'}); - $(".public_icon").twipsy({trigger: 'hover', placement: 'bottom'}); - }); - -- if publisher_open - :javascript - $(document).ready(function() { - Publisher.open(); - }); - -if publisher_explain :javascript - $(document).ready(function() - { + $(document).ready(function() { Publisher.triggerGettingStarted(); }); -#publisher.closed{:class => ((aspect == :profile)? 'mention_popup' : nil )} +#publisher{:class => ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")} .content_creation - = form_for(StatusMessage.new, :remote => remote?, :html => {"data-type" => "json"}) do |status| + = form_for(StatusMessage.new) do |status| = status.error_messages %p %params @@ -81,7 +67,7 @@ - for aspect in all_aspects = aspect_dropdown_list_item(aspect, !all_aspects_selected?(selected_aspects) && selected_aspects.include?(aspect) ) - = status.submit t('.share'), :disable_with => t('.posting'), :class => 'button creation', :tabindex => 2 + = status.submit t('.share'), :disabled => publisher_hidden_text.blank?, :class => 'button creation', :tabindex => 2 .facebox_content #question_mark_pane diff --git a/app/views/status_messages/create.js.erb b/app/views/status_messages/create.js.erb deleted file mode 100644 index 7d2d2a0eb..000000000 --- a/app/views/status_messages/create.js.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= {:html => render( - :partial => 'shared/stream_element', - :locals => { - :post => @status_message, - :author => @status_message.author, - :photos => @status_message.photos, - :comments => [], - :all_aspects => current_user.aspects, - :reshare => nil - } - ), - :post_id => @status_message.guid}.to_json.html_safe%> diff --git a/app/views/status_messages/new.html.haml b/app/views/status_messages/new.html.haml index 0ed7386ae..f6cb104bc 100644 --- a/app/views/status_messages/new.html.haml +++ b/app/views/status_messages/new.html.haml @@ -12,8 +12,7 @@ Publisher.autocompletion.onSelect($("#status_message_fake_text"),person,'#{@person.name}'); $("#publisher #status_message_fake_text").val(function(index, value){ return value + " " }); $("#publisher").bind('ajax:success', function(){location.reload();}); - Publisher.bookmarklet =true; - Publisher.open(); + Publisher.bookmarklet = true; }); #new_status_message_pane diff --git a/app/views/tags/_followed_tags_listings.haml b/app/views/tags/_followed_tags_listings.haml index ff19f21d9..30bed3e9f 100644 --- a/app/views/tags/_followed_tags_listings.haml +++ b/app/views/tags/_followed_tags_listings.haml @@ -7,14 +7,15 @@ %li %b=link_to t('streams.followed_tag.title'), tag_followings_path, :class => 'home_selector' - %ul.sub_nav - - if tags.size > 0 - - for tg in tags - %li.unfollow{:id => "tag-following-#{tg.name}"} - .unfollow_icon.hidden - = link_to image_tag("icons/monotone_close_exit_delete.png", :height => 16, :title => t('aspects.index.unfollow_tag', :tag => tg.name)), tag_tag_followings_path(:name => tg.name, :remote => true), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :id => "unfollow_" + tg.name - = link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector" - %li - = form_for TagFollowing.new do |tg| - = text_field_tag :name, "", :class => "tag_input", :placeholder => t('streams.followed_tag.add_a_tag') - = tg.submit t('streams.followed_tag.follow'), :class => "button hidden" + - if @stream.is_a?(Stream::FollowedTag) + %ul.sub_nav + - if tags.size > 0 + - for tg in tags + %li.unfollow{:id => "tag-following-#{tg.name}"} + .unfollow_icon.hidden + = link_to image_tag("icons/monotone_close_exit_delete.png", :height => 16, :title => t('aspects.index.unfollow_tag', :tag => tg.name)), tag_tag_followings_path(:name => tg.name, :remote => true), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :id => "unfollow_" + tg.name + = link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector" + %li + = form_for TagFollowing.new do |tg| + = text_field_tag :name, "", :class => "tag_input", :placeholder => t('streams.followed_tag.add_a_tag') + = tg.submit t('streams.followed_tag.follow'), :class => "button hidden" diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index 8d8ca74d8..3b563fec4 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -67,10 +67,11 @@ %hr #main_stream.stream - - if @stream.stream_posts.length > 0 - = render 'shared/stream', :posts => @stream.stream_posts - #pagination - =link_to(t('more'), next_page_path, :class => 'paginate') - - else - = t('.nobody_talking', :tag => @stream.display_tag_name) + - if !@backbone + - if @stream.stream_posts.length > 0 + = render 'shared/stream', :posts => @stream.stream_posts + #pagination + =link_to(t('more'), next_page_path, :class => 'paginate') + - else + = t('.nobody_talking', :tag => @stream.display_tag_name) diff --git a/app/views/templates/_templates.haml b/app/views/templates/_templates.haml new file mode 100644 index 000000000..db497c8e2 --- /dev/null +++ b/app/views/templates/_templates.haml @@ -0,0 +1,18 @@ +-# Copyright (c) 2010-2011, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +- ["header", + "feedback", + "static_text", + "stream_element", + "comment_stream", + "comment", + "status_message", + "activity_streams_photo", + "reshare", + "likes_info", + "stream_faces"].each do |template_name| + + %script{:id => "#{template_name.gsub("_","-")}-template", :type => 'text/template'} + != File.read("#{Rails.root}/app/views/templates/#{template_name}.jst") diff --git a/app/views/templates/activity_streams_photo.jst b/app/views/templates/activity_streams_photo.jst new file mode 100644 index 000000000..1c779bf95 --- /dev/null +++ b/app/views/templates/activity_streams_photo.jst @@ -0,0 +1,3 @@ + + + diff --git a/app/views/templates/comment.jst b/app/views/templates/comment.jst new file mode 100644 index 000000000..d6b355387 --- /dev/null +++ b/app/views/templates/comment.jst @@ -0,0 +1,28 @@ +
+ + <% if(author.id === current_user.id) { %> + + Deletelabel + + <% } %> +
+ + + + + +
+ + + <%= author.name %> + + + +

+ <%= text %> +

+ +
+
+
diff --git a/app/views/templates/comment_stream.jst b/app/views/templates/comment_stream.jst new file mode 100644 index 000000000..c47efedef --- /dev/null +++ b/app/views/templates/comment_stream.jst @@ -0,0 +1,29 @@ +<% if(typeof(all_comments_loaded) == 'undefined' || !all_comments_loaded) { %> + +<% } %> + + + +<% if(current_user) { %> +
+
+ + + + +

+ +