diff --git a/app/main.py b/app/main.py
index cbdd7a3..d710690 100644
--- a/app/main.py
+++ b/app/main.py
@@ -76,7 +76,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
#
# Next:
# - fix stream (only content from follows + mention, and dedup shares)
-# - custom emoji in data/
# - allow to undo follow requests
# - indieauth tweaks
# - API for posting notes
@@ -171,6 +170,11 @@ class CustomMiddleware:
app = FastAPI(docs_url=None, redoc_url=None)
+app.mount(
+ "/static/custom_emoji",
+ StaticFiles(directory="data/custom_emoji"),
+ name="static_custom_emoji",
+)
app.mount("/static", StaticFiles(directory="app/static"), name="static")
app.include_router(admin.router, prefix="/admin")
app.include_router(admin.unauthenticated_router, prefix="/admin")
diff --git a/app/templates/utils.html b/app/templates/utils.html
index 5c4602d..aa49de4 100644
--- a/app/templates/utils.html
+++ b/app/templates/utils.html
@@ -157,7 +157,7 @@
-
+
{{ actor.display_name | clean_html(actor) | safe }}
diff --git a/app/utils/emoji.py b/app/utils/emoji.py
index 6484788..1d428e0 100644
--- a/app/utils/emoji.py
+++ b/app/utils/emoji.py
@@ -15,23 +15,27 @@ EMOJIS_BY_NAME: dict[str, "RawObject"] = {}
def _load_emojis(root_dir: Path, base_url: str) -> None:
if EMOJIS:
return
- for emoji in (root_dir / "app" / "static" / "emoji").iterdir():
- mt = mimetypes.guess_type(emoji.name)[0]
- if mt and mt.startswith("image/"):
- name = emoji.name.split(".")[0]
- ap_emoji: "RawObject" = {
- "type": "Emoji",
- "name": f":{name}:",
- "updated": "1970-01-01T00:00:00Z", # XXX: we don't track date
- "id": f"{base_url}/e/{name}",
- "icon": {
- "mediaType": mt,
- "type": "Image",
- "url": f"{base_url}/static/emoji/{emoji.name}",
- },
- }
- EMOJIS[emoji.name] = ap_emoji
- EMOJIS_BY_NAME[ap_emoji["name"]] = ap_emoji
+ for dir_name, path in (
+ (root_dir / "app" / "static" / "emoji", "emoji"),
+ (root_dir / "data" / "custom_emoji", "custom_emoji"),
+ ):
+ for emoji in dir_name.iterdir():
+ mt = mimetypes.guess_type(emoji.name)[0]
+ if mt and mt.startswith("image/"):
+ name = emoji.name.split(".")[0]
+ ap_emoji: "RawObject" = {
+ "type": "Emoji",
+ "name": f":{name}:",
+ "updated": "1970-01-01T00:00:00Z", # XXX: we don't track date
+ "id": f"{base_url}/e/{name}",
+ "icon": {
+ "mediaType": mt,
+ "type": "Image",
+ "url": f"{base_url}/static/{path}/{emoji.name}",
+ },
+ }
+ EMOJIS[emoji.name] = ap_emoji
+ EMOJIS_BY_NAME[ap_emoji["name"]] = ap_emoji
def tags(content: str) -> list["RawObject"]:
diff --git a/data/custom_emoji/.gitignore b/data/custom_emoji/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/data/custom_emoji/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore