From e0ace016708ff127333eb2093da906698506abb2 Mon Sep 17 00:00:00 2001 From: Disco DeDisco Date: Fri, 8 May 2026 23:42:51 -0400 Subject: [PATCH] =?UTF-8?q?post.html=20attribution=20palette:=20usernames?= =?UTF-8?q?=20render=20w.=20@-prefix=20(bare=20emails=20left=20as-is);=20.?= =?UTF-8?q?post-attribution=20spans=20wrap=20username+title=20combos=20for?= =?UTF-8?q?=20the=20--quaUser=20colour=20key=20=E2=80=94=20line=20author?= =?UTF-8?q?=20col,=20self/shared=20header=20lines,=20Note.grant=5Fif=5Fnew?= =?UTF-8?q?=20prose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - new lyric_extras.at_handle filter: '@{username}' if user.username, else truncate_email(user.email). Companion to display_name (which has no @-prefix). Used by post.html line author col + self/shared self lines. - post.html updates: line author span renders {{ line.author|at_handle }}; .post-shared-recipients chips render {{ r|at_handle }} + .post-attribution; .post-shared-self wraps "{handle} the {title}" in . The 'just me' / '& me' prose stays plain (only the handle+title combo is coloured). - Note.grant_if_new prose wraps both the @-handle (or bare email fallback) AND the title in . Standard format wraps the combo "{handle} the {title}" together; admin format wraps each independently since the prose splits them ("recognizes @disco for ... customary title of Schizoid Man"). Existing Lines unchanged — going-forward styling only. - SCSS: .post-attribution { color: rgba(var(--quaUser), 1); } scoped at .post-page so it lights up in both .post-header descendants and #id_post_table descendants. .post-line-author also switches from opacity-based dim to the same --quaUser key (drops opacity 0.75 since the colour change reads as the de-emphasis on its own). - 852 ITs still green — line.text inclusions ("Stargazer", "alice@test.io" etc.) still substring-match through the wrapping spans. Code architected by Disco DeDisco Git commit message Co-Authored-By: Claude Opus 4.7 (1M context) --- src/apps/drama/models.py | 18 ++++++++++++++---- src/apps/lyric/templatetags/lyric_extras.py | 13 +++++++++++++ src/static_src/scss/_billboard.scss | 10 +++++++++- src/templates/apps/billboard/post.html | 8 ++++---- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/apps/drama/models.py b/src/apps/drama/models.py index 97c4ed5..3eba88c 100644 --- a/src/apps/drama/models.py +++ b/src/apps/drama/models.py @@ -293,21 +293,31 @@ class Note(models.Model): post.title = NOTE_UNLOCK_POST_TITLE post.save(update_fields=["title"]) - username = user.username or user.email + # Bare-email fallback when user.username is None (no `@` prefix — + # the address already carries one). When username is set, use the + # `@handle` form. Both wrapped in .post-attribution so the CSS + # palette key (--quaUser) lights up the username + title combo. + handle = f"@{user.username}" if user.username else user.email note_anchor = ( f'' f'{note.display_name}' ) + attr_handle = f'{handle}' + attr_title = f'{note.display_title}' if slug in _ADMIN_NOTE_SLUGS: line_text = ( - f"The administration recognizes {username} for {note_anchor}, " - f"which comes with the customary title of {note.display_title}. " + f"The administration recognizes {attr_handle} for {note_anchor}, " + f"which comes with the customary title of {attr_title}. " "This does not entail any additional benefits." ) else: + attr_combo = ( + f'{handle} ' + f'the {note.display_title}' + ) line_text = ( f"Look!—new Note unlocked. {note_anchor} " - f"recognizes {username} the {note.display_title}." + f"recognizes {attr_combo}." ) # Lazy get-or-create: TransactionTestCase flushes the migration-seeded diff --git a/src/apps/lyric/templatetags/lyric_extras.py b/src/apps/lyric/templatetags/lyric_extras.py index fe8c5bd..88169c7 100644 --- a/src/apps/lyric/templatetags/lyric_extras.py +++ b/src/apps/lyric/templatetags/lyric_extras.py @@ -48,3 +48,16 @@ def display_name(user): if user.username: return user.username return truncate_email(user.email) + + +@register.filter +def at_handle(user): + """`@username` when the user has set one; falls back to the truncated + email otherwise (no `@` prefix on bare emails since the address itself + already carries the `@`). Used in post.html to colour usernames in the + --quaUser palette key while leaving emails as-is.""" + if user is None: + return "" + if user.username: + return f"@{user.username}" + return truncate_email(user.email) diff --git a/src/static_src/scss/_billboard.scss b/src/static_src/scss/_billboard.scss index 76a720c..a4ef689 100644 --- a/src/static_src/scss/_billboard.scss +++ b/src/static_src/scss/_billboard.scss @@ -130,6 +130,14 @@ body.page-billposts { padding: 0.75rem; gap: 0.5rem; + // Username + title attribution spans — line author column, self/shared + // header lines, server-rendered grant prose. --quaUser palette key + // unifies them across the page; placed at .post-page scope so it + // applies in BOTH .post-header and #id_post_table descendants. + .post-attribution { + color: rgba(var(--quaUser), 1); + } + .post-header { flex-shrink: 0; @@ -169,7 +177,7 @@ body.page-billposts { .post-line-author { font-weight: bold; - opacity: 0.75; + color: rgba(var(--quaUser), 1); white-space: nowrap; font-size: 0.85rem; } diff --git a/src/templates/apps/billboard/post.html b/src/templates/apps/billboard/post.html index 5a00487..c830fc0 100644 --- a/src/templates/apps/billboard/post.html +++ b/src/templates/apps/billboard/post.html @@ -16,10 +16,10 @@

{{ post.title }}

{% with recipients=post.shared_with.all %} {% if recipients %} -

shared between {% for r in recipients %}{{ r|display_name }}{% if not forloop.last %}, {% endif %}{% endfor %}

-

& me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}

+

shared between {% for r in recipients %}{{ r|at_handle }}{% if not forloop.last %}, {% endif %}{% endfor %}

+

& me, {{ post.owner|at_handle }} the {{ post.owner.active_title_display }}

{% else %} -

just me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}

+

just me, {{ post.owner|at_handle }} the {{ post.owner.active_title_display }}

{% endif %} {% endwith %} @@ -27,7 +27,7 @@