Permalink
Browse files

added config option to let user set title in Flickr to the tweet text

  • Loading branch information...
1 parent 95ed5a2 commit 855a9cfb1382752fede2ca326a282c34346252ce Steven committed Dec 5, 2009
View
@@ -82,8 +82,14 @@ def to_xml(*args)
def upload_to_flickr
if image && !uploaded?
+ if user.flickr_title
+ escaped_caption = caption.gsub('#','')
+ title = escaped_caption ? escaped_caption : caption
+ else
+ title = Time.now.utc.strftime("%e %b %Y")
+ end
rsp = flickr_api.uploader.upload(image.path,
- :title => Time.now.utc.strftime("%e %b %Y"),
+ :title => title,
:tags => "iphone,flickr4twitter",
:is_public => !user.test_user?
)
@@ -95,7 +101,7 @@ def upload_to_flickr
# Update the description on flickr
def update_flickr_description
if caption_changed? && flickr_image
- description = caption.to_s
+ description = caption.to_s unless user.flickr_title
description += "\n\nTwitter: #{tweet_url}" if tweet_url
flickr_image.set_meta(:description => description)
flickr_image.add_tags(tags.join(',')) unless tags.empty?
@@ -9,6 +9,7 @@
<%- form.inputs :name => 'Flickr', :id => 'flickr' do -%>
<%= form.input :flickr_username, :label => 'Flickr Username', :required => true, :hint => 'http://flickr.com/people/<strong>username</strong>/' %>
<%= form.input :flickr_user_id, :label => 'Flickr ID', :required => false, :input_html => { :disabled => true, :class => 'disabled' } %>
+ <%= form.input :flickr_title, :as => :boolean, :label => 'Use Tweet as Title?', :required => false %>
<%- end -%>
<%- form.inputs :name => 'Client', :id => 'client' do -%>
@@ -0,0 +1,9 @@
+class AddFlickrTitleBooleanToUser < ActiveRecord::Migration
+ def self.up
+ add_column :users, :flickr_title, :boolean
+ end
+
+ def self.down
+ remove_column :users, :flickr_title
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20091024050212) do
+ActiveRecord::Schema.define(:version => 20091204225707) do
create_table "photos", :force => true do |t|
t.string "flickr_id"
@@ -47,6 +47,7 @@
t.string "client_hash"
t.string "custom_client_hash"
t.string "flickr_username"
+ t.boolean "flickr_title"
end
add_index "users", ["client_hash"], :name => "index_users_on_client_hash"

0 comments on commit 855a9cf

Please sign in to comment.