Post gallery support

This commit is contained in:
Felipe M 2019-12-14 22:46:57 +01:00
parent 52a4129939
commit 3d4c191376
Signed by: fmartingr
GPG key ID: 716BC147715E716F
3 changed files with 26 additions and 2 deletions

7
models/gallery.ini Normal file
View file

@ -0,0 +1,7 @@
[model]
name = Gallery
label = gallery
hidden = no
[pagination]
enabled = no

View file

@ -1,5 +1,5 @@
{% extends "blog/_base.html" %} {% extends "blog/_base.html" %}
{% from "macros/blog.html" import render_blog_post %} {% from "macros/blog.html" import render_blog_post, render_gallery %}
{% block body_class %}blog post{% endblock %} {% block body_class %}blog post{% endblock %}
@ -7,8 +7,11 @@
{% block main_content %} {% block main_content %}
{{ render_blog_post(this) }} {{ render_blog_post(this) }}
{% if this.children.get("gallery") %}
{{ render_gallery(this) }}
{% endif %}
<div class="center block-info"> <div class="center block-info">
Comments have been disabled in this blog, if you want to contact me directly please <a href="{{ '/contact'|url }}">go ahead</a>! Comments have been disabled in this blog. If you want to contact me directly please use the information in the bottom of the page.
</div> </div>
{% endblock %} {% endblock %}

View file

@ -20,3 +20,17 @@
<hr class="light"> <hr class="light">
</article> </article>
{% endmacro %} {% endmacro %}
{% macro render_gallery(post) %}
<div class="center">
<h2>Gallery</h2>
<div style="display: flex; justify-content: center; flex-flow: row wrap; ">
{% for attachment in post.children.get("gallery").attachments.order_by("_id") %}
<a href="/blog/{{post._slug}}/gallery/{{attachment._id}}" style="width: 30%">
<img src="/blog/{{post._slug}}/gallery/{{attachment._id}}">
</a>
{% endfor %}
</div>
<hr class="light">
</div>
{% endmacro %}