Simplified
This commit is contained in:
@@ -3,28 +3,49 @@
|
||||
{% block title %}Admin – Gestion des articles{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Gestion des articles</h2>
|
||||
<h2>Gestion des articles</h2>
|
||||
|
||||
<!-- Lien d’ajout -->
|
||||
<a href="/admin/edit/0">+ Ajouter un article</a>
|
||||
<!-- Lien d'ajout -->
|
||||
<p>
|
||||
<a href="/admin/edit/0" class="btn btn-primary">+ Ajouter un article</a>
|
||||
</p>
|
||||
|
||||
{% for post in posts %}
|
||||
<div class="post">
|
||||
<h3>{{ post.title }}</h3>
|
||||
<p>{{ post.content|raw }}</p>
|
||||
|
||||
<div class="admin-actions">
|
||||
<a href="/admin/edit/{{ post.id }}">Éditer</a>
|
||||
{% if posts is not empty %}
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Titre</th>
|
||||
<th>Créé le</th>
|
||||
<th>Modifié le</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for post in posts %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ post.title }}</strong>
|
||||
{% if post.isRecent(7) %}
|
||||
<span class="badge badge-new">Nouveau</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ post.createdAt|date("d/m/Y H:i") }}</td>
|
||||
<td>{{ post.updatedAt|date("d/m/Y H:i") }}</td>
|
||||
<td class="admin-actions">
|
||||
<a href="/admin/edit/{{ post.id }}" class="btn btn-sm btn-secondary">Éditer</a>
|
||||
|
||||
<form method="post" action="/admin/delete/{{ post.id }}" style="display:inline;">
|
||||
<button type="submit"
|
||||
onclick="return confirm('Supprimer cet article ?')">
|
||||
<button type="submit" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Supprimer cet article ?')">
|
||||
Supprimer
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>Aucun article à gérer.</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p><em>Aucun article à gérer.</em></p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -3,12 +3,24 @@
|
||||
{% block title %}Mon Blog{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% for post in posts %}
|
||||
<div class="post">
|
||||
<h2>{{ post.title }}</h2>
|
||||
<p>{{ post.content|raw }}</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>Aucun article publié.</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% for post in posts %}
|
||||
<article class="post">
|
||||
<h2>{{ post.title }}</h2>
|
||||
|
||||
<div class="post-meta">
|
||||
<small>Publié le {{ post.createdAt|date("d/m/Y à H:i") }}</small>
|
||||
{% if post.isRecent(7) %}
|
||||
<span class="badge badge-new">Nouveau</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<p>{{ post.getExcerpt(200) }}</p>
|
||||
|
||||
<p>
|
||||
<a href="/article/{{ post.getSlug() }}">Lire la suite →</a>
|
||||
</p>
|
||||
</article>
|
||||
{% else %}
|
||||
<p>Aucun article publié.</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -1,68 +1,55 @@
|
||||
{% extends "layout.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{% if post is defined and post is not null and post.id is defined %}
|
||||
Éditer l’article
|
||||
{% else %}
|
||||
Créer un article
|
||||
{% endif %}
|
||||
{% if post is defined and post is not null and post.id > 0 %}
|
||||
Éditer l'article
|
||||
{% else %}
|
||||
Créer un article
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>
|
||||
{% if post is defined and post is not null and post.id is defined %}
|
||||
Éditer l’article
|
||||
{% else %}
|
||||
Créer un article
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
{# Formulaire identifié pour le script JavaScript #}
|
||||
<form id="articleForm" method="post" action="{{ action }}">
|
||||
<p>
|
||||
<label>Titre<br>
|
||||
<input type="text" name="title"
|
||||
value="{{ post.title|default('') }}" required>
|
||||
</label>
|
||||
</p>
|
||||
{% if post is defined and post is not null and post.id > 0 %}
|
||||
Éditer l'article
|
||||
{% else %}
|
||||
Créer un article
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<label>Contenu<br>
|
||||
<textarea id="editor" name="content" rows="6">{{ post.content|default('') }}</textarea>
|
||||
</label>
|
||||
</p>
|
||||
{# Formulaire identifié pour le script JavaScript #}
|
||||
<form id="articleForm" method="post" action="{{ action }}">
|
||||
<p>
|
||||
<label for="title">Titre<br>
|
||||
<input type="text" id="title" name="title" value="{{ post.title|default('') }}" required maxlength="255">
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<button type="submit">
|
||||
{% if post is defined and post is not null and post.id is defined %}Mettre à jour{% else %}Enregistrer{% endif %}
|
||||
<p>
|
||||
<label for="editor">Contenu<br>
|
||||
<textarea id="editor" name="content" rows="6" required>{{ post.content|default('') }}</textarea>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% if post is defined and post is not null and post.id > 0 %}
|
||||
Mettre à jour
|
||||
{% else %}
|
||||
Enregistrer
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
<a href="/admin" class="btn btn-secondary">Annuler</a>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{% if post is defined and post is not null and post.id > 0 %}
|
||||
<hr>
|
||||
<small>
|
||||
Créé le : {{ post.createdAt|date("d/m/Y à H:i") }}<br>
|
||||
Modifié le : {{ post.updatedAt|date("d/m/Y à H:i") }}
|
||||
</small>
|
||||
{% endif %}
|
||||
|
||||
<p><a href="/admin">Retour à l’admin</a></p>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/js/tinymce/tinymce.min.js" referrerpolicy="origin" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: '#editor',
|
||||
base_url: '/js/tinymce',
|
||||
license_key: 'gpl',
|
||||
height: 400,
|
||||
menubar: false,
|
||||
plugins: [
|
||||
'advlist', 'autolink', 'lists', 'link', 'image',
|
||||
'charmap', 'preview', 'anchor', 'searchreplace',
|
||||
'visualblocks', 'code', 'fullscreen',
|
||||
'insertdatetime', 'media', 'table',
|
||||
'help', 'wordcount'
|
||||
],
|
||||
toolbar: [
|
||||
'undo redo | formatselect | bold italic underline |',
|
||||
'alignleft aligncenter alignright alignjustify |',
|
||||
'bullist numlist outdent indent | link image media |',
|
||||
'removeformat | help'
|
||||
].join(' '),
|
||||
content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}'
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
Reference in New Issue
Block a user