diff --git a/app/models/services/tumblr.rb b/app/models/services/tumblr.rb index 6f8258f46..e322f630e 100644 --- a/app/models/services/tumblr.rb +++ b/app/models/services/tumblr.rb @@ -1,4 +1,7 @@ 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 += "
" + end + html += auto_link(post.text) end end diff --git a/app/views/services/tumblr.html.haml b/app/views/services/tumblr.html.haml new file mode 100644 index 000000000..ae8a6a9d7 --- /dev/null +++ b/app/views/services/tumblr.html.haml @@ -0,0 +1,5 @@ +- post.photos.each do |photo| + = image_tag(photo.url(:scaled_full)) + %br +%br += auto_link(post.text) diff --git a/features/comments.feature b/features/comments.feature index cda2ebfc1..57c5f8b3c 100644 --- a/features/comments.feature +++ b/features/comments.feature @@ -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" - -