summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-12-20 23:57:27 +0400
committerAndrew Dolgov <[email protected]>2011-12-20 23:59:37 +0400
commitf9ac31d6712b4400a616e49d6217d55edb0daf9c (patch)
tree453002094fe5070074581529a72fe1e083631b8f
parent73621c56055eaff7d222183bfdb5d4fabeb4e209 (diff)
move tweet button to a plugin, implement basic support for article action button plugins
-rw-r--r--classes/feeds.php14
-rw-r--r--classes/rpc.php23
-rw-r--r--config.php-dist10
-rw-r--r--include/functions.php14
-rw-r--r--index.php12
-rw-r--r--js/viewfeed.js31
6 files changed, 44 insertions, 60 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 2e9aea686..ec96d7050 100644
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -704,11 +704,15 @@ class Feeds extends Protected_Handler {
onclick=\"emailArticle($id)\"
alt='Zoom' title='".__('Forward by email')."'>";
- if (ENABLE_TWEET_BUTTON) {
- $reply['content'] .= "<img src=\"".theme_image($this->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);
+ }
}
$reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-share.png')."\"
diff --git a/classes/rpc.php b/classes/rpc.php
index dbdca8a78..45915b9dc 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -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() {
diff --git a/config.php-dist b/config.php-dist
index e4b5ae32d..490a871f6 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -175,9 +175,6 @@
// *** 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
@@ -202,7 +199,12 @@
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).
diff --git a/include/functions.php b/include/functions.php
index 41b31553a..c633c03b5 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -3289,11 +3289,15 @@
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')."\"
diff --git a/index.php b/index.php
index d08afa6ef..9d17da7bc 100644
--- 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";
@@ -40,6 +40,16 @@
<?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>
diff --git a/js/viewfeed.js b/js/viewfeed.js
index d267c7693..d87fc41cf 100644
--- a/js/viewfeed.js
+++ b/js/viewfeed.js
@@ -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 {