Meilleure gestion de la limite des 140 caractères dans twitter
This commit is contained in:
parent
f5ded6c84e
commit
50c021368d
@ -101,7 +101,7 @@ class ModerationsController < ApplicationController
|
||||
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
||||
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']
|
||||
end
|
||||
client.update "#{@event} #{events_url @event}" if client.consumer_key
|
||||
client.update "#{@event.to_tweet url}" if client.consumer_key
|
||||
end
|
||||
|
||||
def send_destroy_mails
|
||||
|
@ -99,6 +99,14 @@ class Event < ActiveRecord::Base
|
||||
"#{start_time.to_date} #{city}: #{title} #{hashtags.join(' ')}"
|
||||
end
|
||||
|
||||
def to_tweet(url)
|
||||
tweet = to_s
|
||||
if (tweet.size + url.size >= 140)
|
||||
tweet = tweet[0, tweet[0, 140 - url.size].rindex(/\s/)]
|
||||
end
|
||||
"#{tweet} #{url}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def end_after_start
|
||||
|
@ -22,8 +22,7 @@
|
||||
|
||||
%h3=t '.tweet_helper'
|
||||
|
||||
= @event
|
||||
= events_url @event
|
||||
= @event.to_tweet events_url @event
|
||||
|
||||
%fieldset
|
||||
%legend
|
||||
|
Loading…
Reference in New Issue
Block a user