From 7252abe3ea5703b3cf75a3745e560499cfde500a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 23 Dec 2012 15:18:41 +0400 Subject: [PATCH] add contributed plugins; load note plugin by default --- config.php-dist | 2 +- include/functions.php | 2 +- plugins/flattr/flattr.php | 46 ++++++++++++++++++++++++++++ plugins/flattr/flattr.png | Bin 0 -> 693 bytes plugins/googleplus/googleplus.js | 29 ++++++++++++++++++ plugins/googleplus/googleplus.php | 47 +++++++++++++++++++++++++++++ plugins/googleplus/googleplus.png | Bin 0 -> 827 bytes plugins/identica/identica.js | 31 +++++++++++++++++++ plugins/identica/identica.php | 47 +++++++++++++++++++++++++++++ plugins/identica/identica.png | Bin 0 -> 121 bytes plugins/pinterest/pinterest.js | 31 +++++++++++++++++++ plugins/pinterest/pinterest.php | 47 +++++++++++++++++++++++++++++ plugins/pinterest/pinterest.png | Bin 0 -> 3829 bytes plugins/pocket/pocket.js | 31 +++++++++++++++++++ plugins/pocket/pocket.php | 48 ++++++++++++++++++++++++++++++ plugins/pocket/pocket.png | Bin 0 -> 471 bytes 16 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 plugins/flattr/flattr.php create mode 100644 plugins/flattr/flattr.png create mode 100644 plugins/googleplus/googleplus.js create mode 100644 plugins/googleplus/googleplus.php create mode 100644 plugins/googleplus/googleplus.png create mode 100644 plugins/identica/identica.js create mode 100644 plugins/identica/identica.php create mode 100644 plugins/identica/identica.png create mode 100644 plugins/pinterest/pinterest.js create mode 100644 plugins/pinterest/pinterest.php create mode 100644 plugins/pinterest/pinterest.png create mode 100644 plugins/pocket/pocket.js create mode 100644 plugins/pocket/pocket.php create mode 100644 plugins/pocket/pocket.png diff --git a/config.php-dist b/config.php-dist index 2975d680..12e47290 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 da676798..a4caf9fd 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 00000000..6af6cb9c --- /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 0000000000000000000000000000000000000000..4933ffc21187b212de7a52509806adb1bbad1d32 GIT binary patch literal 693 zcmV;m0!safP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyV> z5D^DbYG=p*00K2hL_t(I%Z-yyNR&|&#eesGpIXx&D_u;G?ILQ`G9jWC6`@&_U?2p! zh)7D495E~kO>`uSAZihjND;Y+(jp_sj3jG_HbD_Yty_p$;C%DmyDj`TV_2Qd<2~*@ z=W@<{LKc4XZLh*e8L$Z`0favxMtz1ljs=t`;eO-v72Ct>F%2UTA@DbrVuvw91qKY-r zwerw#)6F->I|CavIG704YFVz1zQ9N=!e>0-c@KU=p7&j`BO{6HqsLkU8ztP7kPp@R zby?lNB#@dFH7~yaj9uGOfanqfS7S#<61_u*!*moKv^wWgs8)-!2)<(V+svgPVs}!Q96;>E>q+4LYzEHad~QlP1PT)TB}H#D_<3)k+Ifs_ zs^r4cO0(EgZjB5kcJ`$KoU?Y`YDvhnoeG3r7yS&41IY9KiYj}IWBp8ZHj8=WDIlink = $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 0000000000000000000000000000000000000000..8c64b81a208bcca3c419190d70874ec684266840 GIT binary patch literal 827 zcmV-B1H}A^P) zU{O!MbgbKmI)`37iyt3FCeH&#zWgZ`zBOV!9}ab|=;#~=)+7KA?>?~FAKq)x#5u7@ zXkMRT!O*+3rfbN=IV=RwK*-ye1_@baUFMzxNB}g?(CNR#(lVgP*ZXL$e~onT74qX> zA+K*n7WYxAR?+GrbjN36H*dj-ZA1Xh2ZBVX2Gk%_I&l}y;LK1Fvf5SZmoL%yr-sim z8oy1_{PQw*8H5mU11pK9ryxl{70sGhqmFt{eC8CfLiYHR_$Qtw9X&=8=7cU7c;uar z$d~ldCZgTZiLD-_wR;D?-Nu>V0I!B`WjJEIL@>YTU*6kfy{``8`X8ZEN}+2hZe$Db z&3_+Qsfi#-30%%>y~(QaNl5_wo!i*nPl+TVd~*`t%8(ngc;@|6cmRQr0T2pbL;yZ` zTw2DbWg36i2(1?Ru7mjU0$d2VpatgMJ{TeBy$^KF2J+7jS$N}Z+>c}ASAK`;L%3c0 z2$hAX8mbg9f~w6kNC4`yGgdK7A8&(lr5HsJkUM#3 z++}e7=$G3YYG{(6B4}D7{%H*N?H5E{iwULjoJUkq4K%#x?5+AR_s$J@d0FqO!GT9N zr%@cutFF~5e(j5tMvp_B0^l_0_?6nxv8kC~?^E~x$A890XO`^wexLvV002ovPDHLk FV1iUJeKG(5 literal 0 HcmV?d00001 diff --git a/plugins/identica/identica.js b/plugins/identica/identica.js new file mode 100644 index 00000000..d31fc55f --- /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 00000000..e7a5b357 --- /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 0000000000000000000000000000000000000000..ee3cb61ea83e774986cf51e66984d80dc1deff4c GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!D3?x-;bCrM;OS+@4BLl<6e(pbstUx|nfKP}k zkp7jxQorOuIgrIz666=m;PC858jvIC>Eal|aXmSKf%&(6i=YGpL!2Ss(Stpa>wuCB Mp00i_>zopr0FTrhAOHXW literal 0 HcmV?d00001 diff --git a/plugins/pinterest/pinterest.js b/plugins/pinterest/pinterest.js new file mode 100644 index 00000000..01c525f5 --- /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 00000000..83a95a44 --- /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 0000000000000000000000000000000000000000..b85aed3cd6be0c16eb3b4c3c83eb3f9f2ca5abd3 GIT binary patch literal 3829 zcmaJ^2{e^$*WSlD<}qVPnKBOL)2s+T155JhGcIXZ?yLWIaX zmU(!QsUsZcfAsz9{n!8h-}?4i_r0I>+}E}5YwvsCYdufY2@6AJ20jJ=U^X_=vqn7I z-k_sF=0j@~SH#i#8aZAAVC2{vC`d`$55Qn~0f#$r!qdm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TjsHoZx=Uy=?}>#wn+?Cg%WVY7augu=u^nN#e*kZO~%?d0ZEY57H~vv+IEXR-ffcHoqTT`jm$=$E%OG zJFmX;TP+=$;;?^bpYlrmtoOX%yvA8qOTPka0{)O>JEJDtT@v7uRvVLo9=5_xWyX z2@kh?&}PpFA z2*A7xfO--DkI$2{p9}yng2sBfwl`70hFRW5Q79CU=Ho;81_T&jFc?o16%`hV$AXN1 zXRDOm-S;~?J4uhj!z+8Hrzs%C%S)A(kPt;IFQ;s*uOspPv+ZH_uzQ?6E-LZyV`C99 zF@nC4(LXzOBqqc6*JZHO-Tmhsn}h@i+nfM}i=O{rs@}bWk-){#s(-FYJlBc=)ZFhev}jbV9aaY!5#Rd@M)+4D-{}MYwKZSZ4FQe3A3;Odz}9XfXKlhOJv0FN#jve zgpHL|SYKIz#nv{UL5j(xsPHe@2#XrQ{z(CO{zn0Wun+Dk)Hj9L8dh{H8u0n@-oQezkqK>=0GPc38d9k_(>qbuZqe)d9omdWS5ix$*eS( zMX)GD?e^AIJ!X?cdbPT;at1?94YNp<<*Nv=GCK#~-+us37G_{XQv)5+ft)5rz~gcn zCdbG3c7}o8URYjS%s>TQzpjbgg?c%p@@z=wk&)xsi%!qL06hDVe@Mi(e*cEmJw^Y$ z^FUu8j13JXCB?+tL?JhdQAJ%{NM1<^&&0xFPL07FKq8?3F#pelT;*SgHP6q^W)@{< fmm|v?$e~au)8E7ASoJ>r+`}8|Tj-TwUGDuC7tyqi literal 0 HcmV?d00001 diff --git a/plugins/pocket/pocket.js b/plugins/pocket/pocket.js new file mode 100644 index 00000000..021d5bb0 --- /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 00000000..56592a52 --- /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 0000000000000000000000000000000000000000..ff6bc85a450c35cc26fb912538bfc38ce88c0fe0 GIT binary patch literal 471 zcmV;|0Vw{7P)daKEuIp3XgX5e3!T8pE4;||g-z&C2_liSNn-vDZt zHguZDE4fmHU6FWasHBy3M_{ruDme$`TA zUT*)|?6p0O+VpK1v{D@(UE6s9JI{ZNPVNEDSDNzxhxPm8SI=JnOtKtE4-V^%^;8s( z@|ETs!2ZaSd$owSNPWhZRa5}Rt3qRCkb_yoo9`nN4*{}>*Mhz>KpC%A0EuF%=J;Tp znUp<{MfS0@mAh=qCQ(dPLW~p}hDF&3uw+TOq}-Bq2DM=!QfyRyBEbIeR*8*B~P;YeGMSn&NmG<6A@wt0>>45*P{s5oJlkTTY`F{Wa N002ovPDHLkV1k&R%)$Tw literal 0 HcmV?d00001 -- 2.39.5