summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-19 20:48:00 +0500
committerilotterytea <iltsu@alright.party>2025-04-19 20:48:00 +0500
commita7e961bcd2f1e8d98f2ffbb5ff37c2e7f9b981d1 (patch)
treee5279f13563c7f923745990f48eedd89b396ae8d /public
parent7a66de9852d4683a7b5cdcedb8e88cfdc73f4b56 (diff)
feat: show emotes
Diffstat (limited to 'public')
-rw-r--r--public/emotes/index.php69
-rw-r--r--public/static/style.css187
2 files changed, 256 insertions, 0 deletions
diff --git a/public/emotes/index.php b/public/emotes/index.php
new file mode 100644
index 0000000..a4bf585
--- /dev/null
+++ b/public/emotes/index.php
@@ -0,0 +1,69 @@
+<?php
+include "../../src/emote.php";
+
+function display_list_emotes(int $page, int $limit): array
+{
+ $db = new SQLite3("../../database.db");
+ $stmt = $db->prepare("SELECT * FROM emotes ORDER BY created_at ASC LIMIT :limit OFFSET :offset");
+ $stmt->bindValue(":offset", $page * $limit, SQLITE3_INTEGER);
+ $stmt->bindValue(":limit", $limit, SQLITE3_INTEGER);
+ $results = $stmt->execute();
+
+ $emotes = [];
+
+ while ($row = $results->fetchArray()) {
+ array_push($emotes, new Emote(
+ $row["id"],
+ $row["code"],
+ $row["ext"],
+ intval(strtotime($row["created_at"]))
+ ));
+ }
+
+ return $emotes;
+}
+
+function display_emote(int $id)
+{
+ $db = new SQLite3("../../database.db");
+ $stmt = $db->prepare("SELECT * FROM emotes WHERE id = :id");
+ $stmt->bindValue(":id", $id, SQLITE3_INTEGER);
+ $results = $stmt->execute();
+
+ if ($row = $results->fetchArray()) {
+ $emote = new Emote(
+ $row["id"],
+ $row["code"],
+ $row["ext"],
+ intval(strtotime($row["created_at"]))
+ );
+ }
+
+ if ($emote == null) {
+ echo "not found";
+ exit;
+ }
+
+ return $emote;
+}
+
+$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
+ $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
+$current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+$id = parse_url($current_url, PHP_URL_PATH);
+$id = substr($id, 8);
+$id = str_replace("/", "", $id);
+
+$emotes = null;
+$emote = null;
+
+if ($id == "" || !is_numeric($id)) {
+ $page = intval($_GET["p"] ?? "0");
+ $limit = 50;
+ $emotes = display_list_emotes($page, $limit);
+ include "../../src/emotes/multiple_page.php";
+} else {
+ $emote = display_emote(intval($id));
+ include "../../src/emotes/single_page.php";
+}
diff --git a/public/static/style.css b/public/static/style.css
new file mode 100644
index 0000000..f4d8380
--- /dev/null
+++ b/public/static/style.css
@@ -0,0 +1,187 @@
+:root {
+ --background-color: #d7dfcd;
+ --background-color-hover: #e4eed8;
+ --background-color-disabled: #bec6b3;
+ --border-color: #b0b9a5;
+}
+
+* {
+ padding: 0;
+ margin: 0;
+
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+div {
+ display: unset;
+}
+
+table.vertical th {
+ text-align: right;
+}
+
+table.vertical th,
+table.vertical td {
+ padding: 2px;
+}
+
+.container {
+ width: 100%;
+ min-height: 100vh;
+ display: flex;
+}
+
+.wrapper {
+ flex-grow: 1;
+ display: flex;
+}
+
+main.content {
+ flex-grow: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ margin: 6px;
+}
+
+/**
+-------------
+ BUTTONS
+-------------
+*/
+
+button,
+.button {
+ background: lightgray;
+ border: 1px solid gray;
+ border-radius: 4px;
+ padding: 2px 4px;
+ font-size: 14px;
+ text-decoration: none;
+ color: black;
+}
+
+button:hover,
+.button:hover {
+ background: #b9b9b9;
+ cursor: pointer;
+}
+
+button.transparent,
+.button.transparent {
+ background: unset;
+ border: unset;
+}
+
+/**
+----------
+ LIST
+----------
+*/
+
+.items {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+}
+
+.items.content {
+ flex-grow: 1;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ gap: 16px;
+}
+
+.navtab {
+ position: relative;
+ width: 50%;
+ top: 2px;
+}
+
+.full {
+ flex-grow: 1;
+}
+
+.row {
+ flex-direction: row;
+ align-items: center;
+}
+
+.right {
+ justify-content: flex-end;
+}
+
+/**
+---------
+ BOX
+---------
+*/
+
+.box {
+ background: var(--background-color);
+ border: 2px solid var(--border-color);
+ border-radius: 4px;
+ padding: 4px;
+}
+
+.box.navtab {
+ border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+ border-bottom: unset;
+ margin: 0;
+}
+
+.box:has(.navtab) {
+ background: unset;
+ border: unset;
+ border-radius: unset;
+ padding: 0;
+
+ display: flex;
+ flex-direction: column;
+}
+
+.box:has(.navtab) .content {
+ flex-grow: 1;
+ margin: 0;
+ padding: 16px;
+}
+
+.box.emote {
+ width: 90px;
+ height: 90px;
+
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ gap: 6px;
+
+ overflow: hidden;
+}
+
+.box.emote p {
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+a.box {
+ text-decoration: none;
+ color: black;
+}
+
+a.box:hover {
+ background: linear-gradient(0deg, var(--background-color-hover), var(--background-color-disabled));
+ cursor: pointer;
+}
+
+.emote-showcase {
+ flex-grow: 1;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 32px;
+ margin: 32px 0;
+} \ No newline at end of file