changes to jinja2 templates; issue a warning if .env is not loaded

This commit is contained in:
Yusur 2025-06-14 13:20:16 +02:00
parent c56594345a
commit 8e12714026
4 changed files with 16 additions and 5 deletions

View file

@ -18,7 +18,8 @@ __version__ = '0.3.3'
APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__))
dotenv.load_dotenv()
if not dotenv.load_dotenv():
warnings.warn('.env not loaded; application may break!', UserWarning)
app = Flask(__name__)
app.secret_key = os.getenv('SECRET_KEY')

View file

@ -1,6 +1,7 @@
{% extends "base.html" %}
{% from "macros/feed.html" import feed_post, stop_scrolling, no_more_scrolling with context %}
{% from "macros/title.html" import title_tag with context %}
{% from "macros/nav.html" import nav_guild, nav_top_communities with context %}
{# set feed_title = 'For you' if feed_type == 'foryou' and not feed_title %}
{% set feed_title = 'Explore' if feed_type == 'explore' and not feed_title #}
@ -16,12 +17,10 @@
{% block nav %}
{% if top_communities %}
{% from "macros/nav.html" import nav_top_communities with context %}
{{ nav_top_communities(top_communities) }}
{% endif %}
{% if feed_type == 'guild' %}
{% from "macros/nav.html" import nav_guild with context %}
{{ nav_guild(topic) }}
{% endif %}

View file

@ -3,13 +3,15 @@
{% from "macros/feed.html" import single_comment, feed_upvote, comment_count with context %}
{% from "macros/create.html" import comment_area with context %}
{% from "macros/icon.html" import icon, callout with context %}
{% from "macros/nav.html" import nav_guild, nav_user with context %}
{% block title %}{{ title_tag(p.title + '; from ' + p.topic_or_user().handle()) }}{% endblock %}
{% block nav %}
{% if p.topic %}
{% from "macros/nav.html" import nav_guild with context %}
{{ nav_guild(p.topic) }}
{% elif p.author %}
{{ nav_user(p.author) }}
{% endif %}
{% endblock %}
@ -26,6 +28,9 @@
on their user page
{% endif %}
- <time datetime="{{ p.created_at.isoformat('T') }}">{{ p.created_at.strftime('%B %-d, %Y at %H:%M') }}</time>
{% if p.privacy == 1 %}
- {{ icon('link_post') }} Unlisted
{% endif %}
</div>
{% if current_user.is_administrator and p.report_count() %}
{% call callout() %}

View file

@ -2,13 +2,19 @@
{% from "macros/feed.html" import feed_post, stop_scrolling, no_more_scrolling with context %}
{% from "macros/title.html" import title_tag with context %}
{% from "macros/icon.html" import icon, callout with context %}
{% from "macros/nav.html" import nav_user with context %}
{% block title %}{{ title_tag(user.handle() + 's content') }}{% endblock %}
{% block heading %}
<h2>{{ user.handle() }}</h2>
<p>{{ icon('karma') }} <strong>{{ user.karma }}</strong> karma - Joined at: <time datetime="{{ user.joined_at.isoformat('T') }}">{{ user.joined_at.strftime('%B %-d, %Y %H:%M') }}</time> - ID: {{ user.id|to_b32l }}</p>
{% endblock %}
{% block nav %}
{{ user_nav(user) }}
{% endblock %}
{% block content %}
{% if l and l.pages > 0 %}
{% if not user.is_active %}