deblan.io-murph/templates/page/post/_post.html.twig

232 lines
9.8 KiB
Twig

{% set full = full is defined and full %}
<div class="col-12">
<div class="body">
{% if post.isQuick %}
<div class="quick">
{% set image = null %}
{% if post.quickImage %}
{% set image = post.quickImage %}
{% elseif post.image %}
{% set image = asset(post.image) %}
{% endif %}
{% set url = post.quickUrl %}
{% set title = post.title %}
{% set content = post.content|murph_url %}
{% if post.quickVideo and post.quickShowVideo and post.quickVideoHeight and post.quickVideoWidth %}
<div class="quick-video">
<div class="video-ratio" data-ratio="{{ post.quickVideoHeight * 100 / post.quickVideoWidth }}%">
<iframe src="{{ post.quickVideo }}" allowfullscreen></iframe>
</div>
</div>
{% elseif image %}
<div class="quick-image">
<a href="{{ url }}" target="_blank">
<img src="{{ asset('build/images/px.png') }}" data-src="{{ image }}" alt="{{ title }}" title="{{ title }}">
</a>
</div>
{% endif %}
<div class="quick-body">
<h2 class="h4 no-margin">
<a href="{{ url }}" target="_blank">
{{- title -}}
</a>
</h2>
<p class="no-margin">
<a href="{{ url }}" target="_blank">{{ url }}</a>
</p>
{% if post.contentFormat == 'html' %}
{{- post.content|murph_url|file_attributes|post -}}
{% elseif post.contentFormat == 'markdown' %}
{{- post.content|murph_url|file_attributes|markdown('post') -}}
{% elseif post.contentFormat == 'editorjs' %}
{{- post.content|murph_url|file_attributes|editorjs_to_html -}}
{% endif %}
{% if not full %}
<p>
<a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) }}">
{{- 'Lien permanent' -}}
</a>
</p>
{% endif %}
</div>
</div>
{% else %}
{% if not full %}
<h2 class="h2 no-margin">
<a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) }}">
{{- post.title -}}
</a>
</h2>
<ul class="list--inline no-margin">
<li>
<time datetime="{{ post.publishedAt|date("Y-m-d") }}" title="{{ post.publishedAt|date("r") }}">
{{- 'Le ' ~ post.publishedAt|date("d/m/Y à H\\hi") -}}
</time>
</li>
{% for category in post.categories %}
<li>
<a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug, _domain: _domain}) }}">
{{- category.title -}}
</a>
</li>
{% endfor %}
{% for tag in post.tags %}
<li>
<a href="{{ safe_path('blog_menu_search', {tag: tag.label, _domain: _domain}) }}">
{{- '#' ~ tag.label -}}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
<div class="body-content">
{% if post.contentFormat == 'html' %}
{{- post.content|murph_url|file_attributes|post -}}
{% elseif post.contentFormat == 'markdown' %}
{{- post.content|murph_url|file_attributes|markdown('post')|lazy_load -}}
{% elseif post.contentFormat == 'editorjs' %}
{{- post.content|murph_url|file_attributes|editorjs_to_html|raw -}}
{% endif %}
</div>
{% endif %}
</div>
</div>
{% if full %}
<div class="col-12">
<div class="reviews">
<hr>
{% set comments = post.comments({
isActive: true,
isFirstLevel: true
}) %}
{% if comments|length %}
<div class="grid">
{% for comment in comments %}
{{ include('page/post/_comment.html.twig', {comment: comment, level: 1}) }}
{% endfor %}
</div>
{% endif %}
<div class="grid" id="form">
<form class="form col-12" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri, _domain: _domain}) }}">
{% if comments|length %}
<hr>
{% endif %}
<div class="h4">Ajouter un commentaire</div>
<div class="row">
<div class="field col-6">
{{ form_label(form.author) }}
{{ form_widget(form.author) }}
{{ form_errors(form.author) }}
</div>
<div class="field col-6">
{{ form_label(form.website) }}
{{ form_widget(form.website) }}
{{ form_errors(form.website) }}
</div>
</div>
<div class="row">
<div class="field col-12">
{{ form_label(form.email) }}
{{ form_widget(form.email) }}
{{ form_errors(form.email) }}
</div>
</div>
<div class="row">
<div class="field col-12">
{{ form_label(form.follow) }}
{{ form_widget(form.follow) }}
{{ form_errors(form.follow) }}
</div>
</div>
<div class="field">
<p class="no-margin">
{{- 'Votre commentaire - Vous pouvez utiliser du markdown ' }}
[<a title="Afficher l'aide" href="{{ safe_path('blog_tech_mardown', {_domain: _domain}) }}" target="_blank">?</a>]
</p>
{{ form_errors(form.content) }}
{{ form_widget(form.content, {attr: {cols: 30, rows: 10}}) }}
<div class="hidden alert alert-notice-light" id="answer-alert">
<div class="grid">
<div class="col-9">
{{- 'Vous répondez à un commentaire' -}}
</div>
<div class="col-3 align-right">
<a href="#" id="cancel-answer">
<span class="button small">
{{- 'Annuler' -}}
</span>
</a>
</div>
</div>
</div>
</div>
<div class="field field-captcha">
{{ form_label(form.captcha) }}
{{ form_widget(form.captcha) }}
</div>
<div class="field">
<input type="checkbox" id="rgpd" required>
<label for="rgpd">En validant ce formulaire, vous acceptez que les données saisies seront publiées sur cette page à l'exception de votre e-mail. Votre e-mail sera utilisé pour afficher votre avatar (<a href="https://www.libravatar.org/" target="_blank">via Libravatar</a>) et pour les notifications.</label>
</div>
<div class="field">
<input type="submit" class="button" value="Publier" />
<input type="button" class="button alt preview-button" value="Prévisualiser" />
</div>
{{ form_rest(form) }}
</form>
<div id="preview" class="review-body col-12"></div>
</div>
</div>
</div>
{% if not post.isQuick %}
{%
set ld = {
'@context': 'http://schema.org/',
'@type': 'BlogPosting',
'headline': post.title,
'author': {
'@type': 'Person',
'name': 'Simon Vieille'
},
'publisher': {
'@type': 'Organization',
'name': 'Deblan blog',
'logo': {
'@type': 'imageObject',
'url': asset('build/images/logo.png')
}
},
'datePublished': post.publishedAt|date("c"),
'dateModified': post.updatedAt|date("c"),
'image': post.image ? asset(post.image) : null
}
%}
<script type="application/ld+json">{{- ld|json_encode(128)|replace({'\\/': '/'})|raw -}}</script>
{% endif %}
{% endif %}