Wrap text
Report abuse
|
|
def create_automatic_tumble(text, source)
if text =~ /^http:\/\//
url = text.split(" ")[0]
caption = text.split(" ")[1..-1].join(" ") # HACK
case url
when /(jpg|gif|png)$/ # image
create_tumble('photo', {
'source' => url,
'caption' => "#{caption} (#{source})" })
when /^http:\/\/www\.youtube\.com\/watch\?v=/
create_tumble('video', {
'embed' => url,
'caption' => caption })
else # probably just a link
create_tumble('link', {
'url' => url,
'description' => "#{caption} (#{source})" })
end
else # not a link
if text =~ /^([\w_]+): / # username: stuff here
source = "#{$1}, snitched by #{source}"
text.gsub!("#{$1}: ", "")
end
create_tumble('quote', {
'quote' => text,
'source' => source
})
end
end
|