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 class Services::Tumblr < Service
include ActionView::Helpers::TextHelper
include ActionView::Helpers::TagHelper
MAX_CHARACTERS = 1000 MAX_CHARACTERS = 1000
def provider def provider
...@@ -14,18 +17,28 @@ class Services::Tumblr < Service ...@@ -14,18 +17,28 @@ class Services::Tumblr < Service
end end
def post(post, url='') def post(post, url='')
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://tumblr.com') consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://tumblr.com')
access = OAuth::AccessToken.new(consumer, self.access_token, self.access_secret) access = OAuth::AccessToken.new(consumer, self.access_token, self.access_secret)
body = build_tumblr_post(post, url)
begin 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 resp
rescue rescue
nil nil
end end
end end
def public_message(post, url) def build_tumblr_post(post, url)
super(post, MAX_CHARACTERS, 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
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 ...@@ -88,5 +88,3 @@ Feature: commenting
And I wait for the ajax to finish And I wait for the ajax to finish
When I am on "alice@alice.alice"'s page When I am on "alice@alice.alice"'s page
Then I should see "I think thats a cat" 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