]> git.wh0rd.org Git - tt-rss.git/commitdiff
add support for twitter buttons
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 22 Nov 2010 11:04:32 +0000 (14:04 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 22 Nov 2010 11:04:32 +0000 (14:04 +0300)
config.php-dist
functions.php
tt-rss.php
viewfeed.js

index 85e682ccace708d258bee84fcab1efbafe0d2675..a7ab86283815ec2d710a0a315c33920c2b2ce278 100644 (file)
        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).
index 1db2d27387d11aa00afaad53872cb5a35e0ed624..9133c482a74b9946670d0dbb48237f5d78d6a2f3 100644 (file)
                        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>";
                                                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;
                                        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\">";
index 5b9d1f1fe0f562b949cf5d8afb1764e4f8bfa23b..ceeca35819f8b6fc36f1a39beccdc5f97c0438b1 100644 (file)
 
        <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>
index fc6fb9075accd8433e9fd5f6a9d9c6cbff604173..f9384fc1718978345a804dda75c8308d9b0c70f5 100644 (file)
@@ -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);
        }