From 17413078a72e1298c6dc8953c40e8d83ce38c49c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 18:32:02 +0300 Subject: pref feeds: index cleanup, split into several methods, use tabs to maximize space for feed tree, persist feed tree state --- plugins/share/init.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/share/init.php b/plugins/share/init.php index 0794f5125..42923ed8a 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -42,13 +42,13 @@ class Share extends Plugin { function hook_prefs_tab_section($id) { if ($id == "prefFeedsPublishedGenerated") { - print "

" . __("You can disable all articles shared by unique URLs here.") . "

"; + print "
"; + + print "

" . __("You can disable all articles shared by unique URLs here.") . "

"; print " "; - print "

"; - } } -- cgit v1.2.3 From 15fd23c374eb32c50733de1906065f552afbfbc4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 09:15:51 +0300 Subject: use shortcut echo syntax for php templates --- plugins/af_redditimgur/init.php | 4 ++-- plugins/auth_internal/init.php | 18 +++++++++--------- plugins/toggle_sidebar/init.php | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 2e89fcdff..b9a2db68d 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -648,11 +648,11 @@ class Af_RedditImgur extends Plugin {
- +
- +
diff --git a/plugins/auth_internal/init.php b/plugins/auth_internal/init.php index a69ea444c..6a68534ea 100644 --- a/plugins/auth_internal/init.php +++ b/plugins/auth_internal/init.php @@ -63,21 +63,21 @@ class Auth_Internal extends Auth_Base { Tiny Tiny RSS - + -

+

- - - - "> - "> - "> + + + "> + "> + ">
- +
diff --git a/plugins/toggle_sidebar/init.php b/plugins/toggle_sidebar/init.php index f8ec35a91..19ca960e2 100644 --- a/plugins/toggle_sidebar/init.php +++ b/plugins/toggle_sidebar/init.php @@ -24,7 +24,7 @@ class Toggle_Sidebar extends Plugin { Date: Sun, 14 Feb 2021 22:17:13 +0300 Subject: render headline-specific toolbar on the client --- plugins/mail/init.php | 7 ++++++- plugins/mailto/init.php | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 40d147fc9..829620ebc 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -15,12 +15,17 @@ class Mail extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this); + $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this); } function get_js() { return file_get_contents(dirname(__FILE__) . "/mail.js"); } + function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { + return "
".__('Forward by email')."
"; + } + function save() { $addresslist = $_POST["addresslist"]; @@ -32,7 +37,7 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
mail ".__('Mail plugin')."\">"; print "

" . __("You can set predefined email addressed here (comma-separated list):") . "

"; diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php index 390984b71..3e24dcf29 100644 --- a/plugins/mailto/init.php +++ b/plugins/mailto/init.php @@ -12,6 +12,11 @@ class MailTo extends Plugin { $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this); + } + + function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { + return "
".__('Forward by email')."
"; } function get_js() { -- cgit v1.2.3 From 82adb01307e108e8a2b4eeb900552160d730d0b7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 14:10:46 +0300 Subject: render enclosures on the client --- plugins/shorten_expanded/init.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'plugins') diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 30bfac6ba..181e426a4 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -1,3 +1,5 @@ +/* global Plugins, __, require, PluginHost */ + const _shorten_expanded_threshold = 1.5; //window heights Plugins.Shorten_Expanded = { @@ -22,26 +24,23 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { window.setTimeout(function() { if (row) { - const c_inner = row.select(".content-inner")[0]; - const c_inter = row.select(".intermediate")[0]; + const content = row.querySelector(".content-inner"); + const attachments = row.querySelector(".attachments-inline"); - if (c_inner && c_inter && + if (content && attachments && row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - let tmp = document.createElement("div"); - - c_inter.select("> *:not([class*='attachments'])").each(function(p) { - p.parentNode.removeChild(p); - tmp.appendChild(p); - }); - - c_inner.innerHTML = `
- ${c_inner.innerHTML} - ${tmp.innerHTML}
+ content.innerHTML = ` +
+ ${content.innerHTML} + ${attachments.innerHTML} +
`; - dojo.parser.parse(c_inner); + attachments.innerHTML = ""; + + dojo.parser.parse(content); } } }, 150); -- cgit v1.2.3 From 020f062a76746a313fae9c82fbcf9b37fcc9d459 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:43:07 +0300 Subject: feeds: unify naming --- plugins/af_comics/filters/af_comics_gocomics.php | 2 +- plugins/af_comics/filters/af_comics_gocomics_farside.php | 2 +- plugins/af_psql_trgm/init.php | 2 +- plugins/af_readability/init.php | 2 +- plugins/vf_shared/init.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php index 949b7a235..6c5c7c0d3 100644 --- a/plugins/af_comics/filters/af_comics_gocomics.php +++ b/plugins/af_comics/filters/af_comics_gocomics.php @@ -11,7 +11,7 @@ class Af_Comics_Gocomics extends Af_ComicFilter { public function on_subscribe($url) { if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) - return ''; // Get is_html() to return false. + return ''; // Get _is_html() to return false. else return false; } diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php index 9663da8f9..89322209d 100644 --- a/plugins/af_comics/filters/af_comics_gocomics_farside.php +++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php @@ -11,7 +11,7 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { public function on_subscribe($url) { if (preg_match("#^https?://www\.thefarside\.com#", $url)) - return ''; // Get is_html() to return false. + return ''; // Get _is_html() to return false. else return false; } diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 163b0ec38..47ff98fc2 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -209,7 +209,7 @@ class Af_Psql_Trgm extends Plugin { print "
  • " . "rss_feed " . - Feeds::getFeedTitle($f) . "
  • "; + Feeds::_get_title($f) . ""; } print ""; } diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index a76c98380..4d21a831c 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -122,7 +122,7 @@ class Af_Readability extends Plugin { print "
  • rss_feed ". - Feeds::getFeedTitle($f) . " " . ($is_append ? __("(append)") : "") . "
  • "; + Feeds::_get_title($f) . " " . ($is_append ? __("(append)") : "") . ""; } print ""; } diff --git a/plugins/vf_shared/init.php b/plugins/vf_shared/init.php index 8c38cbf32..1112f6f2f 100644 --- a/plugins/vf_shared/init.php +++ b/plugins/vf_shared/init.php @@ -60,7 +60,7 @@ class VF_Shared extends Plugin { "override_vfeed" => "ttrss_feeds.title AS feed_title," ); - $qfh_ret = Feeds::queryFeedHeadlines($params); + $qfh_ret = Feeds::_get_headlines($params); $qfh_ret[1] = __("Shared articles"); return $qfh_ret; -- cgit v1.2.3 From 257efb43c6e32226280d8198acc946a2fc4c454f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:52:28 +0300 Subject: article: unify naming --- plugins/note/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/note/init.php b/plugins/note/init.php index 3c2ca0075..d5b231190 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -65,7 +65,7 @@ class Note extends Plugin { WHERE ref_id = ? AND owner_uid = ?"); $sth->execute([$note, $id, $_SESSION['uid']]); - $formatted_note = Article::format_article_note($id, $note); + $formatted_note = Article::_format_note_html($id, $note); print json_encode(array("note" => $formatted_note, "raw_length" => mb_strlen($note))); -- cgit v1.2.3 From 166f2d46666bb872a1f30a5ab23b113f2f481640 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:11:30 +0300 Subject: diskcache: unify naming --- plugins/af_proxy_http/init.php | 4 ++-- plugins/cache_starred_images/init.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 3bde08fdb..3f26ca900 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -59,14 +59,14 @@ class Af_Proxy_Http extends Plugin { $local_filename = sha1($url); if ($this->cache->exists($local_filename)) { - header("Location: " . $this->cache->getUrl($local_filename)); + header("Location: " . $this->cache->get_url($local_filename)); return; } else { $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); if ($data) { if ($this->cache->put($local_filename, $data)) { - header("Location: " . $this->cache->getUrl($local_filename)); + header("Location: " . $this->cache->get_url($local_filename)); return; } } else { diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index 9dd4cd49d..9c2d4cb7e 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -17,18 +17,18 @@ class Cache_Starred_Images extends Plugin { $this->host = $host; $this->cache = new DiskCache("starred-images"); - if ($this->cache->makeDir()) - chmod($this->cache->getDir(), 0777); + if ($this->cache->make_dir()) + chmod($this->cache->get_dir(), 0777); if (!$this->cache->exists(".no-auto-expiry")) $this->cache->touch(".no-auto-expiry"); - if ($this->cache->isWritable()) { + if ($this->cache->is_writable()) { $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); $host->add_hook($host::HOOK_SANITIZE, $this); } else { - user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING); + user_error("Starred cache directory ".$this->cache->get_dir()." is not writable.", E_USER_WARNING); } } @@ -69,9 +69,9 @@ class Cache_Starred_Images extends Plugin { /* actual housekeeping */ - Debug::log("expiring " . $this->cache->getDir() . "..."); + Debug::log("expiring " . $this->cache->get_dir() . "..."); - $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE); + $files = glob($this->cache->get_dir() . "/*.{png,mp4,status}", GLOB_BRACE); $last_article_id = 0; $article_exists = 1; @@ -98,7 +98,7 @@ class Cache_Starred_Images extends Plugin { $local_filename = $article_id . "-" . sha1($enc["content_url"]); if ($this->cache->exists($local_filename)) { - $enc["content_url"] = $this->cache->getUrl($local_filename); + $enc["content_url"] = $this->cache->get_url($local_filename); } return $enc; @@ -117,7 +117,7 @@ class Cache_Starred_Images extends Plugin { $local_filename = $article_id . "-" . sha1($src); if ($this->cache->exists($local_filename)) { - $entry->setAttribute("src", $this->cache->getUrl($local_filename)); + $entry->setAttribute("src", $this->cache->get_url($local_filename)); $entry->removeAttribute("srcset"); } } @@ -151,7 +151,7 @@ class Cache_Starred_Images extends Plugin { $status_filename = $article_id . "-" . sha1($site_url) . ".status"; /* housekeeping might run as a separate user, in this case status/media might not be writable */ - if (!$this->cache->isWritable($status_filename)) { + if (!$this->cache->is_writable($status_filename)) { Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE); return false; } -- cgit v1.2.3 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') 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 6e06fe2885f2250d446d613215dbadf63d08a766 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 08:31:24 +0300 Subject: shorten_expanded: fix for posts without attachments --- plugins/shorten_expanded/init.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 181e426a4..873749c03 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -25,20 +25,23 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { if (row) { const content = row.querySelector(".content-inner"); - const attachments = row.querySelector(".attachments-inline"); - if (content && attachments && - row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + //console.log('shorten', row.offsetHeight, 'vs', _shorten_expanded_threshold * window.innerHeight); + + if (content && row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + + const attachments = row.querySelector(".attachments-inline"); // optional content.innerHTML = `
    ${content.innerHTML} - ${attachments.innerHTML} + ${attachments ? attachments.innerHTML : ''}
    `; - attachments.innerHTML = ""; + if (attachments) + attachments.innerHTML = ""; dojo.parser.parse(content); } -- cgit v1.2.3 From 26d6b84a572b5cbd99acffc5ae727ea6d1be543a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- plugins/mail/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 829620ebc..b1263ece5 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -160,7 +160,7 @@ class Mail extends Plugin { style=\"width : 30em;\" name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); + print \Controls\select_tag("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); /* print "
    "; */ -- cgit v1.2.3 From 1f43d7916cda16e9680b9087bda1f52934e8f25b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:32:06 +0300 Subject: replace print_hidden with hidden_tag --- plugins/af_proxy_http/init.php | 6 +++--- plugins/af_psql_trgm/init.php | 6 +++--- plugins/af_readability/init.php | 6 +++--- plugins/af_redditimgur/init.php | 6 +++--- plugins/mail/init.php | 16 ++++++++-------- plugins/note/init.php | 8 ++++---- plugins/nsfw/init.php | 6 +++--- 7 files changed, 27 insertions(+), 27 deletions(-) (limited to 'plugins') diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 3f26ca900..b82999281 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -218,9 +218,9 @@ class Af_Proxy_Http extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_proxy_http"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_proxy_http"); $proxy_all = $this->host->get($this, "proxy_all"); print_checkbox("proxy_all", $proxy_all); diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 47ff98fc2..715e63927 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -157,9 +157,9 @@ class Af_Psql_Trgm extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_psql_trgm"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_psql_trgm"); print "

    " . __("Global settings") . "

    "; diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 4d21a831c..435864c21 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -87,9 +87,9 @@ class Af_Readability extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_readability"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_readability"); $enable_share_anything = $this->host->get($this, "enable_share_anything"); diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index b9a2db68d..b9891ea03 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -58,9 +58,9 @@ class Af_RedditImgur extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_redditimgur"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_redditimgur"); print "
    "; print "
    + host->set($this, "tags", $tags); diff --git a/plugins/share/init.php b/plugins/share/init.php index 42923ed8a..846e1f39c 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -41,14 +41,14 @@ class Share extends Plugin { function hook_prefs_tab_section($id) { if ($id == "prefFeedsPublishedGenerated") { + ?> +
    - print "
    "; - - print "

    " . __("You can disable all articles shared by unique URLs here.") . "

    "; - - print " "; +

    + + execute([$uuid, $param, $_SESSION['uid']]); } - print "
    " . __("You can share this article by the following unique URL:") . "
    "; + $url_path = htmlspecialchars(get_self_url_prefix() . "/public.php?op=share&key=$uuid"); - $url_path = get_self_url_prefix(); - $url_path .= "/public.php?op=share&key=$uuid"; + ?> - print "
    -
    - $url_path -
    -
    "; +
    - /* if (!label_find_id(__('Shared'), $_SESSION["uid"])) - label_create(__('Shared'), $_SESSION["uid"]); - label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */ +
    +
    + +
    +
    + "; - - print ""; - - print ""; - - print ""; - - print ""; + ?> +
    + 'alt-danger', 'onclick' => "App.dialogOf(this).unshare()"]) ?> + "App.dialogOf(this).newurl()"]) ?> + +
    + Date: Wed, 17 Feb 2021 08:52:39 +0300 Subject: share plugin: cleanup, fix icon not highlighting properly --- plugins/share/init.php | 37 ++++++++++++---------------- plugins/share/share.css | 2 +- plugins/share/share.js | 58 +++++++++++++++++++++++--------------------- plugins/share/share_prefs.js | 8 +++--- 4 files changed, 52 insertions(+), 53 deletions(-) (limited to 'plugins') diff --git a/plugins/share/init.php b/plugins/share/init.php index 846e1f39c..a569393fe 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -17,18 +17,17 @@ class Share extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/share.js"); + return file_get_contents(__DIR__ . "/share.js"); } function get_css() { - return file_get_contents(dirname(__FILE__) . "/share.css"); + return file_get_contents(__DIR__ . "/share.css"); } function get_prefs_js() { - return file_get_contents(dirname(__FILE__) . "/share_prefs.js"); + return file_get_contents(__DIR__ . "/share_prefs.js"); } - function unshare() { $id = $_REQUEST['id']; @@ -36,7 +35,7 @@ class Share extends Plugin { AND owner_uid = ?"); $sth->execute([$id, $_SESSION['uid']]); - print "OK"; + print __("Article unshared"); } function hook_prefs_tab_section($id) { @@ -52,16 +51,14 @@ class Share extends Plugin { } } - // Silent function clearArticleKeys() { $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE owner_uid = ?"); $sth->execute([$_SESSION['uid']]); - return; + print __("Shared URLs cleared."); } - function newkey() { $id = $_REQUEST['id']; $uuid = uniqid_short(); @@ -70,26 +67,25 @@ class Share extends Plugin { AND owner_uid = ?"); $sth->execute([$uuid, $id, $_SESSION['uid']]); - print json_encode(array("link" => $uuid)); + print json_encode(["link" => $uuid]); } function hook_article_button($line) { - $img_class = $line['uuid'] ? "shared" : ""; + $icon_class = !empty($line['uuid']) ? "is-shared" : ""; - return "link"; } - function shareArticle() { - $param = $_REQUEST['param']; + function shareDialog() { + $id = (int)clean($_REQUEST['id'] ?? 0); $sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ? AND owner_uid = ?"); - $sth->execute([$param, $_SESSION['uid']]); + $sth->execute([$id, $_SESSION['uid']]); if ($row = $sth->fetch()) { - $uuid = $row['uuid']; if (!$uuid) { @@ -97,27 +93,26 @@ class Share extends Plugin { $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ? AND owner_uid = ?"); - $sth->execute([$uuid, $param, $_SESSION['uid']]); + $sth->execute([$uuid, $id, $_SESSION['uid']]); } - $url_path = htmlspecialchars(get_self_url_prefix() . "/public.php?op=share&key=$uuid"); + $url_path = get_self_url_prefix() . "/public.php?op=share&key=$uuid"; ?>
    -
    - +
    diff --git a/plugins/share/share.css b/plugins/share/share.css index 00bad68dd..ac9247a54 100644 --- a/plugins/share/share.css +++ b/plugins/share/share.css @@ -1,3 +1,3 @@ -i.icon-share.shared { +i.material-icons.icon-share.is-shared { color : #0a0; } \ No newline at end of file diff --git a/plugins/share/share.js b/plugins/share/share.js index 3fc42d654..09fb145c9 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -1,9 +1,7 @@ -/* global Plugins, xhrJson, Notify, fox, xhrPost, __ */ +/* global dojo, Effect, Plugins, xhrJson, Notify, fox, xhrPost, __ */ Plugins.Share = { shareArticle: function(id) { - const query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ id: "shareArticleDlg", title: __("Share article by URL"), @@ -17,20 +15,23 @@ Plugins.Share = { xhrJson("backend.php", query, (reply) => { if (reply) { const new_link = reply.link; - const e = $('gen_article_url'); + const target = dialog.domNode.querySelector(".target-url"); - if (new_link) { + if (new_link && target) { - e.innerHTML = e.innerHTML.replace(/\&key=.*$/, + target.innerHTML = target.innerHTML.replace(/&key=.*$/, "&key=" + new_link); - e.href = e.href.replace(/\&key=.*$/, + target.href = target.href.replace(/&key=.*$/, "&key=" + new_link); - new Effect.Highlight(e); + // eslint-disable-next-line no-new + new Effect.Highlight(target); + + const icon = document.querySelector(".share-icon-" + id); - const img = $("SHARE-IMG-" + id); - img.addClassName("shared"); + if (icon) + icon.addClassName("is-shared"); Notify.close(); @@ -44,32 +45,35 @@ Plugins.Share = { }, unshare: function () { if (confirm(__("Remove sharing for this article?"))) { + xhrPost("backend.php", {op: "pluginhandler", plugin: "share", method: "unshare", id: id}, (transport) => { + Notify.info(transport.responseText); - const query = {op: "pluginhandler", plugin: "share", method: "unshare", id: id}; - - xhrPost("backend.php", query, () => { - try { - const img = $("SHARE-IMG-" + id); + const icon = document.querySelector(".share-icon-" + id); - if (img) { - img.removeClassName("shared"); - img.up("div[id*=RROW]").removeClassName("shared"); - } + if (icon) + icon.removeClassName("is-shared"); - dialog.hide(); - } catch (e) { - console.error(e); - } + dialog.hide(); }); } }, - href: query + content: __("Loading, please wait...") }); - dialog.show(); + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); - const img = $("SHARE-IMG-" + id); - img.addClassName("shared"); + xhrPost("backend.php", {op: "pluginhandler", plugin: "share", method: "shareDialog", id: id}, (transport) => { + dialog.attr('content', transport.responseText) + + const icon = document.querySelector(".share-icon-" + id); + + if (icon) + icon.addClassName("is-shared"); + }); + }); + + dialog.show(); } } diff --git a/plugins/share/share_prefs.js b/plugins/share/share_prefs.js index 071a6667c..29c9aeaf8 100644 --- a/plugins/share/share_prefs.js +++ b/plugins/share/share_prefs.js @@ -1,12 +1,12 @@ +/* global Plugins, Notify, xhrPost */ + Plugins.Share = { clearKeys: function() { if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) { Notify.progress("Clearing URLs..."); - const query = {op: "pluginhandler", plugin: "share", method: "clearArticleKeys"}; - - xhrPost("backend.php", query, () => { - Notify.info("Shared URLs cleared."); + xhrPost("backend.php", {op: "pluginhandler", plugin: "share", method: "clearArticleKeys"}, (transport) => { + Notify.info(transport.responseText); }); } -- cgit v1.2.3 From 273ada7353b185e20452d54a8206d5e0cef9e573 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 09:59:14 +0300 Subject: * implement shortcut syntax for exposed plugin methods * move shared article rendering code to share plugin --- plugins/share/init.php | 169 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/share/init.php b/plugins/share/init.php index a569393fe..6b7b81a2d 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -16,6 +16,10 @@ class Share extends Plugin { $host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this); } + function is_public_method($method) { + return $method == "get"; + } + function get_js() { return file_get_contents(__DIR__ . "/share.js"); } @@ -78,6 +82,168 @@ class Share extends Plugin { title='".__('Share by URL')."'>link"; } + function get() { + $uuid = clean($_REQUEST["key"] ?? ""); + + if ($uuid) { + $sth = $this->pdo->prepare("SELECT ref_id, owner_uid + FROM ttrss_user_entries WHERE uuid = ?"); + $sth->execute([$uuid]); + + if ($row = $sth->fetch()) { + header("Content-Type: text/html"); + + $id = $row["ref_id"]; + $owner_uid = $row["owner_uid"]; + + print $this->format_article($id, $owner_uid); + + return; + } + } + + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); + print "Article not found."; + } + + private function format_article($id, $owner_uid) { + + $pdo = Db::pdo(); + + $sth = $pdo->prepare("SELECT id,title,link,content,feed_id,comments,int_id,lang, + ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, + (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url, + (SELECT title FROM ttrss_feeds WHERE id = feed_id) as feed_title, + (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images, + (SELECT always_display_enclosures FROM ttrss_feeds WHERE id = feed_id) as always_display_enclosures, + num_comments, + tag_cache, + author, + guid, + note + FROM ttrss_entries,ttrss_user_entries + WHERE id = ? AND ref_id = id AND owner_uid = ?"); + $sth->execute([$id, $owner_uid]); + + $rv = ''; + + if ($line = $sth->fetch()) { + + $line["tags"] = Article::_get_tags($id, $owner_uid, $line["tag_cache"]); + unset($line["tag_cache"]); + + $line["content"] = Sanitizer::sanitize($line["content"], + $line['hide_images'], + $owner_uid, $line["site_url"], false, $line["id"]); + + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE, + function ($result) use (&$line) { + $line = $result; + }, + $line); + + $line['content'] = DiskCache::rewrite_urls($line['content']); + + header("Content-Type: text/html"); + + $rv .= " + + + ".$line["title"]."". + javascript_tag("lib/prototype.js"). + javascript_tag("js/utility.js")." + + + "; + + $rv .= "\n"; + $rv .= "\n"; + + $rv .= ""; + + $enclosures = Article::_get_enclosures($line["id"]); + list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $line["site_url"]); + + if ($og_image) { + $rv .= ""; + } + + $rv .= ""; + $rv .= "
    "; + + if ($line["link"]) { + $rv .= "

    " . $line["title"] . "

    "; + } else { + $rv .= "

    " . $line["title"] . "

    "; + } + + $rv .= "
    "; + + /* header */ + + $rv .= "
    "; + $rv .= "
    "; # row + + //$entry_author = $line["author"] ? " - " . $line["author"] : ""; + $parsed_updated = TimeHelper::make_local_datetime($line["updated"], true, + $owner_uid, true); + + $rv .= "
    ".$line['author']."
    "; + $rv .= "
    $parsed_updated
    "; + + $rv .= "
    "; # row + + $rv .= "
    "; # header + + /* content */ + + $lang = $line['lang'] ? $line['lang'] : "en"; + $rv .= "
    "; + + /* content body */ + + $rv .= $line["content"]; + + /* $rv .= Article::format_article_enclosures($id, + $line["always_display_enclosures"], + $line["content"], + $line["hide_images"]); */ + + $rv .= "
    "; # content + + $rv .= "
    "; # post + + } + + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_FORMAT_ARTICLE, + function ($result) use (&$rv) { + $rv = $result; + }, + $rv, $line); + + return $rv; + + } + function shareDialog() { $id = (int)clean($_REQUEST['id'] ?? 0); @@ -96,8 +262,7 @@ class Share extends Plugin { $sth->execute([$uuid, $id, $_SESSION['uid']]); } - $url_path = get_self_url_prefix() . "/public.php?op=share&key=$uuid"; - + $url_path = $this->host->get_public_method_url($this, "get", ["key" => $uuid]); ?>
    -- cgit v1.2.3 From 4325c30a3f7574ed2b1cc3fcf41a08d92c0ccc49 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 12:10:19 +0300 Subject: share: markup cleanup --- plugins/share/init.php | 148 ++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 83 deletions(-) (limited to 'plugins') diff --git a/plugins/share/init.php b/plugins/share/init.php index 6b7b81a2d..4c47e29d3 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -96,7 +96,7 @@ class Share extends Plugin { $id = $row["ref_id"]; $owner_uid = $row["owner_uid"]; - print $this->format_article($id, $owner_uid); + $this->format_article($id, $owner_uid); return; } @@ -125,8 +125,6 @@ class Share extends Plugin { WHERE id = ? AND ref_id = id AND owner_uid = ?"); $sth->execute([$id, $owner_uid]); - $rv = ''; - if ($line = $sth->fetch()) { $line["tags"] = Article::_get_tags($id, $owner_uid, $line["tag_cache"]); @@ -142,106 +140,90 @@ class Share extends Plugin { }, $line); + $enclosures = Article::_get_enclosures($line["id"]); + list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $line["site_url"]); + + $content_decoded = html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401); + $parsed_updated = TimeHelper::make_local_datetime($line["updated"], true, $owner_uid, true); + $line['content'] = DiskCache::rewrite_urls($line['content']); - header("Content-Type: text/html"); + ob_start(); - $rv .= " - - - ".$line["title"]."". - javascript_tag("lib/prototype.js"). - javascript_tag("js/utility.js")." + ?> + + + + + <?= $line["title"] ?> + + - - "; - - $rv .= "\n"; - $rv .= " + + + + \n"; - - $rv .= ""; - - $enclosures = Article::_get_enclosures($line["id"]); - list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $line["site_url"]); - - if ($og_image) { - $rv .= ""; - } - - $rv .= ""; - $rv .= "
    "; - - if ($line["link"]) { - $rv .= "

    " . $line["title"] . "

    "; - } else { - $rv .= "

    " . $line["title"] . "

    "; - } - - $rv .= "
    "; - - /* header */ - - $rv .= "
    "; - $rv .= "
    "; # row - - //$entry_author = $line["author"] ? " - " . $line["author"] : ""; - $parsed_updated = TimeHelper::make_local_datetime($line["updated"], true, - $owner_uid, true); - - $rv .= "
    ".$line['author']."
    "; - $rv .= "
    $parsed_updated
    "; - - $rv .= "
    "; # row - - $rv .= "
    "; # header - - /* content */ - - $lang = $line['lang'] ? $line['lang'] : "en"; - $rv .= "
    "; - - /* content body */ - - $rv .= $line["content"]; - - /* $rv .= Article::format_article_enclosures($id, - $line["always_display_enclosures"], - $line["content"], - $line["hide_images"]); */ - - $rv .= "
    "; # content + ), 500, "...")) ?>"> + + + + + + + +
    + + +

    + "> +

    + +

    + + +
    +
    +
    +
    +
    +
    +
    + +
    "> + +
    +
    + + + "; # post + $rv = ob_get_contents(); + ob_end_clean(); - } - - PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_FORMAT_ARTICLE, + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_FORMAT_ARTICLE, function ($result) use (&$rv) { $rv = $result; }, $rv, $line); - return $rv; - + print $rv; + } } function shareDialog() { -- cgit v1.2.3 From 9ac6741d2476944b77e8665e8ff9a9d811848908 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 12:25:33 +0300 Subject: af_comics: markup cleanup --- plugins/af_comics/init.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'plugins') diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index c99d4b1d8..c8a8f8637 100755 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -47,11 +47,6 @@ class Af_Comics extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
    photo ".__('Feeds supported by af_comics')."\">"; - - print "

    " . __("The following comics are currently supported:") . "

    "; - $comics = []; foreach ($this->filters as $f) { @@ -62,17 +57,22 @@ class Af_Comics extends Plugin { asort($comics); - print "
      "; - foreach ($comics as $comic) { - print "
    • $comic
    • "; - } - print "
    "; + ?> +
    - print_notice("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the Garfield comic use http://www.gocomics.com/garfield)."); +

    - print_notice('Drop any updated filters into filters.local in plugin directory.'); +
      + +
    • + +
    - print "
    "; + Garfield comic use http://www.gocomics.com/garfield).") ?> + filters.local in plugin directory.') ?> +
    + Date: Wed, 17 Feb 2021 12:36:02 +0300 Subject: af_readability: cleanup markup --- plugins/af_readability/init.php | 132 ++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 67 deletions(-) (limited to 'plugins') diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index b9c4e252e..84cfe869a 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -55,79 +55,77 @@ class Af_Readability extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
    extension ".__('Readability settings (af_readability)')."\">"; + $enable_share_anything = sql_bool_to_bool($this->host->get($this, "enable_share_anything")); - if (version_compare(PHP_VERSION, '7.0.0', '<')) { - print_error("This plugin requires PHP 7.0."); - } else { - - print "

    " . __("Global settings") . "

    "; - - print_notice("Enable for specific feeds in the feed editor."); - - print "
    "; - - print ""; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "af_readability"); - - $enable_share_anything = sql_bool_to_bool($this->host->get($this, "enable_share_anything")); - - print "
    "; - print ""; - print "
    "; + ?> +
    - print "
    "; +

    - print \Controls\submit_tag(__("Save")); - print ""; + - /* cleanup */ - $enabled_feeds = $this->filter_unknown_feeds( - $this->get_stored_array("enabled_feeds")); +
    - $append_feeds = $this->filter_unknown_feeds( - $this->get_stored_array("append_feeds")); + + + - $this->host->set($this, "enabled_feeds", $enabled_feeds); - $this->host->set($this, "append_feeds", $append_feeds); - - if (count($enabled_feeds) > 0) { - print "
    "; - print "

    " . __("Currently enabled for (click to edit):") . "

    "; - - print ""; - } - - } - - print "
    "; + + +
    + +
    + +
    + + + + + filter_unknown_feeds( + $this->get_stored_array("enabled_feeds")); + + $append_feeds = $this->filter_unknown_feeds( + $this->get_stored_array("append_feeds")); + + $this->host->set($this, "enabled_feeds", $enabled_feeds); + $this->host->set($this, "append_feeds", $append_feeds); + ?> + + 0) { ?> +
    +

    + +
      + +
    • + rss_feed + + + +
    • + +
    + +
    + Date: Wed, 17 Feb 2021 13:35:10 +0300 Subject: af_redditimgur: cleanup markup --- plugins/af_redditimgur/init.php | 101 ++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 1c520b7ed..1fa61953a 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -31,60 +31,61 @@ class Af_RedditImgur extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
    extension ".__('Reddit content settings (af_redditimgur)')."\">"; + $enable_readability = $this->host->get($this, "enable_readability"); + $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); + $reddit_to_teddit = $this->host->get($this, "reddit_to_teddit"); + ?> + +
    + +
    + + + + + + - $enable_readability = $this->host->get($this, "enable_readability"); - $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); - $reddit_to_teddit = $this->host->get($this, "reddit_to_teddit"); +
    + +
    - if (version_compare(PHP_VERSION, '5.6.0', '<')) { - print_error("Readability requires PHP version 5.6."); - } +
    + +
    - print ""; +
    + +
    - print ""; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "af_redditimgur"); - - print "
    "; - print ""; - print "
    "; - - print "
    "; - print ""; - print "
    "; - - print "
    "; - print ""; - - print "
    "; - print \Controls\submit_tag(__("Save")); - print ""; - - print "
    "; +
    + + +
    + + Date: Wed, 17 Feb 2021 13:36:24 +0300 Subject: RIP af_tumblr_1280 --- plugins/af_tumblr_1280/init.php | 91 ----------------------------------------- 1 file changed, 91 deletions(-) delete mode 100755 plugins/af_tumblr_1280/init.php (limited to 'plugins') diff --git a/plugins/af_tumblr_1280/init.php b/plugins/af_tumblr_1280/init.php deleted file mode 100755 index 5d7f366a4..000000000 --- a/plugins/af_tumblr_1280/init.php +++ /dev/null @@ -1,91 +0,0 @@ - true); - } - - function init($host) { - $this->host = $host; - - if (function_exists("curl_init")) { - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); - } - } - - function hook_article_filter($article) { - - if (!function_exists("curl_init") || ini_get("open_basedir")) - return $article; - - $doc = new DOMDocument(); - $doc->loadHTML('' . $article["content"]); - - $found = false; - - if ($doc) { - $xpath = new DOMXpath($doc); - - $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); - - foreach ($images as $img) { - $src = $img->getAttribute("src"); - - $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); - - if ($src != $test_src) { - - $ch = curl_init($test_src); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); - - @$result = curl_exec($ch); - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if ($result && $http_code == 200) { - $img->setAttribute("src", $test_src); - $found = true; - } - } - } - - $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); - - foreach ($video_sources as $source) { - $src = $source->getAttribute("src"); - - $new_src = preg_replace("/\/\d{3}$/", "", $src); - - if ($src != $new_src) { - $source->setAttribute("src", $new_src); - $found = true; - } - } - - if ($found) { - $doc->removeChild($doc->firstChild); //remove doctype - $article["content"] = $doc->saveHTML(); - } - } - - return $article; - - } - - - function api_version() { - return 2; - } - -} -- cgit v1.2.3 From 3c14eed1c2e0ad80b521e874762f9a326c33cce5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 13:45:38 +0300 Subject: close_button: fix color not applying --- plugins/close_button/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/close_button/init.php b/plugins/close_button/init.php index a2ba89478..4f33d1af0 100644 --- a/plugins/close_button/init.php +++ b/plugins/close_button/init.php @@ -15,7 +15,7 @@ class Close_Button extends Plugin { } function get_css() { - return "i.icon-close-article { color : red; }"; + return ".post .header .buttons i.material-icons.icon-close-article { color : red; }"; } function hook_article_button($line) { -- cgit v1.2.3 From 00b31c3f53db740984220bd9a745f76032890bea Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 13:55:58 +0300 Subject: af_readability: cleanup markup --- plugins/af_readability/init.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'plugins') diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 84cfe869a..aeef8cddc 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -129,26 +129,26 @@ class Af_Readability extends Plugin { } function hook_prefs_edit_feed($feed_id) { - print "
    ".__("Readability")."
    "; - print "
    "; - $enabled_feeds = $this->get_stored_array("enabled_feeds"); $append_feeds = $this->get_stored_array("append_feeds"); + ?> - $enable_checked = in_array($feed_id, $enabled_feeds) ? "checked" : ""; - $append_checked = in_array($feed_id, $append_feeds) ? "checked" : ""; - - print "
    "; - - print ""; - - print "
    "; - - print ""; - - print "
    "; +
    +
    +
    + +
    +
    + +
    +
    + Date: Wed, 17 Feb 2021 14:08:06 +0300 Subject: af_psql_trgm: don't load dialog via http --- plugins/af_psql_trgm/init.js | 17 ++++++++++------- plugins/af_psql_trgm/init.php | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.js b/plugins/af_psql_trgm/init.js index a22e673f6..e5bc21885 100644 --- a/plugins/af_psql_trgm/init.js +++ b/plugins/af_psql_trgm/init.js @@ -1,15 +1,18 @@ -/* global dijit, Plugins, __ */ +/* global dijit, dojo, Plugins, xhrPost, __ */ Plugins.Psql_Trgm = { showRelated: function (id) { - const query = "backend.php?op=pluginhandler&plugin=af_psql_trgm&method=showrelated¶m=" + encodeURIComponent(id); - const dialog = new dijit.Dialog({ title: __("Related articles"), - execute: function () { - // - }, - href: query, + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: 'pluginhandler', plugin: 'af_psql_trgm', method: 'showrelated', id: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); }); dialog.show(); diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 3662e490a..d1a029adc 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -46,7 +46,7 @@ class Af_Psql_Trgm extends Plugin { } function showrelated() { - $id = (int) $_REQUEST['param']; + $id = (int) $_REQUEST['id']; $owner_uid = $_SESSION["uid"]; $sth = $this->pdo->prepare("SELECT title FROM ttrss_entries, ttrss_user_entries -- cgit v1.2.3 From 4632d6cf558774cfcb17b3b4cf10399c3626096b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 14:14:17 +0300 Subject: fix some php8 warnings --- plugins/af_psql_trgm/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index d1a029adc..1d83ce5e0 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -15,7 +15,7 @@ class Af_Psql_Trgm extends Plugin { function save() { $similarity = (float) $_POST["similarity"]; $min_title_length = (int) $_POST["min_title_length"]; - $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]); + $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"] ?? ""); if ($similarity < 0) $similarity = 0; if ($similarity > 1) $similarity = 1; -- cgit v1.2.3 From 2b2833bb4fa6f958b89a83adea89d9e7c73daee7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 14:56:36 +0300 Subject: plugins: load dialogs via xhr instead of http --- plugins/af_redditimgur/init.php | 6 +++++- plugins/mail/init.php | 35 ++++++++--------------------------- plugins/mail/mail.js | 19 ++++++++----------- plugins/mailto/init.js | 17 ++++++++++++----- plugins/mailto/init.php | 6 +++--- plugins/note/init.php | 6 +++--- plugins/note/note.js | 15 ++++++++++----- 7 files changed, 49 insertions(+), 55 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 1fa61953a..63a23cd36 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -647,7 +647,11 @@ class Af_RedditImgur extends Plugin { fieldset { border : 0; } label { display : inline-block; min-width : 120px; } -
    + + + + + ">
    diff --git a/plugins/mail/init.php b/plugins/mail/init.php index c054196df..8a0d01aca 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -19,7 +19,7 @@ class Mail extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/mail.js"); + return file_get_contents(__DIR__ . "/mail.js"); } function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { @@ -83,9 +83,11 @@ class Mail extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); + print ""; + print \Controls\hidden_tag("op", "pluginhandler"); print \Controls\hidden_tag("plugin", "mail"); print \Controls\hidden_tag("method", "sendEmail"); @@ -156,15 +158,8 @@ class Mail extends Plugin { print ""; -/* print ""; */ - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "dojoType" => "dijit.form.ComboBox"]); - -/* print "
    "; */ + ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); print ""; @@ -184,11 +179,11 @@ class Mail extends Plugin { print ""; print "
    "; - print " "; - print ""; + print \Controls\submit_tag(__('Send email')); + print \Controls\cancel_dialog_tag(__('Cancel')); print "
    "; - //return; + print ""; } function sendEmail() { @@ -229,20 +224,6 @@ class Mail extends Plugin { print json_encode($reply); } - /* function completeEmails() { - $search = $_REQUEST["search"]; - - print "
      "; - - foreach ($_SESSION['stored_emails'] as $email) { - if (strpos($email, $search) !== false) { - print "
    • $email
    • "; - } - } - - print "
    "; - } */ - function api_version() { return 2; } diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 5ddc0dc41..4cdf6999d 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, xhrJson, Notify, fox, __ */ +/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */ Plugins.Mail = { send: function(id) { @@ -13,10 +13,7 @@ Plugins.Mail = { id = ids.toString(); } - const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "emailArticleDlg", title: __("Forward article by email"), execute: function () { if (this.validate()) { @@ -35,16 +32,16 @@ Plugins.Mail = { }); } }, - href: query + content: __("Loading, please wait...") }); - /* var tmph = dojo.connect(dialog, 'onLoad', function() { - dojo.disconnect(tmph); + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); - new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', - "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", - { tokens: '', paramName: "search" }); - }); */ + xhrPost("backend.php", {op: "pluginhandler", plugin: "mail", method: "emailArticle", ids: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); + }); dialog.show(); }, diff --git a/plugins/mailto/init.js b/plugins/mailto/init.js index ae68bf49b..4bf672a88 100644 --- a/plugins/mailto/init.js +++ b/plugins/mailto/init.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, fox, __ */ +/* global Plugins, Headlines, xhrPost, dojo, fox, __ */ Plugins.Mailto = { send: function (id) { @@ -13,12 +13,19 @@ Plugins.Mailto = { id = ids.toString(); } - const query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "emailArticleDlg", title: __("Forward article by email"), - href: query}); + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "pluginhandler", plugin: "mailto", method: "emailArticle", ids: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); + }); + dialog.show(); } diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php index 3e24dcf29..4b858eae6 100644 --- a/plugins/mailto/init.php +++ b/plugins/mailto/init.php @@ -20,7 +20,7 @@ class MailTo extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/init.js"); + return file_get_contents(__DIR__ . "/init.js"); } function hook_article_button($line) { @@ -31,7 +31,7 @@ class MailTo extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); $tpl = new Templator(); @@ -85,7 +85,7 @@ class MailTo extends Plugin { print "

    "; print "

    "; - print ""; + print \Controls\submit_tag(__('Close this dialog')); print "
    "; //return; diff --git a/plugins/note/init.php b/plugins/note/init.php index 12c56f7ad..65e1f0eef 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -27,17 +27,17 @@ class Note extends Plugin { } function edit() { - $param = $_REQUEST['param']; + $id = clean($_REQUEST['id']); $sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?"); - $sth->execute([$param, $_SESSION['uid']]); + $sth->execute([$id, $_SESSION['uid']]); if ($row = $sth->fetch()) { $note = $row['note']; - print \Controls\hidden_tag("id", "$param"); + print \Controls\hidden_tag("id", $id); print \Controls\hidden_tag("op", "pluginhandler"); print \Controls\hidden_tag("method", "setNote"); print \Controls\hidden_tag("plugin", "note"); diff --git a/plugins/note/note.js b/plugins/note/note.js index ab2ed9208..215058b21 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -1,11 +1,8 @@ -/* global Plugins, xhrJson, Notify, fox, __ */ +/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */ Plugins.Note = { edit: function(id) { - const query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "editNoteDlg", title: __("Edit article note"), execute: function () { if (this.validate()) { @@ -30,7 +27,15 @@ Plugins.Note = { }); } }, - href: query, + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "pluginhandler", plugin: "note", method: "edit", id: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); }); dialog.show(); -- cgit v1.2.3 From 2ac6508fe697ed5e95cc7bf73ffb9e2e0bf0d3fa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 15:53:00 +0300 Subject: mail, mailto: cleanup markup --- plugins/mail/init.php | 150 ++++++++++++++++++++++++++---------------------- plugins/mailto/init.js | 2 +- plugins/mailto/init.php | 33 +++++------ 3 files changed, 97 insertions(+), 88 deletions(-) (limited to 'plugins') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 8a0d01aca..bb576a4d9 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -37,42 +37,44 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
    mail ".__('Mail plugin')."\">"; - - print "

    " . __("You can set predefined email addressed here (comma-separated list):") . "

    "; - - print "
    "; - - print ""; + - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "mail"); +
    - $addresslist = $this->host->get($this, "addresslist"); + - print ""; +
    - print "

    "; + - print "

    "; + - print "
    "; +
    + "; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("plugin", "mail"); - print \Controls\hidden_tag("method", "sendEmail"); $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE id = ?"); @@ -107,9 +104,6 @@ class Mail extends Plugin { if (!$user_name) $user_name = $_SESSION['name']; - print \Controls\hidden_tag("from_email", "$user_email"); - print \Controls\hidden_tag("from_name", "$user_name"); - $tpl = new Templator(); $tpl->readTemplateFromFile("email_article_template.txt"); @@ -150,40 +144,58 @@ class Mail extends Plugin { $content = ""; $tpl->generateOutputToString($content); - print ""; - - print "
    "; - $addresslist = explode(",", $this->host->get($this, "addresslist")); - print __('To:'); - - print ""; - - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); - - print "
    "; - - print __('Subject:'); - - print ""; - - print ""; - - print "
    "; - - print "
    "; - - print "
    "; - print \Controls\submit_tag(__('Send email')); - print \Controls\cancel_dialog_tag(__('Cancel')); - print "
    "; - - print ""; + ?> + +
    + + + + + + + + + + +
    +
    + + "width: 380px", "required" => 1, "dojoType" => "dijit.form.ComboBox"]) ?> +
    +
    + +
    +
    + + +
    +
    + + + +
    + + +
    + +
    + ".__('Forward by email')."
    "; + return "
    ".__('Forward by email (mailto:)')."
    "; } function get_js() { @@ -26,7 +26,7 @@ class MailTo extends Plugin { function hook_article_button($line) { return "mail_outline"; + title='".__('Forward by email (mailto:)')."'>mail_outline"; } function emailArticle() { @@ -42,7 +42,6 @@ class MailTo extends Plugin { //$tpl->setVariable('USER_EMAIL', $user_email, true); $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND id IN ($ids_qmarks) AND owner_uid = ?"); @@ -70,25 +69,23 @@ class MailTo extends Plugin { $content = ""; $tpl->generateOutputToString($content); - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). - "&body=".rawurlencode($content)); - - print __("Clicking the following link to invoke your mail client:"); - - print ""; + $mailto_link = "mailto:?subject=".rawurlencode($subject)."&body=".rawurlencode($content); - print __("You should be able to edit the message before sending in your mail client."); + ?> - print "

    "; +

    +
    + + + +
    +
    - print "
    "; - print \Controls\submit_tag(__('Close this dialog')); - print "
    "; +
    + +
    - //return; + Date: Wed, 17 Feb 2021 15:53:58 +0300 Subject: delete unused mail .pngs --- plugins/mail/mail.png | Bin 641 -> 0 bytes plugins/mailto/mail.png | Bin 821 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 plugins/mail/mail.png delete mode 100644 plugins/mailto/mail.png (limited to 'plugins') diff --git a/plugins/mail/mail.png b/plugins/mail/mail.png deleted file mode 100644 index 7348aed77..000000000 Binary files a/plugins/mail/mail.png and /dev/null differ diff --git a/plugins/mailto/mail.png b/plugins/mailto/mail.png deleted file mode 100644 index 2c49f78a6..000000000 Binary files a/plugins/mailto/mail.png and /dev/null differ -- cgit v1.2.3 From 6ecee2abbd96eac2b0efab259c184644b71d1449 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 16:17:05 +0300 Subject: cache_starred_images: minor fixes --- plugins/cache_starred_images/init.php | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'plugins') diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index 9c2d4cb7e..bd44a2b28 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -5,7 +5,7 @@ class Cache_Starred_Images extends Plugin { private $host; /* @var DiskCache $cache */ private $cache; - private $max_cache_attempts = 5; // per-article + private $max_cache_attempts = 5; // per-article function about() { return array(1.0, @@ -38,13 +38,13 @@ class Cache_Starred_Images extends Plugin { Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, - ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data + ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON (ttrss_user_entries.feed_id = ttrss_feeds.id) WHERE ref_id = ttrss_entries.id AND marked = true AND site_url != '' AND - ttrss_user_entries.owner_uid = ? AND + ttrss_user_entries.owner_uid = ? AND plugin_data NOT LIKE '%starred_cache_images%' ORDER BY ".Db::sql_random_function()." LIMIT 100"); @@ -59,7 +59,7 @@ class Cache_Starred_Images extends Plugin { $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); if ($success) { - $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"]; + $plugin_data = "starred_cache_images," . $line["owner_uid"] . ":" . $line["plugin_data"]; $usth->execute([$plugin_data, $line['id']]); } @@ -71,7 +71,10 @@ class Cache_Starred_Images extends Plugin { Debug::log("expiring " . $this->cache->get_dir() . "..."); - $files = glob($this->cache->get_dir() . "/*.{png,mp4,status}", GLOB_BRACE); + $files = array_merge( + glob($this->cache->get_dir() . "/*.png"), + glob($this->cache->get_dir() . "/*.mp4"), + glob($this->cache->get_dir() . "/*.status")); $last_article_id = 0; $article_exists = 1; @@ -105,7 +108,7 @@ class Cache_Starred_Images extends Plugin { } function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { - $xpath = new DOMXpath($doc); + $xpath = new DOMXPath($doc); if ($article_id) { $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); @@ -158,30 +161,30 @@ class Cache_Starred_Images extends Plugin { Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); - if ($this->cache->exists($status_filename)) - $status = json_decode($this->cache->get($status_filename), true); - else - $status = []; + if ($this->cache->exists($status_filename)) + $status = json_decode($this->cache->get($status_filename), true); + else + $status = []; - $status["attempt"] += 1; + $status["attempt"] += 1; - // only allow several download attempts for article - if ($status["attempt"] > $this->max_cache_attempts) { - Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); - return false; - } + // only allow several download attempts for article + if ($status["attempt"] > $this->max_cache_attempts) { + Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); + return false; + } - if (!$this->cache->put($status_filename, json_encode($status))) { - user_error("unable to write status file: $status_filename", E_USER_WARNING); - return false; - } + if (!$this->cache->put($status_filename, json_encode($status))) { + user_error("unable to write status file: $status_filename", E_USER_WARNING); + return false; + } $doc = new DOMDocument(); $has_images = false; $success = false; - if (@$doc->loadHTML('' . $content)) { + if (@$doc->loadHTML('' . $content)) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); @@ -203,11 +206,11 @@ class Cache_Starred_Images extends Plugin { $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND (content_type LIKE '%image%' OR content_type LIKE '%video%')"); - if ($esth->execute([$article_id])) { - while ($enc = $esth->fetch()) { + if ($esth->execute([$article_id])) { + while ($enc = $esth->fetch()) { - $has_images = true; - $url = rewrite_relative_url($site_url, $enc["content_url"]); + $has_images = true; + $url = rewrite_relative_url($site_url, $enc["content_url"]); if ($this->cache_url($article_id, $url)) { $success = true; -- cgit v1.2.3 From 35b6d63289dcce3be27127aec607c970b050a986 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 16:27:52 +0300 Subject: af_proxy_http: don't try to proxy back to ourselves --- plugins/af_proxy_http/init.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 79d2f5294..5804e450f 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -50,8 +50,14 @@ class Af_Proxy_Http extends Plugin { public function imgproxy() { $url = UrlHelper::validate(clean($_REQUEST["url"])); - // called without user context, let's just redirect to original URL - if (!$_SESSION["uid"] || $_REQUEST['af_proxy_http_token'] != $_SESSION['af_proxy_http_token']) { + // immediately redirect to original URL if: + // - url points back to ourselves + // - called without user context + // - session-spefific token is invalid + if ( + strpos($url, get_self_url_prefix()) === 0 || + empty($_SESSION["uid"]) || + $_REQUEST['af_proxy_http_token'] != $_SESSION['af_proxy_http_token']) { header("Location: $url"); return; } @@ -104,6 +110,11 @@ class Af_Proxy_Http extends Plugin { } private function rewrite_url_if_needed($url, $all_remote = false) { + /* don't rewrite urls pointing to ourselves */ + + if (strpos($url, get_self_url_prefix()) === 0) + return $url; + /* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */ if (!$this->cache->exists(sha1($url))) { -- cgit v1.2.3 From e4609c18efceebb1e021d814f53061ada7f6489a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 21:44:21 +0300 Subject: * add (disabled) shortcut syntax for plugin methods * add controls shortcut for pluginhandler tags * add similar shortcut for frontend * allow plugins to selectively exclude their methods from CSRF checking --- plugins/af_proxy_http/init.php | 4 +--- plugins/af_psql_trgm/init.php | 4 +--- plugins/af_readability/init.js | 2 +- plugins/af_readability/init.php | 6 ++---- plugins/af_redditimgur/init.php | 9 +++++---- plugins/mail/init.php | 12 ++++-------- plugins/mail/mail.js | 2 +- plugins/mailto/init.js | 2 +- plugins/note/init.php | 4 +--- plugins/note/note.js | 2 +- plugins/nsfw/init.php | 4 +--- plugins/share/share.js | 8 +++----- plugins/share/share_prefs.js | 2 +- 13 files changed, 23 insertions(+), 38 deletions(-) (limited to 'plugins') diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 5804e450f..d6cee5fcd 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -229,9 +229,7 @@ class Af_Proxy_Http extends Plugin { } "; - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "af_proxy_http"); + print \Controls\pluginhandler_tags($this, "save"); $proxy_all = sql_bool_to_bool($this->host->get($this, "proxy_all")); print \Controls\checkbox_tag("proxy_all", $proxy_all); diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 1d83ce5e0..bfbbdf49c 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -157,9 +157,7 @@ class Af_Psql_Trgm extends Plugin { } "; - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "af_psql_trgm"); + print \Controls\pluginhandler_tags($this, "save"); print "

    " . __("Global settings") . "

    "; diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js index 3155475cc..ff2d94e8b 100644 --- a/plugins/af_readability/init.js +++ b/plugins/af_readability/init.js @@ -16,7 +16,7 @@ Plugins.Af_Readability = { Notify.progress("Loading, please wait..."); - xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => { + xhrJson("backend.php", App.getPhArgs("af_readability", "embed", {id: id}), (reply) => { if (content && reply.content) { content.setAttribute(self.orig_attr_name, content.innerHTML); diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index aeef8cddc..43d064fc7 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -67,9 +67,7 @@ class Af_Readability extends Plugin {
    - - - + "; - - print \Controls\pluginhandler_tags($this, "save"); + - $proxy_all = sql_bool_to_bool($this->host->get($this, "proxy_all")); - print \Controls\checkbox_tag("proxy_all", $proxy_all); - print " 
    "; - - print "
    "; + - print \Controls\submit_tag(__("Save")); +
    + +
    - print "
    "; +
    - print "
    "; + + +
    + Date: Thu, 18 Feb 2021 12:27:26 +0300 Subject: shorten many invocations of Ajax.Request in inline form methods --- plugins/af_readability/init.php | 16 ++++++---------- plugins/af_redditimgur/init.php | 13 +++++-------- plugins/mail/init.php | 14 +++++--------- plugins/nsfw/init.php | 10 ++++------ 4 files changed, 20 insertions(+), 33 deletions(-) (limited to 'plugins') diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 43d064fc7..a1f92815c 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -69,19 +69,15 @@ class Af_Readability extends Plugin { - +
    evt.preventDefault(); if (this.validate()) { - new Ajax.Request('backend.php', { - parameters: dojo.objectToQuery(this.getValues()), - onComplete: function(transport) { - Notify.info(transport.responseText); - } - }); + Notify.progress('Saving data...', true); + xhrPost("backend.php", this.getValues(), (transport) => { + Notify.info(transport.responseText); + }) } -- cgit v1.2.3 From d8a99ce06a3ce789a5971a03d97f37b2df23d0f9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 12:45:31 +0300 Subject: remove unneeded headings --- plugins/af_psql_trgm/init.php | 2 -- plugins/af_readability/init.php | 2 -- 2 files changed, 4 deletions(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index bfbbdf49c..c66c49aed 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -159,8 +159,6 @@ class Af_Psql_Trgm extends Plugin { print \Controls\pluginhandler_tags($this, "save"); - print "

    " . __("Global settings") . "

    "; - print_notice("Enable for specific feeds in the feed editor."); print "
    "; diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index a1f92815c..4cd72904a 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -61,8 +61,6 @@ class Af_Readability extends Plugin {
    -

    -
    -- 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') 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: Thu, 18 Feb 2021 13:41:40 +0300 Subject: af_psql_trgm: cleanup --- plugins/af_psql_trgm/init.php | 196 +++++++++++++++++++++--------------------- 1 file changed, 100 insertions(+), 96 deletions(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index c66c49aed..4ecfe0cd5 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -124,113 +124,117 @@ class Af_Psql_Trgm extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
    extension ".__('Mark similar articles as read (af_psql_trgm)')."\">"; + $similarity = $this->host->get($this, "similarity", $this->default_similarity); + $min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length); + $enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally")); - if (DB_TYPE != "pgsql") { - print_error("Database type not supported."); - } else { - - $res = $this->pdo->query("select 'similarity'::regproc"); - - if (!$res || !$res->fetch()) { - print_error("pg_trgm extension not found."); - } + ?> - $similarity = $this->host->get($this, "similarity", $this->default_similarity); - $min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length); - $enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally")); +
    - print ""; + pdo->query("select 'similarity'::regproc"); - print ""; - - print \Controls\pluginhandler_tags($this, "save"); - - print_notice("Enable for specific feeds in the feed editor."); - - print "
    "; - - print " "; - print ""; - - print "
    " . - __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . - "
    "; - - print "
    "; - - print " "; - print ""; - - print "
    "; - - print ""; + } ?> - print "
    "; + - print "
    "; - print \Controls\submit_tag(__("Save")); - print ""; + - /* cleanup */ - $enabled_feeds = $this->filter_unknown_feeds( - $this->get_stored_array("enabled_feeds")); - - $this->host->set($this, "enabled_feeds", $enabled_feeds); - - if (count($enabled_feeds) > 0) { - print "
    "; - print "

    " . __("Currently enabled for (click to edit):") . "

    "; - - print ""; - } - } - - print "
    "; + + + + +
    + + + +
    + +
    +
    + +
    + + +
    + +
    + +
    + +
    + + + + + filter_unknown_feeds( + $this->get_stored_array("enabled_feeds")); + + $this->host->set($this, "enabled_feeds", $enabled_feeds); + ?> + + 0) { ?> +
    +

    + +
      + +
    • + rss_feed + + + +
    • + +
    + +
    + ".__("Similarity (af_psql_trgm)").""; - print "
    "; - - $enabled_feeds = $this->get_stored_array("enabled_feeds"); - $checked = in_array($feed_id, $enabled_feeds) ? "checked" : ""; - - print "
    "; - - print ""; - - print "
    "; - - print "
    "; + $enabled_feeds = $this->get_stored_array("enabled_feeds"); + ?> +
    + +
    +
    + +
    +
    + + Date: Thu, 18 Feb 2021 21:51:18 +0300 Subject: initial for RIP prototype/scriptaculous --- plugins/af_readability/init.js | 4 ++-- plugins/af_zz_vidmute/init.js | 4 ++-- plugins/share/share.js | 3 --- plugins/shorten_expanded/init.js | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js index ff2d94e8b..6dec82f45 100644 --- a/plugins/af_readability/init.js +++ b/plugins/af_readability/init.js @@ -2,8 +2,8 @@ Plugins.Af_Readability = { orig_attr_name: 'data-readability-orig-content', self: this, embed: function(id) { - const content = $$(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" : - ".post[data-article-id=" + id + "] .content")[0]; + const content = App.find(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" : + ".post[data-article-id=" + id + "] .content"); if (content.hasAttribute(self.orig_attr_name)) { content.innerHTML = content.getAttribute(self.orig_attr_name); diff --git a/plugins/af_zz_vidmute/init.js b/plugins/af_zz_vidmute/init.js index fab9b99e6..b8be8cecd 100644 --- a/plugins/af_zz_vidmute/init.js +++ b/plugins/af_zz_vidmute/init.js @@ -3,7 +3,7 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { if (row) { - row.select("video").each(function (v) { + row.querySelectorAll("video").forEach(function (v) { v.muted = true; }); } @@ -14,7 +14,7 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) { if (row) { - row.select("video").each(function (v) { + row.querySelectorAll("video").forEach(function (v) { v.muted = true; }); } diff --git a/plugins/share/share.js b/plugins/share/share.js index 46b62ca5b..a5f60d267 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -23,9 +23,6 @@ Plugins.Share = { target.href = target.href.replace(/&key=.*$/, "&key=" + new_link); - // eslint-disable-next-line no-new - new Effect.Highlight(target); - const icon = document.querySelector(".share-icon-" + id); if (icon) diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 873749c03..0abc8c129 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -7,8 +7,8 @@ Plugins.Shorten_Expanded = { const row = $(id); if (row) { - const content = row.select(".content-shrink-wrap")[0]; - const link = row.select(".expand-prompt")[0]; + const content = row.querySelector(".content-shrink-wrap"); + const link = row.querySelector(".expand-prompt"); if (content) content.removeClassName("content-shrink-wrap"); if (link) Element.hide(link); -- cgit v1.2.3 From c088e9d9d8296fe154763da3b5297bf85c3cc3a1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 22:23:06 +0300 Subject: get rid of a few more prototype-isms --- plugins/share/init.php | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins') diff --git a/plugins/share/init.php b/plugins/share/init.php index 4c47e29d3..0c975cfdd 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -156,7 +156,6 @@ class Share extends Plugin { <?= $line["title"] ?> - + + + +
    +

    +
    + +
    + + + +
    + + +
    + + + + +
    + %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') 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: Sun, 21 Feb 2021 09:35:07 +0300 Subject: for the most part, deal with filter rules UI --- plugins/auto_assign_labels/init.php | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/auto_assign_labels/init.php b/plugins/auto_assign_labels/init.php index 3fa4ad8c0..341895cef 100755 --- a/plugins/auto_assign_labels/init.php +++ b/plugins/auto_assign_labels/init.php @@ -19,6 +19,7 @@ class Auto_Assign_Labels extends Plugin { function get_all_labels_filter_format($owner_uid) { $rv = array(); + // TODO: use Labels::get_all() $sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?"); $sth->execute([$owner_uid]); -- cgit v1.2.3 From 33fff2686946021314a24feef61032beaf48e7a4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 10:00:50 +0300 Subject: reinstate HOOK_RENDER_ENCLOSURE --- plugins/af_youtube_embed/init.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/af_youtube_embed/init.php b/plugins/af_youtube_embed/init.php index db82dc9f5..6309aac02 100644 --- a/plugins/af_youtube_embed/init.php +++ b/plugins/af_youtube_embed/init.php @@ -23,9 +23,9 @@ class Af_Youtube_Embed extends Plugin { $matches = array(); - if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) || - preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) || - preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) { + if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["content_url"], $matches) || + preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["content_url"], $matches) || + preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["content_url"], $matches)) { $vid_id = $matches[1]; -- cgit v1.2.3 From be4e7b13403666fc477d4b563ea8c075d0fd2022 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 14:41:09 +0300 Subject: fix several issues reported by phpstan --- plugins/af_fsckportal/init.php | 5 +---- plugins/af_redditimgur/init.php | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/af_fsckportal/init.php b/plugins/af_fsckportal/init.php index 04b77a15a..8caa617c6 100644 --- a/plugins/af_fsckportal/init.php +++ b/plugins/af_fsckportal/init.php @@ -19,9 +19,7 @@ class Af_Fsckportal extends Plugin { $doc = new DOMDocument(); - @$doc->loadHTML('' . $article["content"]); - - if ($doc) { + if (@$doc->loadHTML('' . $article["content"])) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//img[@src]|//a[@href])'); @@ -34,7 +32,6 @@ class Af_Fsckportal extends Plugin { } $article["content"] = $doc->saveHTML(); - } return $article; diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 2677fdd90..713eaea5c 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -207,7 +207,7 @@ class Af_RedditImgur extends Plugin { $found = false; // embed before reddit post layout - $anchor = $xpath->query('//body/*')->item(0); + $anchor = $xpath->query('//_body/*')->item(0); // deal with json-provided media content first if ($article["link"] && $anchor) { @@ -217,6 +217,7 @@ class Af_RedditImgur extends Plugin { $this->fallback_preview_urls = []; + // @phpstan-ignore-next-line if ($tmp && $anchor) { $json = json_decode($tmp, true); @@ -346,6 +347,8 @@ class Af_RedditImgur extends Plugin { if (strpos($source_stream, "imgur.com") !== false) $poster_url = str_replace(".mp4", "h.jpg", $source_stream); + else + $poster_url = false; $this->handle_as_video($doc, $entry, $source_stream, $poster_url); -- cgit v1.2.3 From 42173386b39bed4b06c5ac6c2fc0da510673b354 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 17:38:46 +0300 Subject: dirname(__FILE__) -> __DIR__ --- plugins/note/init.php | 2 +- plugins/nsfw/init.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/note/init.php b/plugins/note/init.php index f4bdf45bc..52f7be3eb 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -17,7 +17,7 @@ class Note extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/note.js"); + return file_get_contents(__DIR__ . "/note.js"); } diff --git a/plugins/nsfw/init.php b/plugins/nsfw/init.php index 3205b436b..7c5b8d00f 100644 --- a/plugins/nsfw/init.php +++ b/plugins/nsfw/init.php @@ -19,7 +19,7 @@ class NSFW extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/init.js"); + return file_get_contents(__DIR__ . "/init.js"); } function hook_render_article($article) { -- cgit v1.2.3 From e4107ac9520ca404d4ab49ef79ca74430e8fd772 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 21:47:48 +0300 Subject: wip: initial for config object --- plugins/af_psql_trgm/init.php | 4 ++-- plugins/af_redditimgur/init.php | 2 +- plugins/auth_internal/init.php | 2 +- plugins/bookmarklets/init.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 3b7ed6b14..5611d8998 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -134,7 +134,7 @@ class Af_Psql_Trgm extends Plugin { title="extension "> pdo->query("select 'similarity'::regproc"); @@ -258,7 +258,7 @@ class Af_Psql_Trgm extends Plugin { function hook_article_filter($article) { - if (DB_TYPE != "pgsql") return $article; + if (Config::get(Config::DB_TYPE) != "pgsql") return $article; $res = $this->pdo->query("select 'similarity'::regproc"); if (!$res || !$res->fetch()) return $article; diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 713eaea5c..9cd046ba4 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -530,7 +530,7 @@ class Af_RedditImgur extends Plugin { $entry_guid = $article["guid_hashed"]; $owner_uid = $article["owner_uid"]; - if (DB_TYPE == "pgsql") { + if (Config::get(Config::DB_TYPE) == "pgsql") { $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'"; } else { $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)"; diff --git a/plugins/auth_internal/init.php b/plugins/auth_internal/init.php index 6a68534ea..13a7bc969 100644 --- a/plugins/auth_internal/init.php +++ b/plugins/auth_internal/init.php @@ -244,7 +244,7 @@ class Auth_Internal extends Auth_Base { $tpl->readTemplateFromFile("password_change_template.txt"); $tpl->setVariable('LOGIN', $row["login"]); - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); + $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH)); $tpl->addBlock('message'); 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 From 211f699aa0c4211e4ee8a02446d51b9811d0c28c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 22:35:27 +0300 Subject: migrate the rest into Config:: --- plugins/af_proxy_http/init.php | 2 +- plugins/cache_starred_images/init.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index a5ba1d62d..b03cacfe4 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -68,7 +68,7 @@ class Af_Proxy_Http extends Plugin { header("Location: " . $this->cache->get_url($local_filename)); return; } else { - $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); + $data = UrlHelper::fetch(["url" => $url, "max_size" => Config::get(Config::MAX_CACHE_FILE_SIZE)]); if ($data) { if ($this->cache->put($local_filename, $data)) { diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index 9f17c492f..2dbdb99cc 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -136,7 +136,7 @@ class Cache_Starred_Images extends Plugin { if (!$this->cache->exists($local_filename)) { Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); - $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); + $data = UrlHelper::fetch(["url" => $url, "max_size" => Config::get(Config::MAX_CACHE_FILE_SIZE)]); if ($data) return $this->cache->put($local_filename, $data);; -- cgit v1.2.3 From cae54dad564bc1372f0f6cc11101b6377caef9a9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 00:27:52 +0300 Subject: af_redditimgur: fix an oopsie --- plugins/af_redditimgur/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 9cd046ba4..7d5aeff5a 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -207,7 +207,7 @@ class Af_RedditImgur extends Plugin { $found = false; // embed before reddit
    post layout - $anchor = $xpath->query('//_body/*')->item(0); + $anchor = $xpath->query('//body/*')->item(0); // deal with json-provided media content first if ($article["link"] && $anchor) { -- cgit v1.2.3 From 2ae0b7059f2ed56b92a8f396c63224b36f71df09 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 09:01:27 +0300 Subject: cleanup some defined-stuff --- plugins/af_redditimgur/init.php | 4 ++-- plugins/af_unburn/init.php | 8 ++++---- plugins/auth_remote/init.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 7d5aeff5a..1aa4793ea 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -701,7 +701,7 @@ class Af_RedditImgur extends Plugin { private function get_header($url, $header, $useragent = SELF_USER_AGENT) { $ret = false; - if (function_exists("curl_init") && !defined("NO_CURL")) { + if (function_exists("curl_init")) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -727,7 +727,7 @@ class Af_RedditImgur extends Plugin { private function readability($article, $url, $doc, $xpath, $debug = false) { - if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") && + if (function_exists("curl_init") && $this->host->get($this, "enable_readability") && mb_strlen(strip_tags($article["content"])) <= 150) { // do not try to embed posts linking back to other reddit posts diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php index 4d0c56740..386b6387f 100755 --- a/plugins/af_unburn/init.php +++ b/plugins/af_unburn/init.php @@ -21,7 +21,7 @@ class Af_Unburn extends Plugin { function hook_article_filter($article) { $owner_uid = $article["owner_uid"]; - if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) + if (!function_exists("curl_init") || ini_get("open_basedir")) return $article; if ((strpos($article["link"], "feedproxy.google.com") !== false || @@ -37,8 +37,8 @@ class Af_Unburn extends Plugin { curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); - if (defined('_CURL_HTTP_PROXY')) { - curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY); + if (Config::get(Config::HTTP_PROXY)) { + curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY)); } @curl_exec($ch); @@ -80,4 +80,4 @@ class Af_Unburn extends Plugin { return 2; } -} \ No newline at end of file +} diff --git a/plugins/auth_remote/init.php b/plugins/auth_remote/init.php index 85be67d05..f2dcfb318 100644 --- a/plugins/auth_remote/init.php +++ b/plugins/auth_remote/init.php @@ -56,7 +56,7 @@ class Auth_Remote extends Auth_Base { $_SESSION["hide_logout"] = true; // LemonLDAP can send user informations via HTTP HEADER - if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){ + if (Config::get(Config::AUTH_AUTO_CREATE)) { // update user name $fullname = isset($_SERVER['HTTP_USER_NAME']) ? $_SERVER['HTTP_USER_NAME'] : ($_SERVER['AUTHENTICATE_CN'] ?? ""); if ($fullname){ -- cgit v1.2.3