1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-06-20 11:16:36 +02:00

add nsfw plugin

This commit is contained in:
Andrew Dolgov 2013-02-23 16:02:29 +04:00
parent 32c399b1bf
commit 1b9f9925cf
2 changed files with 59 additions and 0 deletions

12
plugins/nsfw/init.js Normal file
View File

@ -0,0 +1,12 @@
function nsfwShow(elem) {
try {
content = elem.parentNode.getElementsBySelector("div.nswf.content")[0];
if (content) {
Element.toggle(content);
}
} catch (e) {
exception_error("nswfSHow", e);
}
}

47
plugins/nsfw/init.php Normal file
View File

@ -0,0 +1,47 @@
<?php
class NSFW extends Plugin {
private $link;
private $host;
function about() {
return array(1.0,
"Hide article content if tags contain \"nsfw\"",
"fox",
false);
}
function init($host) {
$this->link = $host->get_link();
$this->host = $host;
$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
}
function get_js() {
return file_get_contents(dirname(__FILE__) . "/init.js");
}
function hook_render_article($article) {
if (array_search("nsfw", $article["tags"]) !== FALSE) {
$article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
<div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
}
return $article;
}
function hook_render_article_cdm($article) {
if (array_search("nsfw", $article["tags"]) !== FALSE) {
$article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
<div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
}
return $article;
}
}
?>