forked from retoor/devplacepy
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.
75 lines
3.2 KiB
HTML
75 lines
3.2 KiB
HTML
{% extends "base.html" %}
|
|
{% block extra_head %}
|
|
<link rel="stylesheet" href="{{ static_url('/static/css/feed.css') }}">
|
|
<link rel="stylesheet" href="{{ static_url('/static/css/post.css') }}">
|
|
<link rel="stylesheet" href="{{ static_url('/static/css/news.css') }}">
|
|
{% endblock %}
|
|
{% block content %}
|
|
<div class="news-page">
|
|
<div class="news-header">
|
|
<h1>Developer News</h1>
|
|
<p class="news-subtitle">Curated signals for developers. Updated hourly.</p>
|
|
</div>
|
|
|
|
{% if articles %}
|
|
<div class="news-grid">
|
|
{% for item in articles %}
|
|
<article class="news-card card-link-host">
|
|
{% set _href = "/news/" ~ (item.article['slug'] or item.article['uid']) %}
|
|
{% set _label = item.article['title'] %}
|
|
{% include "_card_link.html" %}
|
|
{% if item.image_url %}
|
|
<div class="news-card-image">
|
|
<img src="{{ item.image_url }}" alt="{{ item.article['title'] }}" loading="lazy" class="image-fallback">
|
|
</div>
|
|
{% endif %}
|
|
<div class="news-card-body">
|
|
<div class="news-card-meta">
|
|
<span class="news-source">{{ item.article['source_name'] }}</span>
|
|
{% if is_admin(user) %}
|
|
{% if item.article.get('featured') %}
|
|
<span class="news-featured-badge">★ Featured</span>
|
|
{% endif %}
|
|
{% if item.grade >= 9 %}
|
|
<span class="news-grade news-grade-top">Grade {{ item.grade }}</span>
|
|
{% elif item.grade >= 7 %}
|
|
<span class="news-grade news-grade-high">Grade {{ item.grade }}</span>
|
|
{% else %}
|
|
<span class="news-grade">Grade {{ item.grade }}</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
<span class="news-time">{{ dt_ago(item.synced_at) if item.synced_at else item.time_ago }}</span>
|
|
</div>
|
|
<h3 class="news-card-title">
|
|
<a href="/news/{{ item.article['slug'] or item.article['uid'] }}">{{ render_title(item.article['title']) }}</a>
|
|
</h3>
|
|
{% if item.article.get('description') %}
|
|
<div class="news-card-desc rendered-content">{{ render_content(item.article['description'][:250]) }}</div>
|
|
{% endif %}
|
|
{% if item.recent_comments %}
|
|
{% from "_comment.html" import render_comment with context %}
|
|
<div class="post-card-comments">
|
|
{% for c in item.recent_comments %}
|
|
{{ render_comment(c, 0) }}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
<a href="{{ item.article['url'] }}" target="_blank" rel="noopener" class="news-read-link">
|
|
Read on {{ item.article['source_name'] }} ↗
|
|
</a>
|
|
</div>
|
|
</article>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
{% include "_load_more.html" %}
|
|
{% else %}
|
|
<div class="news-empty">
|
|
<div class="news-empty-icon">📰</div>
|
|
<h2>No news yet</h2>
|
|
<p>Check back soon for curated developer news.</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|