diff --git a/admin/all.php b/admin/all.php index e0ed36e..aef34e6 100644 --- a/admin/all.php +++ b/admin/all.php @@ -35,6 +35,12 @@ if ($_GET["migrated"] == 1) { echo("
migrations have been run!
"); } +if ($_GET["emoji"] == 1) { + echo("
emojis have been updated!
"); +} else if ($_GET["emoji"]) { + echo("
emoji returned non-200 status code {$_GET['emoji']}
"); +} + $totalUnresponded = 0; $totalPriv = 0; $totalPrivRead = 0; @@ -74,6 +80,24 @@ echo(" {$privateRead} "); -include '../boilerplate/pageEnd.php'; +echo(" +
+
migrate db
+"); + +if ($emojiEnabled) { + $query = " + SELECT count(*) FROM emoji; + "; + + $queryResponse = pg_query($db, $query); + $count = pg_fetch_array($queryResponse)["count"]; + + echo(" +
refresh emojis (currently {$count})
+ "); +} + +include "../boilerplate/pageEnd.php"; ?> diff --git a/admin/emoji.php b/admin/emoji.php new file mode 100644 index 0000000..10a3db4 --- /dev/null +++ b/admin/emoji.php @@ -0,0 +1,49 @@ + diff --git a/admin/index.php b/admin/index.php index 9b8d82a..85ebfb6 100644 --- a/admin/index.php +++ b/admin/index.php @@ -8,6 +8,7 @@ if ($_GET["pw"] === $adminPassword) { case "respond": include "respond.php"; break; case "mark": include "mark.php"; break; case "migrate": include "migrate.php"; break; + case "emoji": include "emoji.php"; break; default: include "all.php"; } } else { diff --git a/admin/migrate.php b/admin/migrate.php index 8904c3d..cc6c8e7 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -12,7 +12,8 @@ $migrations = array( "20240218-AddMigrationsTable-40641e8d", "20240218-AddMarkReadOption-a7e43358", "20240218-AddFalsesToPrivRead-67d82b18", - "20250310-AddFediIDColumn-64520350" + "20250310-AddFediIDColumn-64520350", + "20250314-AddEmoji" ); foreach ($migrations as $mig) { diff --git a/admin/respond.php b/admin/respond.php index d224621..ea9a49e 100644 --- a/admin/respond.php +++ b/admin/respond.php @@ -43,13 +43,13 @@ include "../boilerplate/question.php"; if ($question["ispublic"] === "f") { echo("

{$pageTitle} — no such question exists

- (go back?) + (go back?) "); http_response_code(404); } else { echo("

{$pageTitle} — question number {$question['id']}

- (go back?) + (go back?) "); echo(getQuestion($question, 0, 0, 1, $adminPassword)); diff --git a/boilerplate/question.php b/boilerplate/question.php index 98aba49..9f94012 100644 --- a/boilerplate/question.php +++ b/boilerplate/question.php @@ -1,5 +1,53 @@ "; + $allowNext = false; + continue; + } + } + + if ($c !== 1) { + $out .= ":"; + } + } + + $out .= $segment; + } + + return $out; +} + function getQuestion( $question, $includePermalink=1, @@ -7,11 +55,11 @@ function getQuestion( $isResponding=0, $adminPassword="" ) { - $q = htmlspecialchars($question["text"]); + $q = insertEmoji($question["text"]); $q .= "
{$question['time']}
"; if ($question["responsetext"]) { - $q .= "
" . htmlspecialchars($question['responsetext']); + $q .= "
" . insertEmoji($question['responsetext']); $q .= "
{$question['responsetime']}
"; } @@ -78,7 +126,7 @@ function getQuestion( $open = " open"; } - $q = "cw: " . htmlspecialchars($question["cw"]) . "{$q}"; + $q = "cw: " . insertEmoji($question["cw"]) . "{$q}"; } return "
{$q}
"; diff --git a/config.example.php b/config.example.php index 51d251a..dee21b3 100644 --- a/config.example.php +++ b/config.example.php @@ -9,7 +9,7 @@ $adminPassword = "setAPasswordHere!123"; // page title $pageTitle = "the cool qna"; -$pageDomainEnabled = True; +$pageDomainEnabled = true; $pageProto = "https"; $pagePath = "/qna"; $pageDomain = "example.com"; @@ -21,11 +21,16 @@ $pageRoot = "/"; // path to go to $customCSSurl = NULL; // post to fedi? -$fediEnabled = False; +$fediEnabled = false; $fediAPIRoute = "https://example.com/api/v1/statuses"; $fediAPIToken = "Bearer AUTHTOKENGOESHERE"; $fediVisibility = "private"; // "direct", "private", "unlisted", "public" +// fedi emojis? +$emojiEnabled = false; +$emojiAPIRoute = "https://example.com/api/iceshrimp/emoji"; +$emojiAPIToken = $fediAPIToken; + // database setup $dbHost = "localhost"; $dbName = "postgres"; diff --git a/css/base.css b/css/base.css index 307bd94..135935e 100644 --- a/css/base.css +++ b/css/base.css @@ -6,6 +6,7 @@ --link-color: #ff0000; --confirmation-color: #00ff00; + --warning-color: #ffff00; --question-background: #2c2c2c; --response-background: #505050; @@ -33,13 +34,31 @@ hr { background-color: var(--hr-color); } -.permalink { +a, +a:link, +a:visited { color: var(--link-color); +} + +img.emoji { + height: 1.2em; + min-width: 1.2em; + max-width: 3em; + object-fit: contain; +} + +.permalink { font-size: .9em; } -.go-back { - color: var(--link-color); +.warning { + color: var(--warning-color); + margin-bottom: .3em; +} + +.sentconf { + color: var(--confirmation-color); + margin-bottom: .3em; } .title { @@ -70,11 +89,6 @@ hr { margin-bottom: .2em; } -.sentconf { - color: var(--confirmation-color); - margin-bottom: .3em; -} - .sendsum { font-size: 1.17em; font-weight: bold; diff --git a/fetch.php b/fetch.php index dd7a731..576607e 100644 --- a/fetch.php +++ b/fetch.php @@ -23,14 +23,14 @@ include "boilerplate/pageStart.php"; if (pg_num_rows($queryResponse) === 0 || $question["ispublic"] === "f" || $question["isrespondedto"] === "f") { echo("

{$pageTitle} — no such question exists

- (go back?) + (go back?) "); http_response_code(404); } else { echo("

{$pageTitle} — question number {$question['id']}

- (go back?) + (go back?) "); echo(getQuestion($question)); diff --git a/index.php b/index.php index 1c85b34..c11021f 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ include "boilerplate/pageStart.php"; echo("

" . $pageTitle . "

"); if ($pageDomainEnabled) { - echo("(go back to " . $pageDomain . "?)"); + echo("(go back to " . $pageDomain . "?)"); } if ($_GET["sent"] == 1) { diff --git a/migrations/20250314-AddEmoji.php b/migrations/20250314-AddEmoji.php new file mode 100644 index 0000000..9af37cf --- /dev/null +++ b/migrations/20250314-AddEmoji.php @@ -0,0 +1,20 @@ + "20250314-AddEmoji" +); + +pg_insert($db, "migrations", $dataArray); + +?> diff --git a/send.php b/send.php index 67327ea..b1adc0f 100644 --- a/send.php +++ b/send.php @@ -12,7 +12,7 @@ $dataArray = array( "iscwed" => !($_GET["cw"] === null || $_GET["cw"] === ""), "time" => date("Y-m-d H:i:sP"), "ispublic" => $_GET["public"] == 1, - "isrespondedto" => False + "isrespondedto" => false ); pg_insert($db, "data", $dataArray); diff --git a/setup.php b/setup.php index f8ed149..46d675c 100644 --- a/setup.php +++ b/setup.php @@ -27,6 +27,15 @@ CREATE TABLE migrations ( pg_query($db, $query); +$query = " +CREATE TABLE emoji ( + name TEXT NOT NULL PRIMARY KEY, + url TEXT NOT NULL +); +"; + +pg_query($db, $query); + include "admin/migrate.php"; echo "database set up";