diff --git a/config.php-dist b/config.php-dist index 2975d680a..12e472905 100644 --- a/config.php-dist +++ b/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', ''); diff --git a/include/functions.php b/include/functions.php index da6767986..a4caf9fde 100644 --- a/include/functions.php +++ b/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, diff --git a/plugins/flattr/flattr.php b/plugins/flattr/flattr.php new file mode 100644 index 000000000..6af6cb9c3 --- /dev/null +++ b/plugins/flattr/flattr.php @@ -0,0 +1,46 @@ +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 = " + link, 'plugins/flattr/flattr.png')."\" + class='tagsPic' style=\"cursor : pointer\" + title='".__('Flattr article')."'> + "; + } else { + $rv = ""; + } + + return $rv; + } +} +?> diff --git a/plugins/flattr/flattr.png b/plugins/flattr/flattr.png new file mode 100644 index 000000000..4933ffc21 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 index 000000000..027d9b40e --- /dev/null +++ b/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); + } + } + diff --git a/plugins/googleplus/googleplus.php b/plugins/googleplus/googleplus.php new file mode 100644 index 000000000..1c5128eed --- /dev/null +++ b/plugins/googleplus/googleplus.php @@ -0,0 +1,47 @@ +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 = "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 index 000000000..8c64b81a2 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 index 000000000..d31fc55f4 --- /dev/null +++ b/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); + } + } + diff --git a/plugins/identica/identica.php b/plugins/identica/identica.php new file mode 100644 index 000000000..e7a5b3573 --- /dev/null +++ b/plugins/identica/identica.php @@ -0,0 +1,47 @@ +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 = "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 index 000000000..ee3cb61ea 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 index 000000000..01c525f55 --- /dev/null +++ b/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); + } + } + diff --git a/plugins/pinterest/pinterest.php b/plugins/pinterest/pinterest.php new file mode 100644 index 000000000..83a95a449 --- /dev/null +++ b/plugins/pinterest/pinterest.php @@ -0,0 +1,47 @@ +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 = "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 index 000000000..b85aed3cd 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 index 000000000..021d5bb05 --- /dev/null +++ b/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); + } + } + diff --git a/plugins/pocket/pocket.php b/plugins/pocket/pocket.php new file mode 100644 index 000000000..56592a526 --- /dev/null +++ b/plugins/pocket/pocket.php @@ -0,0 +1,48 @@ +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 = "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 index 000000000..ff6bc85a4 Binary files /dev/null and b/plugins/pocket/pocket.png differ