forked from retoor/devplacepy
docs: add block/mute user relations, emoji-sync CLI, and uid indexes
- Add `/block`, `/mute` endpoints with block/unblock and mute/unmute functionality in `routers/relations.py`, hiding blocked users' content everywhere except their own profile while muting only suppresses notifications - Introduce `devplace emoji-sync` CLI command to regenerate `static/js/emoji-shortcodes.js` from the emoji library, documented in `CLAUDE.md` and wired in `cli.py` - Create `get_blocked_uids()` database helper and apply it in `content.py` `load_detail()` to filter blocked users' posts from detail views - Implement `_uid_index()` and `_drop_index()` helpers in `database.py` for unique uid indexes across tables, with `user_relations` added to `SOFT_DELETE_TABLES` - Document new routes in `AGENTS.md` and `README.md`, including emoji shortcodes rendering behavior distinct from the emoji picker
This commit is contained in:
+34
-24
@@ -1,39 +1,49 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
from functools import lru_cache
|
||||
from html.parser import HTMLParser
|
||||
from pathlib import Path
|
||||
|
||||
import emoji
|
||||
import mistune
|
||||
from markupsafe import Markup
|
||||
|
||||
EMOJI_MAP = {
|
||||
"grinning": "\U0001F600", "smiley": "\U0001F603", "smile": "\U0001F604",
|
||||
"grin": "\U0001F601", "laughing": "\U0001F606", "sweat_smile": "\U0001F605",
|
||||
"joy": "\U0001F602", "blush": "\U0001F60A", "innocent": "\U0001F607",
|
||||
"wink": "\U0001F609", "heart_eyes": "\U0001F60D", "kissing_heart": "\U0001F618",
|
||||
"stuck_out_tongue": "\U0001F61B", "stuck_out_tongue_winking_eye": "\U0001F61C",
|
||||
"sunglasses": "\U0001F60E", "unamused": "\U0001F612", "sweat": "\U0001F613",
|
||||
"sob": "\U0001F62D", "scream": "\U0001F631", "sleeping": "\U0001F634",
|
||||
"relieved": "\U0001F60C", "heart": "❤️", "broken_heart": "\U0001F494",
|
||||
"two_hearts": "\U0001F495", "sparkling_heart": "\U0001F496",
|
||||
"star": "⭐", "sparkles": "✨", "zap": "⚡",
|
||||
"fire": "\U0001F525", "rocket": "\U0001F680", "100": "\U0001F4AF",
|
||||
"clap": "\U0001F44F", "ok_hand": "\U0001F44C", "wave": "\U0001F44B",
|
||||
"thumbsup": "\U0001F44D", "+1": "\U0001F44D", "thumbsdown": "\U0001F44E",
|
||||
"-1": "\U0001F44E", "pray": "\U0001F64F", "muscle": "\U0001F4AA",
|
||||
"tada": "\U0001F389", "confetti_ball": "\U0001F38A", "party": "\U0001F973",
|
||||
"beers": "\U0001F37B", "coffee": "☕", "pizza": "\U0001F355",
|
||||
"computer": "\U0001F4BB", "bug": "\U0001F41B", "gear": "⚙️",
|
||||
"warning": "⚠️", "question": "❓", "exclamation": "❗",
|
||||
"checkered_flag": "\U0001F3C1", "eyes": "\U0001F440", "brain": "\U0001F9E0",
|
||||
"robot": "\U0001F916", "skull": "\U0001F480", "point_up": "☝️",
|
||||
"point_down": "\U0001F447", "point_left": "\U0001F448", "point_right": "\U0001F449",
|
||||
"pencil2": "✏️", "memo": "\U0001F4DD", "book": "\U0001F4D6",
|
||||
"tools": "\U0001F6E0️", "hammer_and_wrench": "\U0001F6E0️",
|
||||
EMOJI_JS_PATH = Path(__file__).parent / "static" / "js" / "emoji-shortcodes.js"
|
||||
|
||||
CUSTOM_SHORTCODES = {
|
||||
"party": "\U0001F973",
|
||||
"tools": "\U0001F6E0️",
|
||||
}
|
||||
|
||||
|
||||
def build_emoji_shortcodes() -> dict[str, str]:
|
||||
shortcodes: dict[str, str] = {}
|
||||
for char, data in emoji.EMOJI_DATA.items():
|
||||
if data.get("status", 0) > emoji.STATUS["fully_qualified"]:
|
||||
continue
|
||||
names = [data["en"]] if data.get("en") else []
|
||||
names += data.get("alias", [])
|
||||
for name in names:
|
||||
shortcodes.setdefault(name.strip(":").lower(), char)
|
||||
shortcodes.update(CUSTOM_SHORTCODES)
|
||||
return shortcodes
|
||||
|
||||
|
||||
def write_emoji_module(path: Path = EMOJI_JS_PATH) -> int:
|
||||
shortcodes = build_emoji_shortcodes()
|
||||
body = json.dumps(shortcodes, ensure_ascii=False, sort_keys=True)
|
||||
path.write_text(
|
||||
f"// retoor <retoor@molodetz.nl>\n\nexport const EMOJI_SHORTCODES = {body};\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return len(shortcodes)
|
||||
|
||||
|
||||
EMOJI_MAP = build_emoji_shortcodes()
|
||||
|
||||
_SHORTCODE_RE = re.compile(r":([A-Za-z0-9_+\-]+):")
|
||||
_YOUTUBE_RE = re.compile(
|
||||
r"(?:https?://)?(?:www\.)?"
|
||||
|
||||
Reference in New Issue
Block a user