瀏覽代碼

add contributed plugins; load note plugin by default

Andrew Dolgov 11 年之前
父節點
當前提交
7252abe3ea

+ 1 - 1
config.php-dist

@@ -176,7 +176,7 @@
 	// 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', '');

+ 1 - 1
include/functions.php

@@ -3141,7 +3141,7 @@
 			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,

+ 46 - 0
plugins/flattr/flattr.php

@@ -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;
+  }
+}
+?>

二進制
plugins/flattr/flattr.png


+ 29 - 0
plugins/googleplus/googleplus.js

@@ -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);
+	}
+	}
+

+ 47 - 0
plugins/googleplus/googleplus.php

@@ -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));
+	}
+
+
+}
+?>

二進制
plugins/googleplus/googleplus.png


+ 31 - 0
plugins/identica/identica.js

@@ -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);
+	}
+	}
+

+ 47 - 0
plugins/identica/identica.php

@@ -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));
+	}
+
+
+}
+?>

二進制
plugins/identica/identica.png


+ 31 - 0
plugins/pinterest/pinterest.js

@@ -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);
+	}
+	}
+

+ 47 - 0
plugins/pinterest/pinterest.php

@@ -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));
+	}
+
+
+}
+?>

二進制
plugins/pinterest/pinterest.png


+ 31 - 0
plugins/pocket/pocket.js

@@ -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);
+	}
+	}
+

+ 48 - 0
plugins/pocket/pocket.php

@@ -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));
+	}
+
+
+}
+?>

二進制
plugins/pocket/pocket.png