Skip to content
Extraits de code Groupes Projets
Valider 149c086d rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

make the tumblr posting smarter

parent 6e3fcdd8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class Services::Tumblr < Service
include ActionView::Helpers::TextHelper
include ActionView::Helpers::TagHelper
MAX_CHARACTERS = 1000
def provider
......@@ -14,18 +17,28 @@ class Services::Tumblr < Service
end
def post(post, url='')
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://tumblr.com')
access = OAuth::AccessToken.new(consumer, self.access_token, self.access_secret)
body = build_tumblr_post(post, url)
begin
resp = access.post('http://tumblr.com/api/write', {:type => 'regular', :title => self.public_message(post, url), :generator => 'diaspora'})
resp = access.post('http://tumblr.com/api/write', body)
resp
rescue
nil
end
end
def public_message(post, url)
super(post, MAX_CHARACTERS, url)
def build_tumblr_post(post, url)
{:generator => 'diaspora', :type => 'regular', :body => tumblr_template(post, url)}
end
def tumblr_template(post, url)
html = ''
post.photos.each do |photo|
html += "<img src='#{photo.url(:scaled_full)}'/><br>"
end
html += auto_link(post.text)
end
end
- post.photos.each do |photo|
= image_tag(photo.url(:scaled_full))
%br
%br
= auto_link(post.text)
......@@ -88,5 +88,3 @@ Feature: commenting
And I wait for the ajax to finish
When I am on "alice@alice.alice"'s page
Then I should see "I think thats a cat"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter