From 252e4cfa9c2236e50f38adc4611396a5665f8301 Mon Sep 17 00:00:00 2001
From: Jonas Kohl
Date: Tue, 23 Jul 2024 16:34:35 +0200
Subject: Add codegen & emoticons
---
src/codegen/emoticons.php | 36 ++++++++++++++++++++++++
src/pages/guestbook.php | 52 ++++++++++++++++++++++++++++++++---
src/static/emoticons/angel.gif | Bin 0 -> 175 bytes
src/static/emoticons/angry.gif | Bin 0 -> 167 bytes
src/static/emoticons/azn.gif | Bin 0 -> 168 bytes
src/static/emoticons/bang.gif | Bin 0 -> 351 bytes
src/static/emoticons/blank.gif | Bin 0 -> 156 bytes
src/static/emoticons/cheesy.gif | Bin 0 -> 172 bytes
src/static/emoticons/cool.gif | Bin 0 -> 172 bytes
src/static/emoticons/cry.gif | Bin 0 -> 573 bytes
src/static/emoticons/embarrassed.gif | Bin 0 -> 650 bytes
src/static/emoticons/evil.gif | Bin 0 -> 238 bytes
src/static/emoticons/grin.gif | Bin 0 -> 173 bytes
src/static/emoticons/huh.gif | Bin 0 -> 167 bytes
src/static/emoticons/kiss.gif | Bin 0 -> 171 bytes
src/static/emoticons/laugh.gif | Bin 0 -> 336 bytes
src/static/emoticons/lipsrsealed.gif | Bin 0 -> 231 bytes
src/static/emoticons/police.gif | Bin 0 -> 171 bytes
src/static/emoticons/rolleyes.gif | Bin 0 -> 485 bytes
src/static/emoticons/sad.gif | Bin 0 -> 167 bytes
src/static/emoticons/sad2.gif | Bin 0 -> 436 bytes
src/static/emoticons/shocked.gif | Bin 0 -> 178 bytes
src/static/emoticons/shrug.gif | Bin 0 -> 998 bytes
src/static/emoticons/smiley.gif | Bin 0 -> 174 bytes
src/static/emoticons/tongue.gif | Bin 0 -> 233 bytes
src/static/emoticons/undecided.gif | Bin 0 -> 171 bytes
src/static/emoticons/wink.gif | Bin 0 -> 170 bytes
27 files changed, 84 insertions(+), 4 deletions(-)
create mode 100644 src/codegen/emoticons.php
create mode 100644 src/static/emoticons/angel.gif
create mode 100644 src/static/emoticons/angry.gif
create mode 100644 src/static/emoticons/azn.gif
create mode 100644 src/static/emoticons/bang.gif
create mode 100644 src/static/emoticons/blank.gif
create mode 100644 src/static/emoticons/cheesy.gif
create mode 100644 src/static/emoticons/cool.gif
create mode 100644 src/static/emoticons/cry.gif
create mode 100644 src/static/emoticons/embarrassed.gif
create mode 100644 src/static/emoticons/evil.gif
create mode 100644 src/static/emoticons/grin.gif
create mode 100644 src/static/emoticons/huh.gif
create mode 100644 src/static/emoticons/kiss.gif
create mode 100644 src/static/emoticons/laugh.gif
create mode 100644 src/static/emoticons/lipsrsealed.gif
create mode 100644 src/static/emoticons/police.gif
create mode 100644 src/static/emoticons/rolleyes.gif
create mode 100644 src/static/emoticons/sad.gif
create mode 100644 src/static/emoticons/sad2.gif
create mode 100644 src/static/emoticons/shocked.gif
create mode 100644 src/static/emoticons/shrug.gif
create mode 100644 src/static/emoticons/smiley.gif
create mode 100644 src/static/emoticons/tongue.gif
create mode 100644 src/static/emoticons/undecided.gif
create mode 100644 src/static/emoticons/wink.gif
(limited to 'src')
diff --git a/src/codegen/emoticons.php b/src/codegen/emoticons.php
new file mode 100644
index 0000000..51b9ed6
--- /dev/null
+++ b/src/codegen/emoticons.php
@@ -0,0 +1,36 @@
+ [
+ pathinfo($i, PATHINFO_FILENAME),
+ getimagesize($em_dir . "/" . $i)["3"]
+ ],
+ array_values(
+ array_filter(
+ scandir($em_dir),
+ fn($i) =>
+ $i[0] !== "." &&
+ is_file($em_dir . "/" . $i) &&
+ strtolower(pathinfo($i, PATHINFO_EXTENSION)) === "gif"
+ )
+ )
+);
+
+usort($emoticons, fn($a, $b) => strlen($b[0]) <=> strlen($a[0]));
+
+$emoticons_alpha_lookup = [];
+foreach ($emoticons as $i => $emoticon) {
+ $emoticons_alpha_lookup []= [$i, $emoticon[0]];
+}
+usort($emoticons_alpha_lookup, fn($a, $b) => $a[1] <=> $b[1]);
+$emoticons_alpha_lookup = array_column($emoticons_alpha_lookup, 0);
+
+return [
+ "emoticons.js",
+ "/* auto-generated at " . date("c") . " */\nvar EMOTICONS = " .
+ json_encode([
+ $emoticons,
+ $emoticons_alpha_lookup,
+ ], JSON_PRETTY_PRINT) . ";\n",
+];
diff --git a/src/pages/guestbook.php b/src/pages/guestbook.php
index f84b92d..2d40089 100644
--- a/src/pages/guestbook.php
+++ b/src/pages/guestbook.php
@@ -2,10 +2,11 @@