add some forumoji

This commit is contained in:
Lera Elvoé 2025-05-30 05:24:14 +03:00
parent bda68ed7f4
commit dacc5a8d7b
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
17 changed files with 76 additions and 0 deletions

View File

@ -31,3 +31,10 @@ Copyright: Gabriele Malaspina
Designers: Gabriele Malaspina
License: CC0 1.0/CC BY 4.0
CC BY 4.0 compliance: Modified to indicate the URL. Modified size.
## Forumoji
Affected files: everything in [`data/static/emoji`](./data/static/emoji)
URL: https://gh.vercte.net/forumoji/
License: CC0 1.0
Designers: lolecksdeehaha; Scratch137; 64lu (the project has many more contributors, but these are the people whose designs were reproduced here)

BIN
data/static/emoji/angry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

BIN
data/static/emoji/frown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

BIN
data/static/emoji/grin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

BIN
data/static/emoji/imp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

BIN
data/static/emoji/smile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

BIN
data/static/emoji/sob.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
data/static/emoji/think.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

BIN
data/static/emoji/wink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

36
lib/babycode-emoji.lua Normal file
View File

@ -0,0 +1,36 @@
local emoji_template = " <img class=emoji src=\"/emoji/$.png\" alt=\"$\" title=\"$\"> "
return {
["angry"] = emoji_template:gsub("%$", "angry"),
["("] = emoji_template:gsub("%$", "frown"),
["D"] = emoji_template:gsub("%$", "grin"),
["imp"] = emoji_template:gsub("%$", "imp"),
["angryimp"] = emoji_template:gsub("%$", "impangry"),
["impangry"] = emoji_template:gsub("%$", "impangry"),
["|"] = emoji_template:gsub("%$", "neutral"),
[")"] = emoji_template:gsub("%$", "smile"),
[","] = emoji_template:gsub("%$", "sob"),
["T"] = emoji_template:gsub("%$", "sob"),
["cry"] = emoji_template:gsub("%$", "sob"),
["sob"] = emoji_template:gsub("%$", "sob"),
["o"] = emoji_template:gsub("%$", "surprised"),
["O"] = emoji_template:gsub("%$", "surprised"),
["hmm"] = emoji_template:gsub("%$", "think"),
["think"] = emoji_template:gsub("%$", "think"),
["thinking"] = emoji_template:gsub("%$", "think"),
["P"] = emoji_template:gsub("%$", "tongue"),
["p"] = emoji_template:gsub("%$", "tongue"),
[";"] = emoji_template:gsub("%$", "wink"),
["wink"] = emoji_template:gsub("%$", "wink"),
}

View File

@ -1,6 +1,7 @@
local babycode = {}
local string_trim = require("lapis.util").trim
local emoji = require("lib.babycode-emoji")
local function s_split(s, delimiter, max_matches, trim, allow_empty)
local result = {}
@ -121,6 +122,14 @@ function babycode.to_html(s, escape_html)
-- these can be nested, so replace open and closed separately
text = text:gsub("%[(/?)quote%]", "<%1blockquote>")
text = text:gsub(":(.-):", function(code)
if emoji[code] then
return emoji[code]
else
return code
end
end)
-- replace loose links
text = text:gsub("(https?://[%w-_%.%?%.:/%+=&~%@#%%]+[%w-/])", function(url)

View File

@ -38,6 +38,11 @@ http {
alias data/static/avatars;
expires 1y;
}
location /emoji {
alias data/static/emoji;
expires 1y;
}
location /static/js/ {
alias js/;

View File

@ -1,6 +1,25 @@
<details>
<summary>babycode guide</summary>
<ul>
<li>
<details>
<summary>Forumoji (emoticons)</summary>
<ul>
<li><img class="emoji" src="/emoji/smile.png" alt="smile" title="smile"> - <code class=inline-code>:): </code></li>
<li><img class="emoji" src="/emoji/frown.png" alt="frown" title="frown"> - <code class=inline-code>:(: </code></li>
<li><img class="emoji" src="/emoji/grin.png" alt="grin" title="grin"> - <code class=inline-code>:D: </code></li>
<li><img class="emoji" src="/emoji/neutral.png" alt="neutral" title="neutral"> - <code class=inline-code>:|: </code></li>
<li><img class="emoji" src="/emoji/angry.png" alt="angry" title="angry"> - <code class=inline-code>:angry: </code></li>
<li><img class="emoji" src="/emoji/sob.png" alt="sob" title="sob"> - <code class=inline-code>:,: :cry: :sob: :T: </code></li>
<li><img class="emoji" src="/emoji/surprised.png" alt="surprised" title="surprised"> - <code class=inline-code>:o: :O: </code></li>
<li><img class="emoji" src="/emoji/think.png" alt="think" title="think"> - <code class=inline-code>:hmm: :think: :thinking: </code></li>
<li><img class="emoji" src="/emoji/tongue.png" alt="tongue" title="tongue"> - <code class=inline-code>:p: :P: </code></li>
<li><img class="emoji" src="/emoji/wink.png" alt="wink" title="wink"> - <code class=inline-code>:;: :wink: </code></li>
<li><img class="emoji" src="/emoji/imp.png" alt="imp" title="imp"> - <code class=inline-code>:imp: </code></li>
<li><img class="emoji" src="/emoji/impangry.png" alt="impangry" title="impangry"> - <code class=inline-code>:angryimp: :impangry: </code></li>
</ul>
</details>
</li>
<li>Loose links will be converted to clickable links automatically</li>
<li>[b]<b>bold</b>[/b]</li>
<li>[i]<i>italic</i>[/i]</li>