diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 4beaa6ecd..32b71971f 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -12,8 +12,9 @@ class PostsController < ApplicationController @post = Post.first(:id => params[:id], :public => true) @landing_page = true if @post - render "posts/#{@post.class.to_s.snake_case}", :layout => true + render "posts/#{@post.class.to_s.underscore}", :layout => true else + flash[:error] = "that post does not exsist!" redirect_to root_url end end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 9850243a2..eda3fc759 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -13,29 +13,17 @@ class ServicesController < ApplicationController def create auth = request.env['omniauth.auth'] - pp auth['credentials'] - toke = auth['credentials']['token'] secret = auth['credentials']['secret'] - provider = auth['provider'] user = auth['user_info'] - if provider == 'twitter' - access_token = auth['extra']['access_token'] - current_user.services.create(:nickname => user['nickname'], - :access_token => toke, - :access_secret => secret, - :provider => provider, - :uid => auth['uid']) - - elsif provider == 'facebook' - current_user.services.create(:nickname => user['nickname'], - :access_token => auth['credentials']['token'], - :provider => provider, - :uid => auth['uid']) - end + current_user.services.create(:nickname => user['nickname'], + :access_token => toke, + :access_secret => secret, + :provider => provider, + :uid => auth['uid']) flash[:notice] = I18n.t 'services.create.success' if current_user.getting_started diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 8694d05f7..9dc63c54a 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -27,10 +27,12 @@ class StatusMessagesController < ApplicationController @status_message.photos += photos unless photos.nil? current_user.add_to_streams(@status_message, params[:status_message][:aspect_ids]) - current_user.dispatch_post(@status_message, :to => params[:status_message][:aspect_ids], :url => post_path(@status_message)) + current_user.dispatch_post(@status_message, :to => params[:status_message][:aspect_ids], :url => post_url(@status_message)) for photo in photos + photo.public = public_flag + photo.save current_user.add_to_streams(photo, params[:status_message][:aspect_ids]) current_user.dispatch_post(photo, :to => params[:status_message][:aspect_ids]) end diff --git a/app/models/user.rb b/app/models/user.rb index 6fa9b4c2a..ec8110834 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,8 @@ class User include MongoMapper::Document include Diaspora::UserModules include Encryptor::Private - + include ActionView::Helpers::TextHelper + plugin MongoMapper::Devise QUEUE = MessageHandler.new @@ -169,7 +170,14 @@ class User push_to_aspects(post, aspects_from_ids(aspect_ids)) if post.public && post.respond_to?(:message) - message = opts[:url] ? "#{post.message}%20#{opts[:url]}" : post.message + + if opts[:url] + message = truncate(post.message, :length => (140 - (opts[:url].length + 1))) + message = "#{message} #{opts[:url]}" + else + message = post.message + end + self.services.each do |service| self.send("post_to_#{service.provider}".to_sym, service, message) end @@ -193,10 +201,8 @@ class User config.oauth_token = service.access_token config.oauth_token_secret = service.access_secret end - - client = Twitter::Client.new - - client.update(message) + + Twitter.update(message) end def update_post(post, post_hash = {}) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index adfa88a44..92e06a83f 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -9,7 +9,7 @@ - else = link_to image_tag('diaspora_logo_large.png', :height => "32px", :width => "321px", :class => "diaspora_header_logo"), root_path - - unless current_user + - if !current_user .right %ul#landing_nav %li= link_to '@joindiaspora', "http://twitter.com/joindiaspora" @@ -17,7 +17,7 @@ %li= link_to t('.blog'), 'http://blog.joindiaspora.com/' %li= link_to t('.login'), new_user_session_path, :class => 'login' - - else + - elsif (current_user || !@landing_page) #global_search = form_tag(people_path, :method => 'get', :id => "global_search_form") do = text_field_tag 'q', nil, :placeholder => t('search'), :type => 'search', :results => 5 diff --git a/app/views/posts/photo.html.haml b/app/views/posts/photo.html.haml index 67e260301..bcd846459 100644 --- a/app/views/posts/photo.html.haml +++ b/app/views/posts/photo.html.haml @@ -11,7 +11,7 @@ %h2 = @post.person.name .span-14.append-1.last - #show_photo{:data=>{:guid=>@ost.id}} + #show_photo{:data=>{:guid=>@post.id}} = image_tag @post.url(:scaled_full) #caption @@ -23,14 +23,14 @@ - if @post.status_message_id #original_post_info %h4{:style=>"position:relative;"} - = t('.original_post') - = link_to t('.view'), @post.status_message + = t('photos.show.original_post') + = link_to t('photos.show.view'), post_path(@post.status_message) %p = @post.status_message.message %p - for photo in @post.status_message.photos - = link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + = link_to (image_tag photo.url(:thumb_small)), post_path(photo) %p - = link_to 'permalink', post_path(@post) + = link_to t('photos.show.permalink'), post_path(@post) diff --git a/app/views/posts/status_message.haml b/app/views/posts/status_message.haml index 7feeb9340..bae8db98e 100644 --- a/app/views/posts/status_message.haml +++ b/app/views/posts/status_message.haml @@ -14,8 +14,8 @@ = markdownify(@post.message, :youtube_maps => @post[:youtube_titles]) - for photo in @post.photos - = link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + = link_to (image_tag photo.url(:thumb_small)), post_path(photo) .time = how_long_ago(@post) - = link_to 'permalink', post_path(@post) + = link_to t('status_messages.show.permalink'), post_path(@post) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 7f9876245..6de5bcab4 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -232,6 +232,7 @@ en: edit: "edit" edit_delete_photo: "Edit photo description / delete photo" original_post: "Original Post" + permalink: "permalink" edit: editing: "Editing" photo: @@ -292,6 +293,7 @@ en: oh_yeah: "oh yeah!" show: destroy: "Destroy" + permalink: "permalink" helper: no_message_to_display: "No message to display." people: diff --git a/config/oauth_keys.yml.example b/config/oauth_keys.yml.example index 8e1db632a..dd4e95f9f 100644 --- a/config/oauth_keys.yml.example +++ b/config/oauth_keys.yml.example @@ -1,5 +1,5 @@ twitter: - consumer_key: "" + consumer_token: "" consumer_secret: "" facebook: app_id: "" diff --git a/config/routes.rb b/config/routes.rb index d016a34e1..51bed961c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,7 @@ Diaspora::Application.routes.draw do resources :comments, :only => [:create] resources :requests, :only => [:destroy, :create] resources :services - resources :posts, :only => [:show] + resources :posts, :only => [:show], :path => '/p/' resources :people do resources :status_messages resources :photos diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 9549a9085..23dfe2f32 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -18,7 +18,8 @@ describe ServicesController do let(:omniauth_auth) {{ 'provider' => 'twitter', 'uid' => '2', 'user_info' => { 'nickname' => 'grimmin' }, - 'extra' => { 'access_token' => mock_access_token }}} + 'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" } + }} before do sign_in :user, user diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 5be8ce1ec..e891bfbfa 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -96,8 +96,8 @@ describe User do it 'includes a permalink to my post' do @status_opts[:public] = true status.save - user.should_receive(:post_to_twitter).with(service1, @message+ "%20#{post_path(status)}").once - user.should_receive(:post_to_facebook).with(service2, @message + "%20#{post_path(status)}").once + user.should_receive(:post_to_twitter).with(service1, @message+ " #{post_path(status)}").once + user.should_receive(:post_to_facebook).with(service2, @message + " #{post_path(status)}").once user.dispatch_post(status, :to => "all", :url => post_path(status)) end