feat: add clickable activity cards with comment anchor links to profile tab

Add `url` field to profile activity items so post cards link to `/posts/{slug}` and comment cards link to the parent post with a `#comment-{uid}` anchor, matching notification click behavior. Include the shared `_card_link.html` overlay in the template, fix XP bar rendering for missing `xp` key, and add API + e2e tests verifying the link structure and navigation.
This commit is contained in:
2026-07-04 20:24:59 +00:00
parent c79dfd0291
commit 7002b23eeb
11 changed files with 213 additions and 13 deletions
+3
View File
@@ -26,6 +26,7 @@ from devplacepy.database import (
get_user_media,
search_users_by_username,
mark_notifications_read_by_target,
resolve_object_url,
)
from devplacepy.content import can_view_project, enrich_items
from devplacepy.utils import (
@@ -209,6 +210,7 @@ async def profile_page(
"time_ago": time_ago(p["created_at"]),
"created_at": p["created_at"],
"uid": p["uid"],
"url": resolve_object_url("post", p["uid"]),
}
)
comments_table = get_table("comments")
@@ -228,6 +230,7 @@ async def profile_page(
"created_at": c["created_at"],
"uid": target_uid,
"target_type": target_type,
"url": f"{resolve_object_url(target_type, target_uid)}#comment-{c['uid']}",
}
)
activities.sort(key=lambda a: a["created_at"], reverse=True)
+8 -3
View File
@@ -39,10 +39,10 @@
<div class="profile-level-bar">
<div class="level-label">
<span>Progress to next level</span>
<span>{{ profile_user.get('xp', 0) % 100 }}%</span>
<span>{{ (profile_user.get('xp') or 0) % 100 }}%</span>
</div>
<div class="bar">
<div class="bar-fill" style="--bar-pct: {{ profile_user.get('xp', 0) % 100 }}%;"></div>
<div class="bar-fill" style="--bar-pct: {{ (profile_user.get('xp') or 0) % 100 }}%;"></div>
</div>
</div>
@@ -637,7 +637,12 @@
{% endif %}
{% else %}
{% for act in activities %}
<div class="post-card activity-card">
<div class="post-card activity-card card-link-host">
{% if act['url'] %}
{% set _href = act['url'] %}
{% set _label = (act['type'] == 'post') and 'View post' or 'View comment on post' %}
{% include "_card_link.html" %}
{% endif %}
<div class="activity-row">
<span class="activity-icon">
{% if act['type'] == 'post' %}&#x1F4DD;{% else %}&#x1F4AC;{% endif %}