forked from retoor/devplacepy
feat: add content_preview helper and apply rendered content across templates
Introduce a new `content_preview()` function in `rendering.py` that strips HTML from rendered content and truncates to a given length with an ellipsis. Add a corresponding `plainText()` and `preview()` method to the `ContentRenderer` JS class. Register `content_preview` as a Jinja2 global in `templating.py`. Update multiple templates (`feed.html`, `gists.html`, `landing.html`, `messages.html`, `news.html`, `notifications.html`, `post.html`, `profile.html`) to use `render_title`, `render_content`, or `content_preview` instead of raw string slicing, ensuring consistent rendering of rich text (e.g., Markdown, HTML) in previews, descriptions, bios, and notification messages. Also fix the conversation preview in `MessagesLayout.js` to use the new JS preview method.
This commit is contained in:
@@ -93,7 +93,7 @@
|
||||
<div class="profile-info-row">
|
||||
<span class="profile-info-label">Bio</span>
|
||||
<div class="flex-center-gap">
|
||||
<span class="profile-info-value bio-display" id="display-bio">{{ profile_user.get('bio', '') or 'Not set' }}</span>
|
||||
<span class="profile-info-value bio-display rendered-title" id="display-bio">{{ render_title(profile_user.get('bio', '')) or 'Not set' }}</span>
|
||||
<button type="button" class="profile-info-edit" data-edit-field="bio" aria-label="Edit bio">✎</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -141,7 +141,7 @@
|
||||
<div class="profile-info">
|
||||
<div class="profile-info-row">
|
||||
<span class="profile-info-label">Bio</span>
|
||||
<span class="profile-info-value">{{ profile_user.get('bio', '') or 'Not set' }}</span>
|
||||
<span class="profile-info-value rendered-title">{{ render_title(profile_user.get('bio', '')) or 'Not set' }}</span>
|
||||
</div>
|
||||
<div class="profile-info-row">
|
||||
<span class="profile-info-label">Location</span>
|
||||
@@ -525,7 +525,7 @@
|
||||
<span class="gist-language-badge">📝 {{ language_name(g['language']) }}</span>
|
||||
</div>
|
||||
{% if g.get('description') %}
|
||||
<div class="gist-card-desc">{{ g['description'][:200] }}{% if g['description']|length > 200 %}...{% endif %}</div>
|
||||
<div class="gist-card-desc rendered-content">{{ render_content(g['description'][:200]) }}</div>
|
||||
{% endif %}
|
||||
<div class="gist-card-footer">
|
||||
<span>{{ dt_ago(entry.gist.created_at) if entry.gist.created_at else entry.time_ago }}</span>
|
||||
@@ -549,7 +549,7 @@
|
||||
<img src="{{ avatar_url('multiavatar', person['username'], 40) }}" class="avatar-img avatar-md" alt="{{ person['username'] }}" loading="lazy">
|
||||
<div class="follow-user-info">
|
||||
<span class="follow-user-name">{{ person['username'] }}</span>
|
||||
{% if person['bio'] %}<span class="follow-user-bio">{{ person['bio'] }}</span>{% endif %}
|
||||
{% if person['bio'] %}<span class="follow-user-bio rendered-title">{{ render_title(person['bio']) }}</span>{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% if user and not person['is_self'] %}
|
||||
@@ -644,7 +644,7 @@
|
||||
</span>
|
||||
<span class="activity-time">{{ dt_ago(act['created_at']) if act['created_at'] else act['time_ago'] }}</span>
|
||||
</div>
|
||||
<p class="activity-content">{{ act['content'] }}</p>
|
||||
<div class="activity-content rendered-content">{{ render_content(act['content']) }}</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">No activity yet.</div>
|
||||
|
||||
Reference in New Issue
Block a user