From 3f6646d87b11ec83b2dd24f0075d9bebf1cb9675 Mon Sep 17 00:00:00 2001 From: Carl Chenet Date: Tue, 23 May 2017 10:44:20 +0200 Subject: [PATCH] if a user has a linked twitter account, give them attribution --- app/controllers/stories_controller.rb | 4 ++++ script/post_to_twitter | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 2783824..9c509f2 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -163,6 +163,10 @@ class StoriesController < ApplicationController "apple-touch-icon-144.png", } + if @story.user.twitter_username.present? + @meta_tags["twitter:creator"] = "@" + @story.user.twitter_username + end + load_user_votes render :action => "show" diff --git a/script/post_to_twitter b/script/post_to_twitter index 751c207..d59f495 100755 --- a/script/post_to_twitter +++ b/script/post_to_twitter @@ -25,12 +25,18 @@ Time.now - 1.days).order(:id).each_with_index do |s,x| tags += ' #' + tagging.tag.tag end - tco_status = "\n" + + via = "" + if s.user.twitter_username.present? + via = "\n" + (s.user_is_author? ? "by" : "via") + + " @#{s.user.twitter_username}" + end + + tco_status = via + "\n" + (s.url.present?? ("X" * Twitter::TCO_LEN) + "\n" : "") + ("X" * Twitter::TCO_LEN) + tags - status = "\n" + + status = via + "\n" + (s.url.present?? s.url + "\n" : "") + s.short_id_url + tags