]> git.wh0rd.org - tt-rss.git/commitdiff
add contributed plugins; load note plugin by default
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 23 Dec 2012 11:18:41 +0000 (15:18 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 23 Dec 2012 11:18:41 +0000 (15:18 +0400)
16 files changed:
config.php-dist
include/functions.php
plugins/flattr/flattr.php [new file with mode: 0644]
plugins/flattr/flattr.png [new file with mode: 0644]
plugins/googleplus/googleplus.js [new file with mode: 0644]
plugins/googleplus/googleplus.php [new file with mode: 0644]
plugins/googleplus/googleplus.png [new file with mode: 0644]
plugins/identica/identica.js [new file with mode: 0644]
plugins/identica/identica.php [new file with mode: 0644]
plugins/identica/identica.png [new file with mode: 0644]
plugins/pinterest/pinterest.js [new file with mode: 0644]
plugins/pinterest/pinterest.php [new file with mode: 0644]
plugins/pinterest/pinterest.png [new file with mode: 0644]
plugins/pocket/pocket.js [new file with mode: 0644]
plugins/pocket/pocket.php [new file with mode: 0644]
plugins/pocket/pocket.png [new file with mode: 0644]

index 2975d680ae46cbb4609d48ae3db3278c3415d7f1..12e4729056c7ab91c63c76083402bd794c328b4f 100644 (file)
        // if you experience weird errors and tt-rss failing to start, blank pages
        // after login, or content encoding errors, disable it.
 
-       define('PLUGINS', '');
+       define('PLUGINS', 'note');
        // Plugins to load. Check plugins/ directory for additional information.
 
        define('FEEDBACK_URL', '');
index da676798636a2db5eedb6b6629a91cb49f244b6e..a4caf9fde306e9464b5d6dbec96d9c4dc7453c3d 100644 (file)
                        ccache_update($link, $feed_id, $owner_uid);
                }
 
-               $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
+               $result = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id,
                        ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
                        (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
                        (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
diff --git a/plugins/flattr/flattr.php b/plugins/flattr/flattr.php
new file mode 100644 (file)
index 0000000..6af6cb9
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+class Flattr {
+       private $link;
+       private $host;
+
+       function __construct($host) {
+               $this->link = $host->get_link();
+               $this->host = $host;
+
+               $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+       }
+
+  function hook_article_button($line) {
+
+       $article_id = $line["id"];
+
+    $result = db_query($this->link, "SELECT link
+      FROM ttrss_entries, ttrss_user_entries
+      WHERE id = '$article_id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
+
+    if (db_num_rows($result) != 0) {
+      $article_link = db_fetch_result($result, 0, 'link');
+    }
+
+    $response = null;
+    if ($article_link) {
+      $encoded = urlencode($article_link);
+      $r = file_get_contents("https://api.flattr.com/rest/v2/things/lookup/?url=$encoded");
+      $response = json_decode($r, true);
+    }
+
+    $rv = null;
+    if ($response and array_key_exists('link', $response)) {
+      $rv = "<a id='flattr' href='" . $response['link'] . "'>
+        <img src=\"".theme_image($this->link, 'plugins/flattr/flattr.png')."\"
+        class='tagsPic' style=\"cursor : pointer\"
+        title='".__('Flattr article')."'>
+        </a>";
+    } else {
+      $rv = "";
+    }
+
+    return $rv;
+  }
+}
+?>
diff --git a/plugins/flattr/flattr.png b/plugins/flattr/flattr.png
new file mode 100644 (file)
index 0000000..4933ffc
Binary files /dev/null and b/plugins/flattr/flattr.png differ
diff --git a/plugins/googleplus/googleplus.js b/plugins/googleplus/googleplus.js
new file mode 100644 (file)
index 0000000..027d9b4
--- /dev/null
@@ -0,0 +1,29 @@
+       function shareArticleToGooglePlus(id) {
+       try {
+               var query = "?op=pluginhandler&plugin=googleplus&method=getInfo&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=450,scrollbars=1,menubar=0");
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               var ti = JSON.parse(transport.responseText);
+
+                               var share_url = "https://plus.google.com/share?url=" + param_escape(ti.link);
+
+                               w.location.href = share_url;
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("tweetArticle", e);
+       }
+       }
+
diff --git a/plugins/googleplus/googleplus.php b/plugins/googleplus/googleplus.php
new file mode 100644 (file)
index 0000000..1c5128e
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+class GooglePlus {
+       private $link;
+       private $host;
+
+       function __construct($host) {
+               $this->link = $host->get_link();
+               $this->host = $host;
+
+               $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+       }
+
+       function get_js() {
+               return file_get_contents(dirname(__FILE__) . "/googleplus.js");
+       }
+
+       function hook_article_button($line) {
+               $article_id = $line["id"];
+
+               $rv = "<img src=\"".theme_image($this->link, 'plugins/googleplus/googleplus.png')."\"
+                       class='tagsPic' style=\"cursor : pointer\"
+                       onclick=\"shareArticleToGooglePlus($article_id)\"
+                       title='".__('Share on Google+')."'>";
+
+               return $rv;
+       }
+
+       function getInfo() {
+               $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');
+               }
+
+               print json_encode(array("title" => $title, "link" => $article_link,
+                               "id" => $id));
+       }
+
+
+}
+?>
diff --git a/plugins/googleplus/googleplus.png b/plugins/googleplus/googleplus.png
new file mode 100644 (file)
index 0000000..8c64b81
Binary files /dev/null and b/plugins/googleplus/googleplus.png differ
diff --git a/plugins/identica/identica.js b/plugins/identica/identica.js
new file mode 100644 (file)
index 0000000..d31fc55
--- /dev/null
@@ -0,0 +1,31 @@
+       function shareArticleToIdentica(id) {
+       try {
+               var query = "?op=pluginhandler&plugin=identica&method=getInfo&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=600,height=500,scrollbars=1,menubar=0");
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               var ti = JSON.parse(transport.responseText);
+
+                               var share_url = "http://identi.ca/index.php?action=bookmarkpopup&_=" + ts +
+                                       "&title=" + param_escape(ti.title) +
+                                       "&url=" + param_escape(ti.link);
+
+                               w.location.href = share_url;
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("shareArticleIdentica", e);
+       }
+       }
+
diff --git a/plugins/identica/identica.php b/plugins/identica/identica.php
new file mode 100644 (file)
index 0000000..e7a5b35
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+class Identica {
+       private $link;
+       private $host;
+
+       function __construct($host) {
+               $this->link = $host->get_link();
+               $this->host = $host;
+
+               $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+       }
+
+       function get_js() {
+               return file_get_contents(dirname(__FILE__) . "/identica.js");
+       }
+
+       function hook_article_button($line) {
+               $article_id = $line["id"];
+
+               $rv = "<img src=\"".theme_image($this->link, 'plugins/identica/identica.png')."\"
+                       class='tagsPic' style=\"cursor : pointer\"
+                       onclick=\"shareArticleToIdentica($article_id)\"
+                       title='".__('Share on identi.ca')."'>";
+
+               return $rv;
+       }
+
+       function getInfo() {
+               $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');
+               }
+
+               print json_encode(array("title" => $title, "link" => $article_link,
+                               "id" => $id));
+       }
+
+
+}
+?>
diff --git a/plugins/identica/identica.png b/plugins/identica/identica.png
new file mode 100644 (file)
index 0000000..ee3cb61
Binary files /dev/null and b/plugins/identica/identica.png differ
diff --git a/plugins/pinterest/pinterest.js b/plugins/pinterest/pinterest.js
new file mode 100644 (file)
index 0000000..01c525f
--- /dev/null
@@ -0,0 +1,31 @@
+       function pinterest(id) {
+       try {
+               var query = "?op=pluginhandler&plugin=pinterest&method=getInfo&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=650,height=600,scrollbars=1,menubar=0");
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               var ti = JSON.parse(transport.responseText);
+
+                               var share_url = "http://pinterest.com/pin/create/button/?" +
+                                       "url=" + param_escape(ti.link) +
+                                       "&description=" + param_escape(ti.title);
+
+                               w.location.href = share_url;
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("tweetArticle", e);
+       }
+       }
+
diff --git a/plugins/pinterest/pinterest.php b/plugins/pinterest/pinterest.php
new file mode 100644 (file)
index 0000000..83a95a4
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+class Pinterest {
+       private $link;
+       private $host;
+
+       function __construct($host) {
+               $this->link = $host->get_link();
+               $this->host = $host;
+
+               $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+       }
+
+       function get_js() {
+               return file_get_contents(dirname(__FILE__) . "/pinterest.js");
+       }
+
+       function hook_article_button($line) {
+               $article_id = $line["id"];
+
+               $rv = "<img src=\"".theme_image($this->link, 'plugins/pinterest/pinterest.png')."\"
+                       class='tagsPic' style=\"cursor : pointer\"
+                       onclick=\"pinterest($article_id)\"
+                       title='".__('Pinterest')."'>";
+
+               return $rv;
+       }
+
+       function getInfo() {
+               $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');
+               }
+
+               print json_encode(array("title" => $title, "link" => $article_link,
+                               "id" => $id));
+       }
+
+
+}
+?>
diff --git a/plugins/pinterest/pinterest.png b/plugins/pinterest/pinterest.png
new file mode 100644 (file)
index 0000000..b85aed3
Binary files /dev/null and b/plugins/pinterest/pinterest.png differ
diff --git a/plugins/pocket/pocket.js b/plugins/pocket/pocket.js
new file mode 100644 (file)
index 0000000..021d5bb
--- /dev/null
@@ -0,0 +1,31 @@
+       function shareArticleToPocket(id) {
+       try {
+               var query = "?op=pluginhandler&plugin=pocket&method=getInfo&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 = "https://getpocket.com/save?" +
+                                       "&title=" + param_escape(ti.title) +
+                                       "&url=" + param_escape(ti.link);
+
+                               w.location.href = share_url;
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("tweetArticle", e);
+       }
+       }
+
diff --git a/plugins/pocket/pocket.php b/plugins/pocket/pocket.php
new file mode 100644 (file)
index 0000000..56592a5
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+class Pocket {
+
+       private $link;
+       private $host;
+
+       function __construct($host) {
+               $this->link = $host->get_link();
+               $this->host = $host;
+
+               $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+       }
+
+       function get_js() {
+               return file_get_contents(dirname(__FILE__) . "/pocket.js");
+       }
+
+       function hook_article_button($line) {
+               $article_id = $line["id"];
+
+               $rv = "<img src=\"".theme_image($this->link, 'plugins/pocket/pocket.png')."\"
+                       class='tagsPic' style=\"cursor : pointer\"
+                       onclick=\"shareArticleToPocket($article_id)\"
+                       title='".__('Pocket')."'>";
+
+               return $rv;
+       }
+
+       function getInfo() {
+               $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');
+               }
+
+               print json_encode(array("title" => $title, "link" => $article_link,
+                               "id" => $id));
+       }
+
+
+}
+?>
diff --git a/plugins/pocket/pocket.png b/plugins/pocket/pocket.png
new file mode 100644 (file)
index 0000000..ff6bc85
Binary files /dev/null and b/plugins/pocket/pocket.png differ