From 5fcc32de6d204c27aebb1c3aa65e338fb9c0b563 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 24 May 2025 00:02:23 +0200 Subject: [PATCH] Change the snip layout to make it less cluttered --- src/Controller/SnipController.php | 2 +- templates/snip/base.html.twig | 74 +++++++++++++++++++++++++++++++ templates/snip/edit.html.twig | 28 +++++++----- templates/snip/single.html.twig | 65 ++++----------------------- templates/user/badge.html.twig | 4 +- templates/version/index.html.twig | 14 +++--- 6 files changed, 111 insertions(+), 76 deletions(-) create mode 100644 templates/snip/base.html.twig diff --git a/src/Controller/SnipController.php b/src/Controller/SnipController.php index e47c7e2..434c8c9 100644 --- a/src/Controller/SnipController.php +++ b/src/Controller/SnipController.php @@ -167,6 +167,6 @@ class SnipController extends AbstractController $this->addFlash('success', sprintf('Snip "%s" unarchived', $snip)); } - return $this->redirectToRoute('snip_single', ['snip' => $snip->getId()]); + return $this->redirectToRoute('snip_edit', ['snip' => $snip->getId()]); } } \ No newline at end of file diff --git a/templates/snip/base.html.twig b/templates/snip/base.html.twig new file mode 100644 index 0000000..4b21a19 --- /dev/null +++ b/templates/snip/base.html.twig @@ -0,0 +1,74 @@ +{% extends 'base/one.column.html.twig' %} + +{% block body %} + {% if app.user and app.user is same as(snip.createdBy) %} + + Index + + {% else %} + + Index + + {% endif %} + {% block buttons %}{% endblock %} + +

+
+
+ + + + {{ snip.id }} + + {% for tag in snip.tags %} + {{ tag }} + {% endfor %} + {{ include('user/badge.html.twig', {user: snip.createdBy}) }} + {{ include('snip/badge.html.twig', {snip: snip}) }} + +
+
+ {% block cardbody %}{% endblock %} +
+ +
+{% endblock %} + +{% block css %} + {{ parent() }} + +{% endblock %} + +{% block js %} + {{ parent() }} + + +{% endblock %} \ No newline at end of file diff --git a/templates/snip/edit.html.twig b/templates/snip/edit.html.twig index 6bc44bd..0695aae 100644 --- a/templates/snip/edit.html.twig +++ b/templates/snip/edit.html.twig @@ -1,21 +1,27 @@ -{% extends 'base/one.column.html.twig' %} +{% extends 'snip/base.html.twig' %} {% if snip.id %} - {% set title = 'Edit Snip ' ~ snip %} + {% set title %}{{ snip }} - Edit{% endset %} {% else %} {% set title = 'Create Snip' %} {% endif %} +{% set active = 'edit' %} -{% block body %} - {% if snip.id %} - - - Back +{% block buttons %} + {% if is_granted('edit', snip) %} + + {% if snip.archived %} + Unarchive + {% else %} + Archive + {% endif %} + + + Delete {% endif %} - - - Index -

+{% endblock %} + +{% block cardbody %} {{ form(form) }} {% endblock %} \ No newline at end of file diff --git a/templates/snip/single.html.twig b/templates/snip/single.html.twig index bd3a7dd..c9814cc 100644 --- a/templates/snip/single.html.twig +++ b/templates/snip/single.html.twig @@ -1,63 +1,16 @@ -{% extends 'base/one.column.html.twig' %} +{% extends 'snip/base.html.twig' %} -{% set title %}Snip {{ snip }}{% endset %} +{% set title %}{{ snip }} - View{% endset %} +{% set active = 'single' %} -{% block body %} - {% if app.user %} - - Back - - {% else %} - - Index - - {% endif %} - {% if is_granted('edit', snip) %} - - Versions - - - Edit - - - {% if snip.archived %} - Unarchive - {% else %} - Archive - {% endif %} - - - Delete - - {% endif %} - +{% block buttons %} + Raw -

-
-

- - {{ snip }} #{{ snip.id }} - - - {% for tag in snip.tags %} - {{ tag }} - {% endfor %} - {{ include('user/badge.html.twig', {user: snip.createdBy}) }} - {{ include('snip/badge.html.twig', {snip: snip}) }} - -

-
- {{ content|raw }} -
- -
+{% endblock %} + +{% block cardbody %} + {{ content|raw }} {% endblock %} {% block css %} diff --git a/templates/user/badge.html.twig b/templates/user/badge.html.twig index a6c3cd5..1e014f6 100644 --- a/templates/user/badge.html.twig +++ b/templates/user/badge.html.twig @@ -1 +1,3 @@ -{{ user }} \ No newline at end of file + + {{ user }} + \ No newline at end of file diff --git a/templates/version/index.html.twig b/templates/version/index.html.twig index 81a7c20..079d141 100644 --- a/templates/version/index.html.twig +++ b/templates/version/index.html.twig @@ -1,18 +1,18 @@ -{% extends 'base/one.column.html.twig' %} +{% extends 'snip/base.html.twig' %} -{% set title = 'Snip ' ~ snip %} +{% set title %}{{ snip }} - Versions{% endset %} +{% set active = 'versions' %} -{% block body %} - - Back - +{% block buttons %} Latest Compare -

+{% endblock %} + +{% block cardbody %}
{% for version in snip.snipContents|reverse %}