summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-11-22 14:04:32 +0300
committerAndrew Dolgov <[email protected]>2010-11-22 14:04:32 +0300
commit96d446011bd340c8dc6362876d846e8b89e4341a (patch)
tree651d741a48411cbb2ede45e09c6081e81e9f2ed3
parent083020ad8dfba8e1c504eed503edb4ed6133e0f0 (diff)
add support for twitter buttons
-rw-r--r--config.php-dist3
-rw-r--r--functions.php20
-rw-r--r--tt-rss.php4
-rw-r--r--viewfeed.js7
4 files changed, 33 insertions, 1 deletions
diff --git a/config.php-dist b/config.php-dist
index 85e682cca..a7ab86283 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -171,6 +171,9 @@
define('SPHINX_INDEX', 'ttrss');
// Index name in Sphinx configuration
+ define('ENABLE_TWEET_BUTTON', false);
+ // Enable 'tweet this' button for articles
+
define('CONFIG_VERSION', 20);
// Expected config version. Please update this option in config.php
// if necessary (after migrating all new options from this file).
diff --git a/functions.php b/functions.php
index 1db2d2738..9133c482a 100644
--- a/functions.php
+++ b/functions.php
@@ -4736,6 +4736,14 @@
print_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
+ $short_title = truncate_string(strip_tags($line['title']), 90);
+
+ print "<a href=\"http://twitter.com/share\"
+ class=\"twitter-share-button\"
+ data-text=\"$short_title\"
+ data-url=\"".htmlspecialchars($line["link"])."\"
+ data-count=\"horizontal\">Tweet</a>";
+
print "</div>";
print "</div>";
@@ -5160,7 +5168,8 @@
onclick=\"return cdmClicked(event, $id);\"
class=\"titleWrap$hlc_suffix\">
<a class=\"title\"
- target=\"_blank\" href=\"".$line["link"]."\">".$line["title"].
+ target=\"_blank\" href=\"".
+ htmlspecialchars($line["link"])."\">".$line["title"].
" $entry_author</a>";
print $labels_str;
@@ -5251,6 +5260,15 @@
print_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
+ $short_title = truncate_string(
+ strip_tags($line['title']), 90);
+
+ print "<a href=\"http://twitter.com/share\"
+ class=\"twitter-share-button\"
+ data-text=\"$short_title\"
+ data-url=\"".htmlspecialchars($line["link"])."\"
+ data-count=\"horizontal\">Tweet</a>";
+
print "</div>";
print "<div class=\"cdmFooter\">";
diff --git a/tt-rss.php b/tt-rss.php
index 5b9d1f1fe..ceeca3581 100644
--- a/tt-rss.php
+++ b/tt-rss.php
@@ -39,6 +39,10 @@
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
+ <?php if (ENABLE_TWEET_BUTTON) { ?>
+ <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
+ <?php } ?>
+
<script type="text/javascript" src="lib/prototype.js"></script>
<script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
<script type="text/javascript" src="lib/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
diff --git a/viewfeed.js b/viewfeed.js
index fc6fb9075..f9384fc17 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -104,6 +104,10 @@ function headlines_callback2(transport, feed_cur_page) {
dijit.byId("headlines-toolbar").attr('content',
headlines_toolbar.firstChild.nodeValue);
+ $$("#headlines-frame a.twitter-share-button").each(
+ function(btn) { var tbtn = new twttr.TweetButton(btn);
+ tbtn.render(); });
+
initHeadlinesMenu();
var cache_prefix = "";
@@ -220,6 +224,9 @@ function render_article(article) {
correctHeadlinesOffset(getActiveArticleId());
+ $$("#content-insert a.twitter-share-button").each(
+ function(btn) { var tbtn = new twttr.TweetButton(btn); tbtn.render(); });
+
} catch (e) {
exception_error("render_article", e);
}