post.html attribution palette: usernames render w. @-prefix (bare emails left as-is); .post-attribution spans wrap username+title combos for the --quaUser colour key — line author col, self/shared header lines, Note.grant_if_new prose

- 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 <span class="post-attribution">. 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 <span class="post-attribution">. 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 <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-05-08 23:42:51 -04:00
parent eb0369f0b7
commit e0ace01670
4 changed files with 40 additions and 9 deletions

View File

@@ -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'<a class="note-ref" href="/billboard/my-notes/">'
f'{note.display_name}</a>'
)
attr_handle = f'<span class="post-attribution">{handle}</span>'
attr_title = f'<span class="post-attribution">{note.display_title}</span>'
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'<span class="post-attribution">{handle} '
f'the {note.display_title}</span>'
)
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

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -16,10 +16,10 @@
<h3 class="post-title">{{ post.title }}</h3>
{% with recipients=post.shared_with.all %}
{% if recipients %}
<p class="post-shared-recipients">shared between {% for r in recipients %}<span class="post-recipient">{{ r|display_name }}</span>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
<p class="post-shared-self">&amp; me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}</p>
<p class="post-shared-recipients">shared between {% for r in recipients %}<span class="post-recipient post-attribution">{{ r|at_handle }}</span>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
<p class="post-shared-self">&amp; me, <span class="post-attribution">{{ post.owner|at_handle }} the {{ post.owner.active_title_display }}</span></p>
{% else %}
<p class="post-shared-self">just me, {{ post.owner|display_name }} the {{ post.owner.active_title_display }}</p>
<p class="post-shared-self">just me, <span class="post-attribution">{{ post.owner|at_handle }} the {{ post.owner.active_title_display }}</span></p>
{% endif %}
{% endwith %}
</header>
@@ -27,7 +27,7 @@
<ul id="id_post_table" class="post-lines">
{% for line in post.lines.all %}
<li class="post-line {% if line.author.username == 'adman' %}post-line--system{% endif %}">
<span class="post-line-author">{{ line.author|display_name }}</span>
<span class="post-line-author">{{ line.author|at_handle }}</span>
<span class="post-line-text">{# adman-authored Lines (note unlock + share invite system prose) carry an `<a class="note-ref">` anchor that needs to render as HTML. User-typed Lines stay escaped. #}{% if line.author.username == 'adman' %}{{ line.text|safe }}{% else %}{{ line.text }}{% endif %}</span>
<time class="post-line-time" datetime="{{ line.created_at|date:'c' }}">{{ line.created_at|date:'g:i A' }}</time>
</li>