use <code> where appropriate

This commit is contained in:
discomrade 2024-06-11 15:02:52 +00:00 committed by Shish
parent 24d6aff794
commit 38a7bb542b
24 changed files with 64 additions and 55 deletions

View file

@ -8,11 +8,11 @@ use MicroHTML\HTMLElement;
use function MicroHTML\{emptyHTML}; use function MicroHTML\{emptyHTML};
use function MicroHTML\A; use function MicroHTML\A;
use function MicroHTML\CODE;
use function MicroHTML\DIV;
use function MicroHTML\FORM; use function MicroHTML\FORM;
use function MicroHTML\INPUT; use function MicroHTML\INPUT;
use function MicroHTML\DIV;
use function MicroHTML\OPTION; use function MicroHTML\OPTION;
use function MicroHTML\PRE;
use function MicroHTML\P; use function MicroHTML\P;
use function MicroHTML\SELECT; use function MicroHTML\SELECT;
use function MicroHTML\SPAN; use function MicroHTML\SPAN;
@ -87,7 +87,7 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement
{ {
return DIV( return DIV(
["class" => "command_example"], ["class" => "command_example"],
PRE($ex), CODE($ex),
P($desc) P($desc)
); );
} }

View file

@ -708,7 +708,7 @@ function _fatal_error(\Exception $e): void
<p><b>Message:</b> '.html_escape($message).' <p><b>Message:</b> '.html_escape($message).'
'.$q.' '.$q.'
<p><b>Version:</b> '.$version.' (on '.$phpver.') <p><b>Version:</b> '.$version.' (on '.$phpver.')
<p><b>Stack Trace:</b></p><pre>'.$e->getTraceAsString().'</pre> <p><b>Stack Trace:</b></p><pre><code>'.$e->getTraceAsString().'</code></pre>
</body> </body>
</html> </html>
'; ';

View file

@ -51,7 +51,7 @@ class BBCodeInfo extends ExtensionInfo
<li>[ul]Unordered list[/ul] <li>[ul]Unordered list[/ul]
<li>[ol]Ordered list[/ol] <li>[ol]Ordered list[/ol]
<li>[li]List Item[/li] <li>[li]List Item[/li]
<li>[code]<pre>print(\"Hello World!\");</pre>[/code] <li>[code]<pre><code>print(\"Hello World!\");</code></pre>[/code]
<li>[spoiler]<span style=\"background-color:#000; color:#000;\">Voldemort is bad</span>[/spoiler] <li>[spoiler]<span style=\"background-color:#000; color:#000;\">Voldemort is bad</span>[/spoiler]
<li>[quote]<blockquote><small>To be or not to be...</small></blockquote>[/quote] <li>[quote]<blockquote><small>To be or not to be...</small></blockquote>[/quote]
<li>[quote=Shakespeare]<blockquote><em>Shakespeare said:</em><br><small>... That is the question</small></blockquote>[/quote] <li>[quote=Shakespeare]<blockquote><em>Shakespeare said:</em><br><small>... That is the question</small></blockquote>[/quote]

View file

@ -164,7 +164,7 @@ class BBCode extends FormatterExtension
$middle = base64_decode(substr($text, $start + $l1, ($end - $start - $l1))); $middle = base64_decode(substr($text, $start + $l1, ($end - $start - $l1)));
$ending = substr($text, $end + $l2, (strlen($text) - $end + $l2)); $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2));
$text = $beginning . "<pre class='code'>" . $middle . "</pre>" . $ending; $text = $beginning . "<pre><code>" . $middle . "</code></pre>" . $ending;
} }
return $text; return $text;
} }

View file

@ -1,7 +1,3 @@
.bbcode PRE.code {
background: #DEDEDE;
font-size: 0.9rem;
}
.bbcode BLOCKQUOTE { .bbcode BLOCKQUOTE {
border: 1px solid black; border: 1px solid black;
padding: 8px; padding: 8px;

View file

@ -37,7 +37,7 @@ class BBCodeTest extends ShimmiePHPUnitTestCase
public function testCode(): void public function testCode(): void
{ {
$this->assertEquals( $this->assertEquals(
"<pre class='code'>[b]bold[/b]</pre>", "<pre><code>[b]bold[/b]</code></pre>",
$this->filter("[code][b]bold[/b][/code]") $this->filter("[code][b]bold[/b][/code]")
); );
} }

View file

@ -16,13 +16,11 @@ class BulkAddCSVInfo extends ExtensionInfo
public string $description = "Bulk add server-side posts with metadata from CSV file"; public string $description = "Bulk add server-side posts with metadata from CSV file";
public ?string $documentation = public ?string $documentation =
"Adds posts from a CSV with the five following values: "Adds posts from a CSV with the five following values:
<pre>\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\"</pre> <pre><code>\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\"</code></pre>
<b>e.g.</b> <pre><code>\"/tmp/cat.png\",\"shish oekaki\",\"http://shimmie.shishnet.org\",\"s\",\"tmp/custom.jpg\"</code></pre>
<b>e.g.</b>
<pre>\"/tmp/cat.png\",\"shish oekaki\",\"http://shimmie.shishnet.org\",\"s\",\"tmp/custom.jpg\"</pre>
Any value but the first may be omitted, but there must be five values per line. Any value but the first may be omitted, but there must be five values per line.
<b>e.g.</b> <pre>\"/why/not/try/bulk_add.jpg\",\"\",\"\",\"\",\"\"</pre> <b>e.g.</b> <pre><code>\"/why/not/try/bulk_add.jpg\",\"\",\"\",\"\",\"\"</code></pre>
Useful for importing tagged posts without having to do database manipulation. Useful for importing tagged posts without having to do database manipulation.

View file

@ -306,20 +306,20 @@ class CommentListTheme extends Themelet
{ {
return '<p>Search for posts containing a certain number of comments, or comments by a particular individual.</p> return '<p>Search for posts containing a certain number of comments, or comments by a particular individual.</p>
<div class="command_example"> <div class="command_example">
<pre>comments=1</pre> <code>comments=1</code>
<p>Returns posts with exactly 1 comment.</p> <p>Returns posts with exactly 1 comment.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>comments>0</pre> <code>comments>0</code>
<p>Returns posts with 1 or more comments. </p> <p>Returns posts with 1 or more comments. </p>
</div> </div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<div class="command_example"> <div class="command_example">
<pre>commented_by:username</pre> <code>commented_by:username</code>
<p>Returns posts that have been commented on by "username". </p> <p>Returns posts that have been commented on by "username". </p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>commented_by_userno:123</pre> <code>commented_by_userno:123</code>
<p>Returns posts that have been commented on by user 123. </p> <p>Returns posts that have been commented on by user 123. </p>
</div> </div>
'; ';

View file

@ -102,7 +102,7 @@ class CronUploaderTheme extends Themelet
<li style='text-align: left;'>You can inherit categories by creating a folder that ends with \";\". For instance category;\\tag1 would result in the tag category:tag1. This allows creating a category folder, then creating many subfolders that will use that category.</li> <li style='text-align: left;'>You can inherit categories by creating a folder that ends with \";\". For instance category;\\tag1 would result in the tag category:tag1. This allows creating a category folder, then creating many subfolders that will use that category.</li>
</ol> </ol>
The cron uploader works by importing files from the queue folder whenever this url is visited: The cron uploader works by importing files from the queue folder whenever this url is visited:
<br/><pre><a href='$cron_url'>$cron_url</a></pre> <br/><code><a href='$cron_url'>$cron_url</a></code>
<ul> <ul>
<li>If an import is already running, another cannot start until it is done.</li> <li>If an import is already running, another cannot start until it is done.</li>

View file

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shimmie2; namespace Shimmie2;
use function MicroHTML\{PRE}; use function MicroHTML\{CODE};
class ETServer extends Extension class ETServer extends Extension
{ {
@ -28,7 +28,7 @@ class ETServer extends Extension
foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) { foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) {
$page->add_block(new Block( $page->add_block(new Block(
$row["responded"], $row["responded"],
PRE(["style" => "text-align: left; overflow: scroll;"], $row["data"]), CODE(["style" => "text-align: left; overflow: scroll;"], $row["data"]),
"main", "main",
$n++ $n++
)); ));

View file

@ -34,20 +34,20 @@ class FavoritesTheme extends Themelet
{ {
return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p> return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p>
<div class="command_example"> <div class="command_example">
<pre>favorites=1</pre> <code>favorites=1</code>
<p>Returns posts that have been favorited once.</p> <p>Returns posts that have been favorited once.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>favorites>0</pre> <code>favorites>0</code>
<p>Returns posts that have been favorited 1 or more times</p> <p>Returns posts that have been favorited 1 or more times</p>
</div> </div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<div class="command_example"> <div class="command_example">
<pre>favorited_by:username</pre> <code>favorited_by:username</code>
<p>Returns posts that have been favorited by "username". </p> <p>Returns posts that have been favorited by "username". </p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>favorited_by_userno:123</pre> <code>favorited_by_userno:123</code>
<p>Returns posts that have been favorited by user 123. </p> <p>Returns posts that have been favorited by user 123. </p>
</div> </div>
'; ';

View file

@ -3,9 +3,10 @@
padding-left: 16pt; padding-left: 16pt;
} }
.command_example pre { .command_example code {
padding:4pt; padding:4pt;
border: dashed 2px black; border: dashed 2px black;
background: inherit;
} }
.command_example p { .command_example p {
@ -13,7 +14,7 @@
} }
@media (min-width: 750px) { @media (min-width: 750px) {
.command_example pre { .command_example code {
display: table-cell; display: table-cell;
width: 256px; width: 256px;
} }

View file

@ -10,11 +10,11 @@ class MediaTheme extends Themelet
{ {
return '<p>Search for posts based on the type of media.</p> return '<p>Search for posts based on the type of media.</p>
<div class="command_example"> <div class="command_example">
<pre>content:audio</pre> <code>content:audio</code>
<p>Returns posts that contain audio, including videos and audio files.</p> <p>Returns posts that contain audio, including videos and audio files.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>content:video</pre> <code>content:video</code>
<p>Returns posts that contain video, including animated GIFs.</p> <p>Returns posts that contain video, including animated GIFs.</p>
</div> </div>
<p>These search terms depend on the posts being scanned for media content. Automatic scanning was implemented in mid-2019, so posts uploaded before, or posts uploaded on a system without ffmpeg, will require additional scanning before this will work.</p> <p>These search terms depend on the posts being scanned for media content. Automatic scanning was implemented in mid-2019, so posts uploaded before, or posts uploaded on a system without ffmpeg, will require additional scanning before this will work.</p>

View file

@ -21,7 +21,7 @@ class MimeSystemTheme extends Themelet
return '<p>Search for posts by extension</p> return '<p>Search for posts by extension</p>
<div class="command_example"> <div class="command_example">
<pre>ext=jpg</pre> <code>ext=jpg</code>
<p>Returns posts with the extension "jpg".</p> <p>Returns posts with the extension "jpg".</p>
</div> </div>
@ -33,7 +33,7 @@ class MimeSystemTheme extends Themelet
<p>Search for posts by MIME type</p> <p>Search for posts by MIME type</p>
<div class="command_example"> <div class="command_example">
<pre>mime=image/jpeg</pre> <code>mime=image/jpeg</code>
<p>Returns posts that have the MIME type "image/jpeg".</p> <p>Returns posts that have the MIME type "image/jpeg".</p>
</div> </div>

View file

@ -192,20 +192,20 @@ class NotesTheme extends Themelet
{ {
return '<p>Search for posts with notes.</p> return '<p>Search for posts with notes.</p>
<div class="command_example"> <div class="command_example">
<pre>note=noted</pre> <code>note=noted</code>
<p>Returns posts with a note matching "noted".</p> <p>Returns posts with a note matching "noted".</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>notes>0</pre> <code>notes>0</code>
<p>Returns posts with 1 or more notes.</p> <p>Returns posts with 1 or more notes.</p>
</div> </div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<div class="command_example"> <div class="command_example">
<pre>notes_by=username</pre> <code>notes_by=username</code>
<p>Returns posts with note(s) by "username".</p> <p>Returns posts with note(s) by "username".</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>notes_by_user_id=123</pre> <code>notes_by_user_id=123</code>
<p>Returns posts with note(s) by user 123.</p> <p>Returns posts with note(s) by user 123.</p>
</div> </div>
'; ';

View file

@ -95,38 +95,38 @@ class NumericScoreTheme extends Themelet
{ {
return '<p>Search for posts that have received numeric scores by the score or by the scorer.</p> return '<p>Search for posts that have received numeric scores by the score or by the scorer.</p>
<div class="command_example"> <div class="command_example">
<pre>score=1</pre> <code>score=1</code>
<p>Returns posts with a score of 1.</p> <p>Returns posts with a score of 1.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>score>0</pre> <code>score>0</code>
<p>Returns posts with a score of 1 or more.</p> <p>Returns posts with a score of 1 or more.</p>
</div> </div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<div class="command_example"> <div class="command_example">
<pre>upvoted_by=username</pre> <code>upvoted_by=username</code>
<p>Returns posts upvoted by "username".</p> <p>Returns posts upvoted by "username".</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>upvoted_by_id=123</pre> <code>upvoted_by_id=123</code>
<p>Returns posts upvoted by user 123.</p> <p>Returns posts upvoted by user 123.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>downvoted_by=username</pre> <code>downvoted_by=username</code>
<p>Returns posts downvoted by "username".</p> <p>Returns posts downvoted by "username".</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>downvoted_by_id=123</pre> <code>downvoted_by_id=123</code>
<p>Returns posts downvoted by user 123.</p> <p>Returns posts downvoted by user 123.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>order:score_desc</pre> <code>order:score_desc</code>
<p>Sorts the search results by score, descending.</p> <p>Sorts the search results by score, descending.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>order:score_asc</pre> <code>order:score_asc</code>
<p>Sorts the search results by score, ascending.</p> <p>Sorts the search results by score, ascending.</p>
</div> </div>
'; ';

View file

@ -12,11 +12,11 @@ class PrivateImageTheme extends Themelet
{ {
return '<p>Search for posts that are private/public.</p> return '<p>Search for posts that are private/public.</p>
<div class="command_example"> <div class="command_example">
<pre>private:yes</pre> <code>private:yes</code>
<p>Returns posts that are private, restricted to yourself if you are not an admin.</p> <p>Returns posts that are private, restricted to yourself if you are not an admin.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>private:no</pre> <code>private:no</code>
<p>Returns posts that are public.</p> <p>Returns posts that are public.</p>
</div> </div>
'; ';

View file

@ -75,23 +75,23 @@ class RelationshipsTheme extends Themelet
{ {
return '<p>Search for posts that have parent/child relationships.</p> return '<p>Search for posts that have parent/child relationships.</p>
<div class="command_example"> <div class="command_example">
<pre>parent=any</pre> <code>parent=any</code>
<p>Returns posts that have a parent.</p> <p>Returns posts that have a parent.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>parent=none</pre> <code>parent=none</code>
<p>Returns posts that have no parent.</p> <p>Returns posts that have no parent.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>parent=123</pre> <code>parent=123</code>
<p>Returns posts that have image 123 set as parent.</p> <p>Returns posts that have image 123 set as parent.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>child=any</pre> <code>child=any</code>
<p>Returns posts that have at least 1 child.</p> <p>Returns posts that have at least 1 child.</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>child=none</pre> <code>child=none</code>
<p>Returns posts that have no children.</p> <p>Returns posts that have no children.</p>
</div> </div>
'; ';

View file

@ -113,11 +113,11 @@ class TagCategoriesTheme extends Themelet
{ {
return '<p>Search for posts containing a certain number of tags with the specified tag category.</p> return '<p>Search for posts containing a certain number of tags with the specified tag category.</p>
<div class="command_example"> <div class="command_example">
<pre>persontags=1</pre> <code>persontags=1</code>
<p>Returns posts with exactly 1 tag with the tag category "person".</p> <p>Returns posts with exactly 1 tag with the tag category "person".</p>
</div> </div>
<div class="command_example"> <div class="command_example">
<pre>cattags>0</pre> <code>cattags>0</code>
<p>Returns posts with 1 or more tags with the tag category "cat". </p> <p>Returns posts with 1 or more tags with the tag category "cat". </p>
</div> </div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>

View file

@ -10,7 +10,7 @@ class TrashTheme extends Themelet
{ {
return '<p>Search for posts in the trash.</p> return '<p>Search for posts in the trash.</p>
<div class="command_example"> <div class="command_example">
<pre>in:trash</pre> <code>in:trash</code>
<p>Returns posts that are in the trash.</p> <p>Returns posts that are in the trash.</p>
</div> </div>
'; ';

View file

@ -100,6 +100,10 @@ font-size:0.9em;
padding-left:10px; padding-left:10px;
padding-top:8px; padding-top:8px;
} }
CODE {
background: #DEDEDE;
font-size: 0.9rem;
}
form { form {
margin:0; margin:0;
} }

View file

@ -165,6 +165,10 @@ font-size:0.8rem;
FOOTER > DIV { FOOTER > DIV {
margin: 1rem 2rem; margin: 1rem 2rem;
} }
CODE {
background: #DEDEDE;
font-size: 0.9rem;
}
form { form {
margin:0; margin:0;
} }

View file

@ -127,6 +127,11 @@ UL {
text-align: left; text-align: left;
} }
CODE {
background: #BBB;
font-size: 0.9rem;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the navigation bar, and all its blocks * * the navigation bar, and all its blocks *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View file

@ -33,6 +33,7 @@ FOOTER {
A, A:visited {text-decoration: none; color: #0000EE;} A, A:visited {text-decoration: none; color: #0000EE;}
A:hover {text-decoration: underline; color: #DD0000;} A:hover {text-decoration: underline; color: #DD0000;}
HR {border: none; border-top: 1px solid #D9BFB7; height: 0; clear: both;} HR {border: none; border-top: 1px solid #D9BFB7; height: 0; clear: both;}
CODE {background: #DEDEDE; font-size: 0.9rem;}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the navigation bar, and all its blocks * * the navigation bar, and all its blocks *