public posts are now accessible by your friends, and facebook and twitter include a permalink. we prob want to link shorten these bad boys(and it has a max length of 140 chars, with a permalink), also, facebook and twitter posting are sync, but that will make it more reliable
This commit is contained in:
parent
11f04a060e
commit
579a288351
12 changed files with 39 additions and 39 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -13,30 +13,18 @@ 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
|
||||
|
||||
flash[:notice] = I18n.t 'services.create.success'
|
||||
if current_user.getting_started
|
||||
redirect_to getting_started_path(:step => 3)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class User
|
|||
include MongoMapper::Document
|
||||
include Diaspora::UserModules
|
||||
include Encryptor::Private
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
plugin MongoMapper::Devise
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -194,9 +202,7 @@ class User
|
|||
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 = {})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
twitter:
|
||||
consumer_key: ""
|
||||
consumer_token: ""
|
||||
consumer_secret: ""
|
||||
facebook:
|
||||
app_id: ""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue