summaryrefslogtreecommitdiff
path: root/plugins/nsfw
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-10 20:47:00 +0300
committerAndrew Dolgov <[email protected]>2021-03-10 20:47:00 +0300
commit21e0b28cf1e6bef1fe66a86c03cffacaa52dcbf6 (patch)
tree15a3481c9eedee9930b16043c7cbf69a0e8d154e /plugins/nsfw
parentf9a9fcbb56ddfe072f80e361c921e07e4e8b3fcf (diff)
nsfw plugin: we don't actually need any JS
Diffstat (limited to 'plugins/nsfw')
-rw-r--r--plugins/nsfw/init.js18
-rw-r--r--plugins/nsfw/init.php17
2 files changed, 3 insertions, 32 deletions
diff --git a/plugins/nsfw/init.js b/plugins/nsfw/init.js
deleted file mode 100644
index 71fe4747b..000000000
--- a/plugins/nsfw/init.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* global Plugins */
-
-Plugins.NSFW = {
- toggle: function(elem) {
- elem = elem.domNode || elem;
-
- const content = elem.closest(".nsfw-wrapper").querySelector('.nsfw-content');
-
- // we can't use .toggle() here because this script could be invoked by the api client
- // so it's back to vanilla js
-
- if (content.style.display == 'none')
- content.style.display = '';
- else
- content.style.display = 'none';
- }
-}
-
diff --git a/plugins/nsfw/init.php b/plugins/nsfw/init.php
index 8ace94b51..0d876c423 100644
--- a/plugins/nsfw/init.php
+++ b/plugins/nsfw/init.php
@@ -20,10 +20,6 @@ class NSFW extends Plugin {
}
- function get_js() {
- return file_get_contents(__DIR__ . "/init.js");
- }
-
function hook_article_image($enclosures, $content, $site_url, $article) {
$tags = explode(",", $this->host->get($this, "tags"));
$article_tags = $article["tags"];
@@ -35,19 +31,12 @@ class NSFW extends Plugin {
}
}
- private function rewrite_contents($article, bool $add_api_js = false) {
+ private function rewrite_contents($article) {
$tags = explode(",", $this->host->get($this, "tags"));
$article_tags = $article["tags"];
if (count(array_intersect($tags, $article_tags)) > 0) {
- $article["content"] = "<div class='nsfw-wrapper'>".
- \Controls\button_tag(__("Not work safe (click to toggle)"), '', ['onclick' => 'Plugins.NSFW.toggle(this)']).
- "<div class='nsfw-content' style='display : none'>".$article["content"]."</div>
- </div>";
-
- if ($add_api_js) {
- $article["content"] .= "<script type='text/javascript'>const Plugins = {}; " . $this->get_js() . "</script>";
- }
+ $article["content"] = "<details><summary>" . __("Not safe for work (click to toggle)") . "</summary>" . $article["content"] . "</details>";
}
return $article;
@@ -55,7 +44,7 @@ class NSFW extends Plugin {
function hook_render_article_api($row) {
$article = isset($row['headline']) ? $row['headline'] : $row['article'];
- return $this->rewrite_contents($article, true);
+ return $this->rewrite_contents($article);
}
function hook_render_article($article) {