From bd3c38de849330b3ed28df05c1220c631c103628 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:41:52 +0300 Subject: move bookmarklet-related subscribe_to_feed_url to bookmarklet plugin --- plugins/bookmarklets/init.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins/bookmarklets/init.php') diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index fa1bb8cf6..9e0f8f348 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -16,6 +16,12 @@ class Bookmarklets extends Plugin { $host->add_hook($host::HOOK_PREFS_TAB, $this); } + private function subscribe_to_feed_url() { + $url_path = get_self_url_prefix() . + "/public.php?op=subscribe&feed_url=%s"; + return $url_path; + } + function hook_prefs_tab($args) { if ($args == "prefFeeds") { @@ -24,7 +30,7 @@ class Bookmarklets extends Plugin { print "

" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "

"; - $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url()); + $bm_subscribe_url = str_replace('%s', '', $this->subscribe_to_feed_url()); $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); -- cgit v1.2.3 From a2c75257f191d218dae6de8e5e4ad240a0588654 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 13:16:55 +0300 Subject: bookmarklets: cleanup --- plugins/bookmarklets/init.php | 71 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'plugins/bookmarklets/init.php') diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index 9e0f8f348..a9dc3e69d 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -1,59 +1,60 @@ host = $host; + function init($host) { + $this->host = $host; - $host->add_hook($host::HOOK_PREFS_TAB, $this); - } + $host->add_hook($host::HOOK_PREFS_TAB, $this); + } - private function subscribe_to_feed_url() { + private function subscribe_to_feed_url() { $url_path = get_self_url_prefix() . "/public.php?op=subscribe&feed_url=%s"; return $url_path; } - function hook_prefs_tab($args) { - if ($args == "prefFeeds") { - - print "
bookmark ".__('Bookmarklets')."\">"; + function hook_prefs_tab($args) { + if ($args != "prefFeeds") + return; - print "

" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "

"; + $bm_subscribe_url = str_replace('%s', '', $this->subscribe_to_feed_url()); + $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); + $bm_subscribe_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+encodeURIComponent(window.location.href)}"); - $bm_subscribe_url = str_replace('%s', '', $this->subscribe_to_feed_url()); + $bm_share_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); + ?> - $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); +
- $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+encodeURIComponent(window.location.href)}"); +

- print "

"; + - print "

" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "

"; +

- print ""; + - print ""; + 'alt-info', "onclick" => "window.open('https://tt-rss.org/wiki/ShareAnything')"]) ?> - print "
"; #pane +
- } - } + Date: Fri, 19 Feb 2021 20:21:36 +0300 Subject: move bookmarklet-related methods out of public.php into the plugin --- plugins/bookmarklets/init.php | 331 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 324 insertions(+), 7 deletions(-) (limited to 'plugins/bookmarklets/init.php') diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index a9dc3e69d..4c3bbf4cc 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -16,21 +16,338 @@ class Bookmarklets extends Plugin { $host->add_hook($host::HOOK_PREFS_TAB, $this); } - private function subscribe_to_feed_url() { - $url_path = get_self_url_prefix() . - "/public.php?op=subscribe&feed_url=%s"; - return $url_path; + function is_public_method($method) { + return in_array($method, ["subscribe", "sharepopup"]); } + function subscribe() { + if (SINGLE_USER_MODE) { + UserHelper::login_sequence(); + } + + if (!empty($_SESSION["uid"])) { + + $feed_url = clean($_REQUEST["feed_url"] ?? ""); + $csrf_token = clean($_POST["csrf_token"] ?? ""); + + header('Content-Type: text/html; charset=utf-8'); + ?> + + + + <?= __("Subscribe to feed...") ?> + + + + + + + + + + + +
+

+
+ +
+ + + +
+ + +
+ + + + +
+ %s.", $feed_url)); + break; + case 1: + print_notice(T_sprintf("Subscribed to %s.", $feed_url)); + break; + case 2: + print_error(T_sprintf("Could not subscribe to %s.", $feed_url)); + break; + case 3: + print_error(T_sprintf("No feeds found in %s.", $feed_url)); + break; + case 4: + $feed_urls = $rc["feeds"]; + break; + case 5: + print_error(T_sprintf("Could not subscribe to %s.
Can't download the Feed URL.", $feed_url)); + break; + } + + if ($feed_urls) { + + print "
"; + print \Controls\public_method_tags($this, "subscribe"); + print \Controls\hidden_tag("csrf_token", $_SESSION["csrf_token"]); + + print "
"; + print ""; + print ""; + print "
"; + + print ""; + print "".__("Return to Tiny Tiny RSS").""; + + print "
"; + } + + $tp_uri = get_self_url_prefix() . "/prefs.php"; + + if ($rc['code'] <= 2){ + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE + feed_url = ? AND owner_uid = ?"); + $sth->execute([$feed_url, $_SESSION['uid']]); + $row = $sth->fetch(); + + $feed_id = $row["id"]; + } else { + $feed_id = 0; + } + + if ($feed_id) { + print "
+ + + + + ".__("Return to Tiny Tiny RSS")." +
"; + } + } + + print "
"; + } else { + Handler_Public::_render_login_form(); + } + } + + function sharepopup() { + if (SINGLE_USER_MODE) { + UserHelper::login_sequence(); + } + + header('Content-Type: text/html; charset=utf-8'); + ?> + + + + <?= __("Share with Tiny Tiny RSS") ?> + + + + + + + + + + + +
+ + "; + print "window.close();"; + print ""; + + } else { + $title = htmlspecialchars(clean($_REQUEST["title"])); + $url = htmlspecialchars(clean($_REQUEST["url"])); + + ?> +
+ + + + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ +
+ + "window.close()"]) ?> + +
+ +
+ + +
+ + + +
+ + " /> +
+ +
+ + + "/> +
+ +
+ +
+ + + +
+ +
+ +
+ + "; + subscribe_to_feed_url()); + $bm_subscribe_url = $this->host->get_public_method_url($this, "subscribe"); + $bm_share_url = $this->host->get_public_method_url($this, "sharepopup"); + $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); - $bm_subscribe_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+encodeURIComponent(window.location.href)}"); - $bm_share_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); + $bm_subscribe_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url&feed_url='+encodeURIComponent(window.location.href)}"); + $bm_share_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='$bm_share_url',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); + + //$bm_subscribe_url = str_replace('%s', '', $this->subscribe_to_feed_url()); + //$confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); + //$bm_subscribe_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+encodeURIComponent(window.location.href)}"); + + //$bm_share_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); ?>
Date: Sat, 20 Feb 2021 08:49:40 +0300 Subject: bookmarklets: cleanup some more markup --- plugins/bookmarklets/init.php | 92 ++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 49 deletions(-) (limited to 'plugins/bookmarklets/init.php') diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index 4c3bbf4cc..caa8b39df 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -118,56 +118,54 @@ class Bookmarklets extends Plugin { } if ($feed_urls) { + ?> +
+ + - print ""; - print \Controls\public_method_tags($this, "subscribe"); - print \Controls\hidden_tag("csrf_token", $_SESSION["csrf_token"]); - - print "
"; - print ""; - print ""; - print "
"; - - print ""; - print "".__("Return to Tiny Tiny RSS").""; +
+ + +
- print "
"; + + + + pdo->prepare("SELECT id FROM ttrss_feeds WHERE - feed_url = ? AND owner_uid = ?"); - $sth->execute([$feed_url, $_SESSION['uid']]); - $row = $sth->fetch(); - - $feed_id = $row["id"]; + if ($rc['code'] <= 2) { + $feed_id = Feeds::_find_by_url($feed_url, $_SESSION["uid"]); } else { $feed_id = 0; } if ($feed_id) { - print "
- - - - - ".__("Return to Tiny Tiny RSS")." -
"; + ?> +
"> + + + + + +
+ + +
"; + ?> + + + + + "; - print "window.close();"; - print ""; + ?> + + - "; + subscribe_to_feed_url()); - //$confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); - //$bm_subscribe_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+encodeURIComponent(window.location.href)}"); - - //$bm_share_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); ?>
Date: Mon, 22 Feb 2021 21:47:48 +0300 Subject: wip: initial for config object --- plugins/bookmarklets/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/bookmarklets/init.php') diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index caa8b39df..967918823 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -21,7 +21,7 @@ class Bookmarklets extends Plugin { } function subscribe() { - if (SINGLE_USER_MODE) { + if (Config::get(Config::SINGLE_USER_MODE)) { UserHelper::login_sequence(); } @@ -172,7 +172,7 @@ class Bookmarklets extends Plugin { } function sharepopup() { - if (SINGLE_USER_MODE) { + if (Config::get(Config::SINGLE_USER_MODE)) { UserHelper::login_sequence(); } -- cgit v1.2.3