Simplified

This commit is contained in:
julien
2026-03-09 14:33:50 +01:00
parent 38d78d6df9
commit f63246ac20
5 changed files with 35 additions and 356 deletions

3
.gitignore vendored
View File

@@ -8,3 +8,6 @@ composer.lock
# Base de données SQLite # Base de données SQLite
/database/*.sqlite /database/*.sqlite
/database/*.db /database/*.db
# Cache et logs
/var/

View File

@@ -1,151 +0,0 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* pages/home.twig */
class __TwigTemplate_9471f8175ca69249c24a559aa9930d1d extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->blocks = [
'title' => [$this, 'block_title'],
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
{
// line 1
return "layout.twig";
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$this->parent = $this->load("layout.twig", 1);
yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
}
// line 3
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_title(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
yield "Mon Blog";
yield from [];
}
// line 5
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_content(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
// line 6
$context['_parent'] = $context;
$context['_seq'] = CoreExtension::ensureTraversable(($context["posts"] ?? null));
$context['_iterated'] = false;
foreach ($context['_seq'] as $context["_key"] => $context["post"]) {
// line 7
yield "<article class=\"post\">
<h2>";
// line 8
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "title", [], "any", false, false, false, 8), "html", null, true);
yield "</h2>
<div class=\"post-meta\">
<small>Publié le ";
// line 11
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "createdAt", [], "any", false, false, false, 11), "d/m/Y à H:i"), "html", null, true);
yield "</small>
";
// line 12
if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, $context["post"], "isRecent", [7], "method", false, false, false, 12)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
// line 13
yield " <span class=\"badge badge-new\">Nouveau</span>
";
}
// line 15
yield " </div>
<p>";
// line 17
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "getExcerpt", [200], "method", false, false, false, 17), "html", null, true);
yield "</p>
<p>
<a href=\"/article/";
// line 20
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "getSlug", [], "method", false, false, false, 20), "html", null, true);
yield "\">Lire la suite →</a>
</p>
</article>
";
$context['_iterated'] = true;
}
// line 23
if (!$context['_iterated']) {
// line 24
yield "<p>Aucun article publié.</p>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_key'], $context['post'], $context['_parent'], $context['_iterated']);
$context = array_intersect_key($context, $_parent) + $_parent;
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "pages/home.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable(): bool
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 114 => 24, 112 => 23, 104 => 20, 98 => 17, 94 => 15, 90 => 13, 88 => 12, 84 => 11, 78 => 8, 75 => 7, 70 => 6, 63 => 5, 52 => 3, 41 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "pages/home.twig", "/home/julien/Documents/Git/julien/blog-slim/views/pages/home.twig");
}
}

View File

@@ -109,68 +109,67 @@ class __TwigTemplate_1bca1bf826c65d946ceb9c6169e6cfec extends Template
<p> <p>
<label for=\"editor\">Contenu<br> <label for=\"editor\">Contenu<br>
<textarea id=\"editor\" name=\"content\" rows=\"6\" required>"; ";
// line 31 // line 32
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(((CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "content", [], "any", true, true, false, 31)) ? (Twig\Extension\CoreExtension::default(CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "content", [], "any", false, false, false, 31), "")) : ("")), "html", null, true); yield " <textarea id=\"editor\" name=\"content\" rows=\"6\" required></textarea>
yield "</textarea>
</label> </label>
</p> </p>
<p> <p>
<button type=\"submit\" class=\"btn btn-primary\"> <button type=\"submit\" class=\"btn btn-primary\">
"; ";
// line 37
if (((array_key_exists("post", $context) && !(null === ($context["post"] ?? null))) && (CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "id", [], "any", false, false, false, 37) > 0))) {
// line 38 // line 38
if (((array_key_exists("post", $context) && !(null === ($context["post"] ?? null))) && (CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "id", [], "any", false, false, false, 38) > 0))) {
// line 39
yield " Mettre à jour yield " Mettre à jour
"; ";
} else { } else {
// line 40 // line 41
yield " Enregistrer yield " Enregistrer
"; ";
} }
// line 42 // line 43
yield " </button> yield " </button>
<a href=\"/admin\" class=\"btn btn-secondary\">Annuler</a> <a href=\"/admin\" class=\"btn btn-secondary\">Annuler</a>
</p> </p>
</form> </form>
"; ";
// line 47
if (((array_key_exists("post", $context) && !(null === ($context["post"] ?? null))) && (CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "id", [], "any", false, false, false, 47) > 0))) {
// line 48 // line 48
if (((array_key_exists("post", $context) && !(null === ($context["post"] ?? null))) && (CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "id", [], "any", false, false, false, 48) > 0))) {
// line 49
yield "<hr> yield "<hr>
<small> <small>
Créé le : "; Créé le : ";
// line 50 // line 51
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "createdAt", [], "any", false, false, false, 50), "d/m/Y à H:i"), "html", null, true); yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "createdAt", [], "any", false, false, false, 51), "d/m/Y à H:i"), "html", null, true);
yield "<br> yield "<br>
Modifié le : "; Modifié le : ";
// line 51 // line 52
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "updatedAt", [], "any", false, false, false, 51), "d/m/Y à H:i"), "html", null, true); yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, ($context["post"] ?? null), "updatedAt", [], "any", false, false, false, 52), "d/m/Y à H:i"), "html", null, true);
yield " yield "
</small> </small>
"; ";
} }
// line 54 // line 55
yield " yield "
"; ";
yield from []; yield from [];
} }
// line 57 // line 58
/** /**
* @return iterable<null|scalar|\Stringable> * @return iterable<null|scalar|\Stringable>
*/ */
public function block_scripts(array $context, array $blocks = []): iterable public function block_scripts(array $context, array $blocks = []): iterable
{ {
$macros = $this->macros; $macros = $this->macros;
// line 58 // line 59
yield "<script src=\"/js/tinymce/tinymce.min.js\" referrerpolicy=\"origin\" crossorigin=\"anonymous\"></script> yield "<script src=\"/js/tinymce/tinymce.min.js\" referrerpolicy=\"origin\" crossorigin=\"anonymous\"></script>
<script> <script>
tinymce.init({ tinymce.init({
selector: '#editor', selector: '#editor',
base_url: '/js/tinymce', // assure le bon chemin relatif base_url: '/js/tinymce',
license_key: 'gpl', license_key: 'gpl',
height: 400, height: 400,
menubar: false, menubar: false,
@@ -189,6 +188,11 @@ class __TwigTemplate_1bca1bf826c65d946ceb9c6169e6cfec extends Template
].join(' '), ].join(' '),
content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}' content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}'
}); });
// Synchroniser TinyMCE avant soumission du formulaire
document.getElementById('articleForm').addEventListener('submit', function (e) {
tinymce.triggerSave();
});
</script> </script>
"; ";
yield from []; yield from [];
@@ -215,7 +219,7 @@ class __TwigTemplate_1bca1bf826c65d946ceb9c6169e6cfec extends Template
*/ */
public function getDebugInfo(): array public function getDebugInfo(): array
{ {
return array ( 169 => 58, 162 => 57, 156 => 54, 150 => 51, 146 => 50, 142 => 48, 140 => 47, 133 => 42, 129 => 40, 125 => 38, 123 => 37, 114 => 31, 105 => 25, 98 => 22, 94 => 19, 90 => 17, 86 => 15, 84 => 14, 80 => 12, 73 => 11, 66 => 7, 62 => 5, 60 => 4, 53 => 3, 42 => 1,); return array ( 168 => 59, 161 => 58, 155 => 55, 149 => 52, 145 => 51, 141 => 49, 139 => 48, 132 => 43, 128 => 41, 124 => 39, 122 => 38, 114 => 32, 105 => 25, 98 => 22, 94 => 19, 90 => 17, 86 => 15, 84 => 14, 80 => 12, 73 => 11, 66 => 7, 62 => 5, 60 => 4, 53 => 3, 42 => 1,);
} }
public function getSourceContext(): Source public function getSourceContext(): Source

View File

@@ -1,182 +0,0 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* pages/admin.twig */
class __TwigTemplate_9953ee20db26573f1b0e2b3758f3423d extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->blocks = [
'title' => [$this, 'block_title'],
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
{
// line 1
return "layout.twig";
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
$this->parent = $this->load("layout.twig", 1);
yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
}
// line 3
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_title(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
yield "Admin Gestion des articles";
yield from [];
}
// line 5
/**
* @return iterable<null|scalar|\Stringable>
*/
public function block_content(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
// line 6
yield "<h2>Gestion des articles</h2>
<!-- Lien d'ajout -->
<p>
<a href=\"/admin/edit/0\" class=\"btn btn-primary\">+ Ajouter un article</a>
</p>
";
// line 13
if ((($tmp = !Twig\Extension\CoreExtension::testEmpty(($context["posts"] ?? null))) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
// line 14
yield "<table class=\"admin-table\">
<thead>
<tr>
<th>Titre</th>
<th>Créé le</th>
<th>Modifié le</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
";
// line 24
$context['_parent'] = $context;
$context['_seq'] = CoreExtension::ensureTraversable(($context["posts"] ?? null));
foreach ($context['_seq'] as $context["_key"] => $context["post"]) {
// line 25
yield " <tr>
<td>
<strong>";
// line 27
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "title", [], "any", false, false, false, 27), "html", null, true);
yield "</strong>
";
// line 28
if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, $context["post"], "isRecent", [7], "method", false, false, false, 28)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
// line 29
yield " <span class=\"badge badge-new\">Nouveau</span>
";
}
// line 31
yield " </td>
<td>";
// line 32
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "createdAt", [], "any", false, false, false, 32), "d/m/Y H:i"), "html", null, true);
yield "</td>
<td>";
// line 33
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "updatedAt", [], "any", false, false, false, 33), "d/m/Y H:i"), "html", null, true);
yield "</td>
<td class=\"admin-actions\">
<a href=\"/admin/edit/";
// line 35
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "id", [], "any", false, false, false, 35), "html", null, true);
yield "\" class=\"btn btn-sm btn-secondary\">Éditer</a>
<form method=\"post\" action=\"/admin/delete/";
// line 37
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "id", [], "any", false, false, false, 37), "html", null, true);
yield "\" style=\"display:inline;\">
<button type=\"submit\" class=\"btn btn-sm btn-danger\"
onclick=\"return confirm('Supprimer cet article ?')\">
Supprimer
</button>
</form>
</td>
</tr>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_key'], $context['post'], $context['_parent']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 46
yield " </tbody>
</table>
";
} else {
// line 49
yield "<p><em>Aucun article à gérer.</em></p>
";
}
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "pages/admin.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable(): bool
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 148 => 49, 143 => 46, 128 => 37, 123 => 35, 118 => 33, 114 => 32, 111 => 31, 107 => 29, 105 => 28, 101 => 27, 97 => 25, 93 => 24, 81 => 14, 79 => 13, 70 => 6, 63 => 5, 52 => 3, 41 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "pages/admin.twig", "/home/julien/Documents/Git/julien/blog-slim/views/pages/admin.twig");
}
}

View File

@@ -29,7 +29,7 @@ Créer un article
<p> <p>
<label for="editor">Contenu<br> <label for="editor">Contenu<br>
{# <textarea id="editor" name="content" rows="6" required>{{ post.content|default('') }}</textarea> #} {# <textarea id="editor" name="content" rows="6" required>{{ post.content|default('') }}</textarea> #}
<textarea id="editor" name="content" rows="6">{{ post.content|default('') }}</textarea> <textarea id="editor" name="content" rows="6" required></textarea>
</label> </label>
</p> </p>
@@ -60,7 +60,7 @@ Créer un article
<script> <script>
tinymce.init({ tinymce.init({
selector: '#editor', selector: '#editor',
base_url: '/js/tinymce', // assure le bon chemin relatif base_url: '/js/tinymce',
license_key: 'gpl', license_key: 'gpl',
height: 400, height: 400,
menubar: false, menubar: false,
@@ -79,5 +79,10 @@ Créer un article
].join(' '), ].join(' '),
content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}' content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}'
}); });
// Synchroniser TinyMCE avant soumission du formulaire
document.getElementById('articleForm').addEventListener('submit', function (e) {
tinymce.triggerSave();
});
</script> </script>
{% endblock %} {% endblock %}