Correction so that the tweet url is actually well generated
This commit is contained in:
parent
31d64d636a
commit
791b9d58b0
@ -103,12 +103,16 @@ class Event < ActiveRecord::Base
|
|||||||
"#{start_time.to_date} #{city}: #{title} #{hashtags.join(' ')}"
|
"#{start_time.to_date} #{city}: #{title} #{hashtags.join(' ')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_tweet(url)
|
def to_tweet
|
||||||
tweet = to_s
|
url = Rails.application.routes.url_helpers.event_url(
|
||||||
if (tweet.size + url.size >= 140)
|
self,
|
||||||
tweet = tweet[0, tweet[0, 140 - url.size].rindex(/\s/)]
|
host: ActionMailer::Base.default_url_options[:host])
|
||||||
|
|
||||||
|
tweet = "#{self} #{url}"
|
||||||
|
if (tweet.size >= 140)
|
||||||
|
tweet = "#{tweet[0, tweet.rindex(/\s/, 140 - url.size)]} #{url}"
|
||||||
end
|
end
|
||||||
"#{tweet} #{url}"
|
tweet
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -33,6 +33,6 @@ class EventCallbacks
|
|||||||
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
||||||
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']
|
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']
|
||||||
end
|
end
|
||||||
client.update "#{event.to_tweet event_url(event)}" if client.consumer_key
|
client.update event.to_tweet if client.consumer_key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
%h2
|
%h2
|
||||||
%em.fa.fa-exclamation-triangle
|
%em.fa.fa-exclamation-triangle
|
||||||
=t '.title'
|
= t '.title'
|
||||||
|
|
||||||
- if @event.locality?
|
- if @event.locality?
|
||||||
%h2.warning=t '.warning'
|
%h2.warning= t '.warning'
|
||||||
|
|
||||||
= form_for @moderation, url: { action: :accept }, html: { method: :put } do |f|
|
= form_for @moderation, url: { action: :accept }, html: { method: :put } do |f|
|
||||||
= link_to moderations_path do
|
= link_to moderations_path do
|
||||||
%em.fa.fa-arrow-left
|
%em.fa.fa-arrow-left
|
||||||
=t '.ko'
|
= t '.ko'
|
||||||
|
|
||||||
= f.button do
|
= f.button do
|
||||||
%em.fa.fa-thumbs-up
|
%em.fa.fa-thumbs-up
|
||||||
=t '.ok'
|
= t '.ok'
|
||||||
|
|
||||||
- if ENV['TWITTER_CONSUMER_KEY'] || Rails.env.development?
|
- if ENV['TWITTER_CONSUMER_KEY'] || Rails.env.development?
|
||||||
%fieldset
|
%fieldset
|
||||||
@ -20,12 +20,12 @@
|
|||||||
%em.fa.fa-twitter
|
%em.fa.fa-twitter
|
||||||
Tweet
|
Tweet
|
||||||
|
|
||||||
%h3=t '.tweet_helper'
|
%h3= t '.tweet_helper'
|
||||||
|
|
||||||
= @event.to_tweet event_url @event
|
= @event.to_tweet
|
||||||
|
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend
|
%legend
|
||||||
%em.fa.fa-calendar
|
%em.fa.fa-calendar
|
||||||
=Event.model_name.human
|
= Event.model_name.human
|
||||||
= render file: '/events/show'
|
= render file: '/events/show'
|
||||||
|
Loading…
Reference in New Issue
Block a user