beeware.github.io/templates/news.html
Luna Meadows cbe4a851dc
Apply suggestions from code review
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2023-04-07 06:21:35 -05:00

51 lines
1.8 KiB
HTML

{% extends "page.html" %}
{% from "macros/translation.html" import transbag %}
{% set t_more_articles = transbag('translate', this.alt, 'more_articles') %}
{% set t_on = transbag('translate', this.alt, 'on') %}
{% set t_posted_by = transbag('translate', this.alt, 'posted_by') %}
{% block title %}{{ this.title }}{% endblock %}
{% block body %}
{% set blog = site.query('/news/buzz', alt=this.alt).all() %}
{% set events = site.query('/news/events', alt=this.alt).filter(F.upcoming == True) %}
{% block extra_script %}
<script>
(function() {
var today = new Date();
$('.upcoming.event').each(function() {
var event_date = new Date($(this).data('date'));
if (event_date >= today) {
$(this).show();
}
});
})();
</script>
{% endblock %}
<div class="row">
<div class="col-md-12 col-lg-8">
{% for child in blog[:10] %}
<h3><a href="{{ child|url(alt=this.alt) }}">{{ child.title }}</a></h3>
<p>{{ t_posted_by }}
{% if this.mastodon_handle %}
<a href="https://{{ this.mastodon_handle.split('@')[2] }}/@{{ this.mastodon_handle.split('@')[1] }}">{{ this.author or this.mastodon_handle }}</a>
{% elif this.twitter_handle %}
<a href="https://twitter.com/{{ this.twitter_handle }}">{{ this.author or this.twitter_handle }}</a>
{% else %}
{{ child.author }}
{% endif %}
{{ t_on }} {{ child.pub_date }}
</p>
{% endfor %}
<a href="{{ '/news/buzz/'|url(alt=this.alt) }}">{{ t_more_articles }}</a>
</div>
<div class="col-md-12 col-lg-4 gutter">
{{ this.gutter }}
<ul>
{% for child in events %}
<li class="upcoming event" data-date="{{ child.date }}">{{ child.date.strftime("%-d %B %Y") }}: <a href="{{ child|url(alt=this.alt) }}">{{ child.title }} {{ child.event_type}}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}