diff --git a/Gemfile b/Gemfile index b5df343a6..96d233a77 100644 --- a/Gemfile +++ b/Gemfile @@ -38,9 +38,10 @@ end group :heroku do gem 'pg' + gem 'mysql' end -gem 'settingslogic', '2.0.6' +gem 'settingslogic', :git => 'git://github.com/binarylogic/settingslogic.git' # database gem 'activerecord-import' diff --git a/Gemfile.lock b/Gemfile.lock index 6beb3d254..755db741c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,6 +15,12 @@ GIT json rails (>= 3.0.0) +GIT + remote: git://github.com/binarylogic/settingslogic.git + revision: 4884d455bf18d92723cb8190cfd2dbf87f3aafd5 + specs: + settingslogic (2.0.8) + GIT remote: git://github.com/diaspora/acts-as-taggable-on.git revision: c3592fe1a906f6ff1cd12766c5cf1152c51eec40 @@ -237,6 +243,7 @@ GEM gem_plugin (>= 0.2.3) multi_json (1.0.4) multipart-post (1.1.4) + mysql (2.8.1) mysql2 (0.2.17) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -360,7 +367,6 @@ GEM ffi (~> 1.0.9) multi_json (~> 1.0.4) rubyzip - settingslogic (2.0.6) simple_oauth (0.1.5) sinatra (1.2.8) rack (~> 1.1) @@ -450,6 +456,7 @@ DEPENDENCIES mobile-fu mock_redis mongrel + mysql mysql2 (= 0.2.17) newrelic_rpm nokogiri (~> 1.5.0) @@ -479,7 +486,7 @@ DEPENDENCIES ruby-oembed sass selenium-webdriver (~> 2.16.0) - settingslogic (= 2.0.6) + settingslogic! sqlite3 thin (~> 1.3.1) timecop diff --git a/Procfile b/Procfile index e65f16603..f8e7db76b 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -web: bundle exec rails s -p $PORT +web: bundle exec rails s thin -p $PORT redis: redis-server worker: QUEUE=* bundle exec rake resque:work diff --git a/app/controllers/aspect_memberships_controller.rb b/app/controllers/aspect_memberships_controller.rb index d75832bbf..89327f420 100644 --- a/app/controllers/aspect_memberships_controller.rb +++ b/app/controllers/aspect_memberships_controller.rb @@ -54,29 +54,7 @@ class AspectMembershipsController < ApplicationController end end - def update - @person = Person.find(params[:person_id]) - @from_aspect = current_user.aspects.where(:id => params[:aspect_id]).first - @to_aspect = current_user.aspects.where(:id => params[:to]).first - - response_hash = { } - - unless current_user.move_contact( @person, @to_aspect, @from_aspect) - flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect - end - if aspect = current_user.aspects.where(:id => params[:to]).first - response_hash[:notice] = I18n.t 'aspects.move_contact.success' - response_hash[:success] = true - else - response_hash[:notice] = I18n.t 'aspects.move_contact.failure' - response_hash[:success] = false - end - - render :text => response_hash.to_json - end - rescue_from ActiveRecord::StatementInvalid do render :text => "Duplicate record rejected.", :status => 400 end - end diff --git a/app/controllers/community_spotlight_controller.rb b/app/controllers/community_spotlight_controller.rb deleted file mode 100644 index 837d77bdb..000000000 --- a/app/controllers/community_spotlight_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.join(Rails.root, 'lib', 'stream', 'community_spotlight') - -class CommunitySpotlightController < ApplicationController - def index - default_stream_action(Stream::CommunitySpotlight) - end -end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 30cbe1149..0857378d1 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -42,7 +42,7 @@ class PeopleController < ApplicationController #only do it if it is an email address if diaspora_id?(params[:q]) people = Person.where(:diaspora_handle => params[:q].downcase) - webfinger(params[:q]) if people.empty? + Webfinger.in_background(params[:q]) if people.empty? else people = Person.search(params[:q], current_user) end @@ -53,7 +53,7 @@ class PeopleController < ApplicationController #only do it if it is an email address if diaspora_id?(params[:q]) people = Person.where(:diaspora_handle => params[:q]) - webfinger(params[:q]) if people.empty? + Webfinger.in_background(params[:q]) if people.empty? else people = Person.search(params[:q], current_user) end @@ -131,7 +131,7 @@ class PeopleController < ApplicationController def retrieve_remote if params[:diaspora_handle] - webfinger(params[:diaspora_handle], :single_aspect_form => true) + Webfinger.in_background(params[:diaspora_handle], :single_aspect_form => true) render :nothing => true else render :nothing => true, :status => 422 @@ -161,7 +161,6 @@ class PeopleController < ApplicationController @contact = current_user.contact_for(@person) || Contact.new render :partial => 'aspect_membership_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left'} end - Webfinger.new(account, opts) end def diaspora_id?(query) @@ -169,9 +168,6 @@ class PeopleController < ApplicationController end private - def webfinger(account, opts = {}) - Webfinger.new(account, opts) - end def remote_profile_with_no_user_session? @person && @person.remote? && !user_signed_in? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7fda03658..f8f6bac23 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,7 +21,7 @@ module ApplicationHelper if language != DEFAULT_LANGUAGE translations = I18n.t('javascripts', :locale => language) - defaults.update(translations) + defaults.deep_merge!(translations) end defaults diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb new file mode 100644 index 000000000..1944752df --- /dev/null +++ b/app/helpers/posts_helper.rb @@ -0,0 +1,19 @@ +# Copyright (c) 2012, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module PostsHelper + def post_page_title(post) + if post.is_a?(Photo) + I18n.t "posts.show.photos_by", :count => 1, :author => post.status_message.author.name + elsif post.is_a?(Reshare) + I18n.t "posts.show.reshare_by", :author => post.author.name + else + if post.text.present? + truncate(post.text(:plain_text => true), :length => 20) + elsif post.respond_to?(:photos) && post.photos.present? + I18n.t "posts.show.photos_by", :count => post.photos.size, :author => post.author.name + end + end + end +end diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 7420e7cb4..44b882380 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -5,34 +5,32 @@ module StreamHelper def next_page_path(opts ={}) if controller.instance_of?(TagsController) - tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) + tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream)) elsif controller.instance_of?(AppsController) "/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}" elsif controller.instance_of?(PeopleController) - local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) + local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream)) elsif controller.instance_of?(TagFollowingsController) - 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)) + tag_followings_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(MentionsController) - mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + mentions_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(MultisController) - multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + multi_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(PostsController) - public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + public_stream_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(AspectsController) - aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids) + aspects_path(:max_time => time_for_scroll(@stream), :a_ids => @stream.aspect_ids) elsif controller.instance_of?(LikeStreamController) - like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + like_stream_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(CommentStreamController) - comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + comment_stream_path(:max_time => time_for_scroll(@stream)) else raise 'in order to use pagination for this new controller, update next_page_path in stream helper' end end - def time_for_scroll(ajax_stream, stream) - if ajax_stream || stream.stream_posts.empty? + def time_for_scroll(stream) + if stream.stream_posts.empty? (Time.now() + 1).to_i else stream.stream_posts.last.send(stream.order.to_sym).to_i diff --git a/app/models/app_config.rb b/app/models/app_config.rb index 88857781e..12e266bac 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -6,9 +6,11 @@ require 'uri' require File.join(Rails.root, 'lib', 'enviroment_configuration') class AppConfig < Settingslogic - ARRAY_VARS = [:community_spotlight, :admins] - def self.source_file_name + if ENV['application_yml'].present? + puts "using remote application.yml" + return ENV['application_yml'] + end config_file = File.join(Rails.root, "config", "application.yml") if !File.exists?(config_file) && (Rails.env == 'test' || Rails.env.include?("integration") || EnviromentConfiguration.heroku?) config_file = File.join(Rails.root, "config", "application.yml.example") @@ -121,18 +123,9 @@ HELP def self.[] (key) return self.pod_uri if key == :pod_uri - return fetch_from_env(key.to_s) if EnviromentConfiguration.heroku? super end - def fetch_from_env(key) - if ARRAY_VARS.include?(key.to_sym) - ENV[key].split(EnviromentConfiguration::ARRAY_SEPERATOR) - else - ENV[key] if ENV[key] - end - end - def self.[]= (key, value) super if key.to_sym == :pod_url diff --git a/app/models/comment.rb b/app/models/comment.rb index f8de11dad..ef1e7c3eb 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -84,5 +84,4 @@ class Comment < ActiveRecord::Base def parent= parent self.post = parent end - end diff --git a/app/models/jobs/fetch_webfinger.rb b/app/models/jobs/fetch_webfinger.rb new file mode 100644 index 000000000..3b387b6bf --- /dev/null +++ b/app/models/jobs/fetch_webfinger.rb @@ -0,0 +1,13 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module Jobs + class FetchWebfinger < Base + @queue = :socket_webfinger + + def self.perform(account) + Webfinger.new(account).fetch + end + end +end diff --git a/app/models/post.rb b/app/models/post.rb index 387ce465e..2cdfa5fd3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -36,7 +36,7 @@ class Post < ActiveRecord::Base t.add :user_like t.add :mentioned_people t.add lambda { |post| - if post.photos_count > 0 + if post.respond_to?(:photos) && post.photos_count > 0 post.photos else [] diff --git a/app/models/status_message.rb b/app/models/status_message.rb index f8a172425..7fe01de82 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -40,10 +40,6 @@ 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 @@ -177,7 +173,7 @@ class StatusMessage < Post end def update_photos_counter - StatusMessage.where(:id => self.id). + self.class.where(:id => self.id). update_all(:photos_count => self.photos.count) end @@ -192,6 +188,5 @@ class StatusMessage < Post def self.tag_stream(tag_ids) joins(:tags).where(:tags => {:id => tag_ids}) end - end diff --git a/app/models/user.rb b/app/models/user.rb index 2b9bc2362..7c91f29bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -172,17 +172,6 @@ class User < ActiveRecord::Base end ######### Aspects ###################### - - def move_contact(person, to_aspect, from_aspect) - return true if to_aspect == from_aspect - contact = contact_for(person) - - add_contact_to_aspect(contact, to_aspect) - - membership = contact ? AspectMembership.where(:contact_id => contact.id, :aspect_id => from_aspect.id).first : nil - return(membership && membership.destroy) - end - def add_contact_to_aspect(contact, aspect) return true if AspectMembership.exists?(:contact_id => contact.id, :aspect_id => aspect.id) contact.aspect_memberships.create!(:aspect => aspect) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6a5d085bf..cc6ddcad8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -65,6 +65,17 @@ - if rtl? = include_stylesheets :rtl, :media => 'all' + :javascript + // Support for older browsers + if(Array.isArray === undefined) { + Array.isArray = function (arg) { + return Object.prototype.toString.call(arg) == '[object Array]'; + }; + } + if ((window.history) && (window.history.pushState === undefined)) { + window.history.pushState = function() { }; + } + = csrf_meta_tag