summaryrefslogtreecommitdiff
path: root/plugins/af_readability
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-24 21:56:52 +0300
committerAndrew Dolgov <[email protected]>2021-02-24 21:56:52 +0300
commit93940d2a9f80d9e1dac49b5eb7db23230d31c5f6 (patch)
tree71016661f6017918d0934eb462bd9552018d557a /plugins/af_readability
parent8b022c2bfb356d7dddaf334bc931d6dec77086fb (diff)
parent1adacd057230aea4ede29dab510385bf01cf99a3 (diff)
Merge branch 'master' of git.fakecake.org:fox/tt-rss into weblate-integration
Diffstat (limited to 'plugins/af_readability')
-rw-r--r--plugins/af_readability/init.js8
-rwxr-xr-xplugins/af_readability/init.php166
2 files changed, 82 insertions, 92 deletions
diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js
index 3155475cc..0232ed32d 100644
--- a/plugins/af_readability/init.js
+++ b/plugins/af_readability/init.js
@@ -1,9 +1,11 @@
+/* global xhr, App, Plugins, Article, Notify */
+
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);
@@ -16,7 +18,7 @@ Plugins.Af_Readability = {
Notify.progress("Loading, please wait...");
- xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => {
+ xhr.json("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 a76c98380..be9220cda 100755
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -18,7 +18,7 @@ class Af_Readability extends Plugin {
}
function save() {
- $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]);
+ $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"] ?? "");
$this->host->set($this, "enable_share_anything", $enable_share_anything);
@@ -29,11 +29,6 @@ class Af_Readability extends Plugin {
{
$this->host = $host;
- if (version_compare(PHP_VERSION, '7.0.0', '<')) {
- user_error("af_readability requires PHP 7.0", E_USER_WARNING);
- return;
- }
-
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
$host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
@@ -60,99 +55,92 @@ class Af_Readability extends Plugin {
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
- print "<div dojoType='dijit.layout.AccordionPane'
- title=\"<i class='material-icons'>extension</i> ".__('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 {
+ ?>
+ <div dojoType='dijit.layout.AccordionPane'
+ title="<i class='material-icons'>extension</i> <?= __('Readability settings (af_readability)') ?>">
- print "<h2>" . __("Global settings") . "</h2>";
+ <?= format_notice("Enable for specific feeds in the feed editor.") ?>
- print_notice("Enable for specific feeds in the feed editor.");
+ <form dojoType='dijit.form.Form'>
- print "<form dojoType='dijit.form.Form'>";
+ <?= \Controls\pluginhandler_tags($this, "save") ?>
- print "<script type='dojo/method' event='onSubmit' args='evt'>
- evt.preventDefault();
- if (this.validate()) {
- console.log(dojo.objectToQuery(this.getValues()));
- new Ajax.Request('backend.php', {
- parameters: dojo.objectToQuery(this.getValues()),
- onComplete: function(transport) {
- Notify.info(transport.responseText);
+ <script type="dojo/method" event="onSubmit" args="evt">
+ evt.preventDefault();
+ if (this.validate()) {
+ Notify.progress('Saving data...', true);
+ xhr.post("backend.php", this.getValues(), (reply) => {
+ Notify.info(reply);
+ })
}
- });
- //this.reset();
- }
- </script>";
-
- print_hidden("op", "pluginhandler");
- print_hidden("method", "save");
- print_hidden("plugin", "af_readability");
-
- $enable_share_anything = $this->host->get($this, "enable_share_anything");
-
- print "<fieldset>";
- print "<label class='checkbox'> ";
- print_checkbox("enable_share_anything", $enable_share_anything);
- print " " . __("Provide full-text services to core code (bookmarklets) and other plugins");
- print "</label>";
- print "</fieldset>";
-
- print_button("submit", __("Save"), "class='alt-primary'");
- print "</form>";
-
- /* 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 "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
-
- print "<ul class='panel panel-scrollable list list-unstyled'>";
- foreach ($enabled_feeds as $f) {
- $is_append = in_array($f, $append_feeds);
-
- print "<li><i class='material-icons'>rss_feed</i> <a href='#'
- onclick='CommonDialogs.editFeed($f)'>".
- Feeds::getFeedTitle($f) . " " . ($is_append ? __("(append)") : "") . "</a></li>";
- }
- print "</ul>";
- }
-
- }
-
- print "</div>";
+ </script>
+
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("enable_share_anything", $enable_share_anything) ?>
+ <?= __("Provide full-text services to core code (bookmarklets) and other plugins") ?>
+ </label>
+ </fieldset>
+
+ <hr/>
+
+ <?= \Controls\submit_tag(__("Save")) ?>
+ </form>
+
+ <?php
+ /* 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);
+ ?>
+
+ <?php if (count($enabled_feeds) > 0) { ?>
+ <hr/>
+ <h3><?= __("Currently enabled for (click to edit):") ?></h3>
+
+ <ul class='panel panel-scrollable list list-unstyled'>
+ <?php foreach ($enabled_feeds as $f) { ?>
+ <li>
+ <i class='material-icons'>rss_feed</i>
+ <a href='#' onclick="CommonDialogs.editFeed(<?= $f ?>)">
+ <?= Feeds::_get_title($f) . " " . (in_array($f, $append_feeds) ? __("(append)") : "") ?>
+ </a>
+ </li>
+ <?php } ?>
+ </ul>
+ <?php } ?>
+ </div>
+ <?php
}
function hook_prefs_edit_feed($feed_id) {
- print "<header>".__("Readability")."</header>";
- print "<section>";
-
$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 "<fieldset>";
-
- print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_enabled'
- name='af_readability_enabled' $enable_checked>&nbsp;".__('Inline article content')."</label>";
-
- print "</fieldset><fieldset>";
-
- print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_append'
- name='af_readability_append' $append_checked>&nbsp;".__('Append to summary, instead of replacing it')."</label>";
-
- print "</section>";
+ ?>
+
+ <header><?= __("Readability") ?></header>
+ <section>
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("af_readability_enabled", in_array($feed_id, $enabled_feeds)) ?>
+ <?= __('Inline article content') ?>
+ </label>
+ </fieldset>
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("af_readability_append", in_array($feed_id, $append_feeds)) ?>
+ <?= __('Append to summary, instead of replacing it') ?>
+ </label>
+ </fieldset>
+ </section>
+ <?php
}
function hook_prefs_save_feed($feed_id) {
@@ -333,7 +321,7 @@ class Af_Readability extends Plugin {
}
function embed() {
- $article_id = (int) $_REQUEST["param"];
+ $article_id = (int) $_REQUEST["id"];
$sth = $this->pdo->prepare("SELECT link FROM ttrss_entries WHERE id = ?");
$sth->execute([$article_id]);