Skip to content

Commit

Permalink
add contributed plugins; load note plugin by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Dolgov committed Dec 23, 2012
1 parent a5c9a5c commit 7252abe
Show file tree
Hide file tree
Showing 16 changed files with 359 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.php-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
Expand Down
2 changes: 1 addition & 1 deletion include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3141,7 +3141,7 @@ function format_article($link, $id, $mark_as_read = true, $zoom_mode = false, $o
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,
Expand Down
46 changes: 46 additions & 0 deletions plugins/flattr/flattr.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
?>
Binary file added plugins/flattr/flattr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions plugins/googleplus/googleplus.js
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions plugins/googleplus/googleplus.php
Original file line number Diff line number Diff line change
@@ -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));
}


}
?>
Binary file added plugins/googleplus/googleplus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions plugins/identica/identica.js
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions plugins/identica/identica.php
Original file line number Diff line number Diff line change
@@ -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));
}


}
?>
Binary file added plugins/identica/identica.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions plugins/pinterest/pinterest.js
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions plugins/pinterest/pinterest.php
Original file line number Diff line number Diff line change
@@ -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));
}


}
?>
Binary file added plugins/pinterest/pinterest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions plugins/pocket/pocket.js
Original file line number Diff line number Diff line change
@@ -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 changes: 48 additions & 0 deletions plugins/pocket/pocket.php
Original file line number Diff line number Diff line change
@@ -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));
}


}
?>
Binary file added plugins/pocket/pocket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7252abe

Please sign in to comment.