From 498d71ab4510c94cb17ec081fc5b7d5c4948db0a Mon Sep 17 00:00:00 2001 From: Luana Date: Mon, 10 Jul 2023 15:04:23 -0300 Subject: [PATCH] index help html --- ext/index/main.php | 5 +- ext/index/theme.php | 284 ++++++++++++-------------------------------- 2 files changed, 77 insertions(+), 212 deletions(-) diff --git a/ext/index/main.php b/ext/index/main.php index ca1d7e16..a851fddf 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -150,10 +150,7 @@ class Index extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { if ($event->key===HelpPages::SEARCH) { - $block = new Block(); - $block->header = "General"; - $block->body = $this->theme->get_help_html(); - $event->add_block($block, 0); + $event->add_block(new Block("General", $this->theme->get_help_html()), 0); } } diff --git a/ext/index/theme.php b/ext/index/theme.php index 8c2bf8f1..10da779c 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -4,6 +4,11 @@ declare(strict_types=1); namespace Shimmie2; +use MicroHTML\HTMLElement; + +use function MicroHTML\emptyHTML; +use function MicroHTML\{BR,H3,HR,P}; + class IndexTheme extends Themelet { protected int $page_number; @@ -182,227 +187,90 @@ and of course start organising your images :-) } } - public function get_help_html(): string + public function get_help_html(): HTMLElement { - return '

Searching is largely based on tags, with a number of special keywords available that allow searching based on properties of the posts.

+ return emptyHTML( + H3("Tag Searching"), + P("Searching is largely based on tags, with a number of special keywords available that allow searching based on properties of the posts."), -
-
tagname
-

Returns posts that are tagged with "tagname".

-
+ SHM_COMMAND_EXAMPLE("tagname", 'Returns posts that are tagged with "tagname".'), + SHM_COMMAND_EXAMPLE("tagname othertagname", 'Returns posts that are tagged with "tagname" and "othertagme".'), -
-
tagname othertagname
-

Returns posts that are tagged with "tagname" and "othertagname".

-
+ BR(), + P("Most tags and keywords can be prefaced with a negative sign (-) to indicate that you want to search for posts that do not match something."), + SHM_COMMAND_EXAMPLE("-tagname", 'Returns posts that are not tagged with "tagname".'), + SHM_COMMAND_EXAMPLE("-tagname -othertagname", 'Returns posts that are not tagged with "tagname" or "othertagname".'), + SHM_COMMAND_EXAMPLE("tagname -othertagname", 'Returns posts that are tagged with "tagname", but are not tagged with "othertagname".'), -

Most tags and keywords can be prefaced with a negative sign (-) to indicate that you want to search for posts that do not match something.

+ BR(), + P('Wildcard searches are possible as well using * for "any one, more, or none" and ? for "any one".'), + SHM_COMMAND_EXAMPLE("tagn*", 'Returns posts that are tagged with "tagname", "tagnot", or anything else that starts with "tagn".'), + SHM_COMMAND_EXAMPLE("tagn?me", 'Returns posts that are tagged with "tagname", "tagnome", or anything else that starts with "tagn", has one character, and ends with "me".'), + + HR(), + H3("Comparing values (<, <=, >, >=, or =)"), + P("For example, you can use this to count tags."), + SHM_COMMAND_EXAMPLE("tags=1", "Returns posts with exactly 1 tag."), + SHM_COMMAND_EXAMPLE("tags>0", "Returns posts with 1 or more tags."), -
-
-tagname
-

Returns posts that are not tagged with "tagname".

-
+ BR(), + P("Searching for posts by aspect ratio."), + P("The relation is calculated as: width / height."), + SHM_COMMAND_EXAMPLE("ratio=4:3", "Returns posts with an aspect ratio of 4:3."), + SHM_COMMAND_EXAMPLE("ratio>16:9", "Returns posts with an aspect ratio greater than 16:9."), -
-
-tagname -othertagname
-

Returns posts that are not tagged with "tagname" and "othertagname". This is different than without the negative sign, as posts with "tagname" or "othertagname" can still be returned as long as the other one is not present.

-
+ BR(), + P("Searching by dimentions."), + SHM_COMMAND_EXAMPLE("size=640x480", "Returns posts exactly 640 pixels wide by 480 pixels high."), + SHM_COMMAND_EXAMPLE("size>1920x1080", "Returns posts with a width larger than 1920 and a height larger than 1080."), + SHM_COMMAND_EXAMPLE("width=1000", "Returns posts exactly 1000 pixels wide."), + SHM_COMMAND_EXAMPLE("height=1000", "Returns posts exactly 1000 pixels high."), -
-
tagname -othertagname
-

Returns posts that are tagged with "tagname", but are not tagged with "othertagname".

-
+ BR(), + P("Searching by file size."), + P("Supported suffixes are kb, mb, and gb. Uses multiples of 1024."), + SHM_COMMAND_EXAMPLE("filesize=1", "Returns posts exactly 1 byte in size"), + SHM_COMMAND_EXAMPLE("filesize>100mb", "Returns posts greater than 100 megabytes in size."), -

Wildcard searches are possible as well using * for "any one, more, or none" and ? for "any one".

+ BR(), + P("Searching by date posted."), + P("Date format is yyyy-mm-dd. Date posted includes time component, so = will not work unless the time is exact."), + SHM_COMMAND_EXAMPLE("posted>=2019-07-19", "Returns posts posted on or after 2019-07-19."), -
-
tagn*
-

Returns posts that are tagged with "tagname", "tagnot", or anything else that starts with "tagn".

-
+ BR(), + P("Searching posts by media length."), + P("Available suffixes are ms, s, m, h, d, and y. A number by itself will be interpreted as milliseconds. Searches using = are not likely to work unless time is specified down to the millisecond."), + SHM_COMMAND_EXAMPLE("length>=1h","Returns posts that are longer than an hour."), + SHM_COMMAND_EXAMPLE("length<=10h15m","Returns posts that are shorter than 10 hours and 15 minutes."), + SHM_COMMAND_EXAMPLE("length>=10000","Returns posts that are longer than 10,000 milliseconds, or 10 seconds."), -
-
tagn?me
-

Returns posts that are tagged with "tagname", "tagnome", or anything else that starts with "tagn", has one character, and ends with "me".

-
+ BR(), + P("Searching posts by ID."), + SHM_COMMAND_EXAMPLE("id=1234", "Find the 1234th thing uploaded."), + SHM_COMMAND_EXAMPLE("id>1234", "Find more recently posted things."), -
-
tags=1
-

Returns posts with exactly 1 tag.

-
+ HR(), + H3("Post attributes."), + P("Searching by MD5 hash."), + SHM_COMMAND_EXAMPLE("hash=0D3512CAA964B2BA5D7851AF5951F33B", "Returns post with MD5 hash 0D3512CAA964B2BA5D7851AF5951F33B."), -
-
tags>0
-

Returns posts with 1 or more tags.

-
+ BR(), + P("Searching by file name."), + SHM_COMMAND_EXAMPLE("filename=picasso.jpg", 'Returns posts that are named "picasso.jpg".'), -

Can use <, <=, >, >=, or =.

+ BR(), + P("Searching for posts by source."), + SHM_COMMAND_EXAMPLE("source=https:///google.com/", 'Returns posts with a source of "https://google.com/".'), + SHM_COMMAND_EXAMPLE("source=any", "Returns posts with a source set."), + SHM_COMMAND_EXAMPLE("source=none", "Returns posts without a source set."), -
- -

Search for posts by aspect ratio

- -
-
ratio=4:3
-

Returns posts with an aspect ratio of 4:3.

-
- -
-
ratio>16:9
-

Returns posts with an aspect ratio greater than 16:9.

-
- -

Can use <, <=, >, >=, or =. The relation is calculated by dividing width by height.

- -
- -

Search for posts by file size

- -
-
filesize=1
-

Returns posts exactly 1 byte in size.

-
- -
-
filesize>100mb
-

Returns posts greater than 100 megabytes in size.

-
- -

Can use <, <=, >, >=, or =. Supported suffixes are kb, mb, and gb. Uses multiples of 1024.

- -
- -

Search for posts by MD5 hash

- -
-
hash=0D3512CAA964B2BA5D7851AF5951F33B
-

Returns post with an MD5 hash 0D3512CAA964B2BA5D7851AF5951F33B.

-
- -
- -

Search for posts by file name

- -
-
filename=picasso.jpg
-

Returns posts that are named "picasso.jpg".

-
- -
- -

Search for posts by source

- -
-
source=https:///google.com/
-

Returns posts with a source of "https://google.com/".

-
- -
-
source=any
-

Returns posts with a source set.

-
- -
-
source=none
-

Returns posts without a source set.

-
- -
- -

Search for posts by date posted.

- -
-
posted>=2019-07-19
-

Returns posts posted on or after 2019-07-19.

-
- -

Can use <, <=, >, >=, or =. Date format is yyyy-mm-dd. Date posted includes time component, so = will not work unless the time is exact.

- -
- -

Search for posts by length.

- -
-
length>=1h
-

Returns posts that are longer than an hour.

-
- -
-
length<=10h15m
-

Returns posts that are shorter than 10 hours and 15 minutes.

-
- -
-
length>=10000
-

Returns posts that are longer than 10,000 milliseconds, or 10 seconds.

-
- -

Can use <, <=, >, >=, or =. Available suffixes are ms, s, m, h, d, and y. A number by itself will be interpreted as milliseconds. Searches using = are not likely to work unless time is specified down to the millisecond.

- -
- -

Search for posts by dimensions

- -
-
size=640x480
-

Returns posts exactly 640 pixels wide by 480 pixels high.

-
- -
-
size>1920x1080
-

Returns posts with a width larger than 1920 and a height larger than 1080.

-
- -
-
width=1000
-

Returns posts exactly 1000 pixels wide.

-
- -
-
height=1000
-

Returns posts exactly 1000 pixels high.

-
- -

Can use <, <=, >, >=, or =.

- -
- -

Search for posts by ID

- -
-
id=1234
-

Find the 1234th thing uploaded.

-
- -
-
id>1234
-

Find more recently posted things

-
- -

Can use <, <=, >, >=, or =.

- -
- -

Sorting search results can be done using the pattern order:field_direction. _direction can be either _asc or _desc, indicating ascending (123) or descending (321) order.

- -
-
order:id_asc
-

Returns posts sorted by ID, smallest first.

-
- -
-
order:width_desc
-

Returns posts sorted by width, largest first.

-
- -

These fields are supported: -

-

- '; + HR(), + H3("Sorting search results"), + P("Sorting can be done using the pattern order:field_direction."), + P("Supported fields: id, width, height, filesize, filename."), + P("Direction can be either asc or desc, indicating ascending (123) or descending (321) order."), + SHM_COMMAND_EXAMPLE("order:id_asc", "Returns posts sorted by ID, smallest first."), + SHM_COMMAND_EXAMPLE("order:width_desc", "Returns posts sorted by width, largest first."), + ); } }