]> git.wh0rd.org Git - tt-rss.git/commitdiff
move tweet button to a plugin, implement basic support for article action button...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 20 Dec 2011 19:57:27 +0000 (23:57 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 20 Dec 2011 19:59:37 +0000 (23:59 +0400)
classes/feeds.php
classes/rpc.php
config.php-dist
include/functions.php
index.php
js/viewfeed.js

index 2e9aea6861e7220ded425401b72943e6ddb37add..ec96d70500e6d1277678dbb5c715e531da584819 100644 (file)
@@ -704,11 +704,15 @@ class Feeds extends Protected_Handler {
                                                onclick=\"emailArticle($id)\"\r
                                                alt='Zoom' title='".__('Forward by email')."'>";\r
 \r
-                                       if (ENABLE_TWEET_BUTTON) {\r
-                                               $reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-tweet.png')."\"\r
-                                                       class='tagsPic' style=\"cursor : pointer\"\r
-                                                       onclick=\"tweetArticle($id)\"\r
-                                                       alt='Zoom' title='".__('Share on Twitter')."'>";\r
+                                       $button_plugins = explode(",", ARTICLE_BUTTON_PLUGINS);\r
+\r
+                                       foreach ($button_plugins as $p) {\r
+                                               $pclass = "${p}_button";\r
+\r
+                                               if (class_exists($pclass)) {\r
+                                                       $plugin = new $pclass($link);\r
+                                                       $rv['content'] .= $plugin->render($id);\r
+                                               }\r
                                        }\r
 \r
                                        $reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-share.png')."\"\r
index dbdca8a7886a2115659990d2ae1251dd68ff1b89..45915b9dc229c1a366bf1ddfe6ba5909017d87a9 100644 (file)
@@ -753,21 +753,16 @@ class RPC extends Protected_Handler {
                return;
        }
 
-       function getTweetInfo() {
-               $id = db_escape_string($_REQUEST['id']);
-
-               $result = db_query($this->link, "SELECT title, link
-                               FROM ttrss_entries, ttrss_user_entries
-                               WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
-
-               if (db_num_rows($result) != 0) {
-                       $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
-                               100, '...');
-                       $article_link = db_fetch_result($result, 0, 'link');
+       function buttonPlugin() {
+               $pclass = basename($_REQUEST['plugin']) . "_button";
+               $method = $_REQUEST['plugin_method'];
+
+               if (class_exists($pclass)) {
+                       $plugin = new $pclass($this->link);
+                       if (method_exists($plugin, $method)) {
+                               return $plugin->$method();
+                       }
                }
-
-               print json_encode(array("title" => $title, "link" => $article_link,
-                               "id" => $id));
        }
 
        function setNote() {
index e4b5ae32d74fa8f31e2594a8c31d2dee6437a42f..490a871f60ac687534792541e7538910a20405de 100644 (file)
        // *** Twitter integration settings ***
        // ************************************
        
-       define('ENABLE_TWEET_BUTTON', false);
-       // Enable 'tweet this' button for articles
-
        define('CONSUMER_KEY', '');
        define('CONSUMER_SECRET', '');
        // Your OAuth instance authentication information for Twitter, visit
        define('FEEDBACK_URL', '');
        // Displays an URL for users to provide feedback or comments regarding
        // this instance of tt-rss. Can lead to a forum, contact email, etc.
-       
+
+       define('ARTICLE_BUTTON_PLUGINS', 'tweet');
+       // Comma-separated list of additional article action button plugins
+       // to enable, like tweet button, etc.
+       // The following plugins are available: tweet
+
        define('CONFIG_VERSION', 24);
        // Expected config version. Please update this option in config.php
        // if necessary (after migrating all new options from this file).
index 41b31553af5b5f434e2d1c6fa7125fd015c99a32..c633c03b53d115e448cec66dc71a9fb35b6eb15a 100644 (file)
                                        onclick=\"emailArticle($id)\"
                                        alt='Zoom' title='".__('Forward by email')."'>";
 
-                               if (ENABLE_TWEET_BUTTON) {
-                                       $rv['content'] .= "<img src=\"".theme_image($link, 'images/art-tweet.png')."\"
-                                                       class='tagsPic' style=\"cursor : pointer\"
-                                                       onclick=\"tweetArticle($id)\"
-                                                       alt='Zoom' title='".__('Share on Twitter')."'>";
+                               $button_plugins = explode(",", ARTICLE_BUTTON_PLUGINS);
+
+                               foreach ($button_plugins as $p) {
+                                       $pclass = "${p}_button";
+
+                                       if (class_exists($pclass)) {
+                                               $plugin = new $pclass($link);
+                                               $rv['content'] .= $plugin->render($id);
+                                       }
                                }
 
                                $rv['content'] .= "<img src=\"".theme_image($link, 'images/art-share.png')."\"
index d08afa6efd016aedade0102589939ce86be83746..9d17da7bc9837a21ffe1a36d732fbded1c23a4b9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,7 +5,7 @@
                exit;
        }
 
-       set_include_path(get_include_path() . PATH_SEPARATOR . 
+       set_include_path(get_include_path() . PATH_SEPARATOR .
                dirname(__FILE__) ."/include");
 
        require_once "functions.php";
        <?php print_theme_includes($link) ?>
        <?php print_user_stylesheet($link) ?>
 
+       <script type="text/javascript">
+       <?php foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
+               $jsf = "js/${p}_button.js";
+               if (file_exists($jsf)) {
+                       include $jsf;
+                       print "</script>";
+               }
+       } ?>
+       </script>
+
        <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
 
        <script type="text/javascript" src="lib/prototype.js"></script>
index d267c7693e02ea821e30dbca7f940cbd69818db8..d87fc41cf969d6af312c0c0821c5ee482fb45f95 100644 (file)
@@ -1994,37 +1994,6 @@ function initHeadlinesMenu() {
        }
 }
 
-function tweetArticle(id) {
-       try {
-               var query = "?op=rpc&method=getTweetInfo&id=" + param_escape(id);
-
-               console.log(query);
-
-               var d = new Date();
-      var ts = d.getTime();
-
-               var w = window.open('backend.php?op=backend&method=loading', 'ttrss_tweet',
-                       "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               var ti = JSON.parse(transport.responseText);
-
-                               var share_url = "http://twitter.com/share?_=" + ts +
-                                       "&text=" + param_escape(ti.title) +
-                                       "&url=" + param_escape(ti.link);
-
-                               w.location.href = share_url;
-
-                       } });
-
-
-       } catch (e) {
-               exception_error("tweetArticle", e);
-       }
-}
-
 function editArticleNote(id) {
        try {