forked from shish/shimmie2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
43 changed files
with
984 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shimmie2; | ||
|
||
class FilterInfo extends ExtensionInfo | ||
{ | ||
public const KEY = "filter"; | ||
|
||
public string $key = self::KEY; | ||
public string $name = "Filter Tags"; | ||
public array $authors = ["Danbooru Project" => "", "Discomrade" => ""]; | ||
public string $license = "WTFPL"; | ||
public string $description = "Allow users to filter out tags."; | ||
public ?string $documentation = "Admins can set default filters and users can override them in user settings. This is derived from Danbooru's blacklist code, it works in the user's browser with JavaScript, and will hide posts until the filter runs."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shimmie2; | ||
|
||
class Filter extends Extension | ||
{ | ||
/** @var FilterTheme */ | ||
protected Themelet $theme; | ||
|
||
public function onInitExt(InitExtEvent $event): void | ||
{ | ||
global $config; | ||
$config->set_default_string("filter_tags", "spoilers\nguro\nscat\nfurry -rating:s\n"); | ||
} | ||
|
||
public function onPageRequest(PageRequestEvent $event): void | ||
{ | ||
global $page; | ||
$this->theme->addFilterBox(); | ||
$page->add_html_header("<script> | ||
Array.from(document.getElementsByClassName('thumb')).forEach(function(post) { | ||
post.style.display='none'; | ||
});</script>"); | ||
} | ||
|
||
public function onSetupBuilding(SetupBuildingEvent $event): void | ||
{ | ||
$sb = $event->panel->create_new_block("Filters"); | ||
$sb->add_longtext_option("filter_tags", 'Default filtered tags'); | ||
$sb->add_label("This controls the tags which are hidden by default. This feature currently requires JavaScript. Separate filters by line, or by commas. You can enter multiple tags per filter, as well as negative tags."); | ||
} | ||
|
||
public function onInitUserConfig(InitUserConfigEvent $event): void | ||
{ | ||
global $config; | ||
$event->user_config->set_default_string("filter_tags", $config->get_string("filter_tags")); | ||
} | ||
|
||
public function onUserOptionsBuilding(UserOptionsBuildingEvent $event): void | ||
{ | ||
global $user; | ||
|
||
$sb = $event->panel->create_new_block("Filters"); | ||
$sb->add_longtext_option("filter_tags", 'Default filtered tags'); | ||
$sb->add_label("This controls the tags which are hidden by default. This feature currently requires JavaScript. Separate filters by line, or by commas. You can enter multiple tags per filter, as well as negative tags."); | ||
} | ||
} |
Oops, something went wrong.