Refactor templates to be more structured

This commit is contained in:
Tim 2023-12-23 23:56:18 +01:00
parent be5e457d1b
commit a5619e2307
15 changed files with 46 additions and 45 deletions

View File

@ -132,7 +132,7 @@ class SnipController extends AbstractController
return $this->redirectToRoute('snip_index');
}
return $this->render('form.html.twig', [
return $this->render('generic/form.html.twig', [
'message' => sprintf('Do you really want to delete "%s"?', $snip),
'form' => $form->createView(),
]);

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}SNIPS{% endblock %}</title>
<title>{% if title is defined %}{{ title }}{% else %}SNIPS{% endif %}</title>
<link rel="shortcut icon" type="image/jpg" href="/favicon.png">
{% block css %}
@ -37,19 +37,7 @@
</div>
{# body blocks #}
{% block bodyraw %}
<div class="container">
<div class="row">
<div class="col-sm mx-auto">
{% block body %}{% endblock %}
</div>
{% if block('body2') is defined %}
<div class="col-sm mx-auto">
{{ block('body2') }}
</div>
{% endif %}
</div>
</div>
{% block content %}
{% endblock %}
{# javascript block #}

View File

@ -0,0 +1,8 @@
{% extends 'base/base.html.twig' %}
{% block content %}
<div class="container">
{% block container %}
{% endblock %}
</div>
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends 'base/container.html.twig' %}
{% block container %}
<div class="row">
<div class="col-sm mx-auto">
{% if title is defined %}<h3>{{ title }}</h3>{% endif %}
{% block body %}{% endblock %}
</div>
</div>
{% endblock %}

View File

@ -1,6 +0,0 @@
{% extends 'base/base.html.twig' %}
{% block body %}
<h3>{{ message }}</h3>
{{ form(form) }}
{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends 'base/single.column.html.twig' %}
{% set title %}{{ message }}{% endset %}
{% block body %}
{{ form(form) }}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends 'base/single.column.html.twig' %}
{% block body %}
{{ text | nl2br }}
{% endblock %}

View File

@ -1,6 +1,6 @@
{% extends 'base/base.html.twig' %}
{% extends 'base/single.column.html.twig' %}
{% block title %}Login{% endblock %}
{% set title %}Login{% endset %}
{% block body %}
<form action="{{ path('login') }}" method="post">
@ -12,7 +12,6 @@
You are already logged in as {{ app.user }}, <a href="{{ path('logout') }}">Logout</a>
</div>
{% endif %}
<h1 class="h3 mb-3 font-weight-normal">Please login</h1>
<label for="inputUsername">Username</label>
<input type="text" value="{{ last_username }}" name="_username" id="inputUsername" class="form-control" required
autofocus>

View File

@ -1,8 +1,7 @@
{% extends 'base/base.html.twig' %}
{% extends 'base/single.column.html.twig' %}
{% block title %}Register{% endblock %}
{% set title %}Register{% endset %}
{% block body %}
<h1 class="h3 mb-3 font-weight-normal">Register new user</h1>
{{ form(registrationForm) }}
{% endblock %}

View File

@ -1,5 +0,0 @@
{% extends 'base/base.html.twig' %}
{% block body %}
{{ text | nl2br }}
{% endblock %}

View File

@ -1,6 +1,6 @@
{% extends 'base/base.html.twig' %}
{% extends 'base/single.column.html.twig' %}
{% block title %}Edit {{ snip }}{% endblock %}
{% set title %}Edit {{ snip }}{% endset %}
{% block body %}
{% if snip.id %}
@ -13,6 +13,5 @@
<i class="fa fa-list"></i>
Index
</a><br><br>
<h2>Editing {{ snip }}</h2>
{{ form(form) }}
{% endblock %}

View File

@ -1,9 +1,6 @@
{% extends 'base/base.html.twig' %}
{% block title %}{{ title }}{% endblock %}
{% extends 'base/single.column.html.twig' %}
{% block body %}
<h1>{{ title }}</h1>
<a class="btn btn-success" href="{{ path('snip_new') }}">
<i class="fa fa-plus"></i> Add
</a>

View File

@ -1,6 +1,6 @@
{% extends 'base/base.html.twig' %}
{% extends 'base/single.column.html.twig' %}
{% block title %}Snip {{ snip }}{% endblock %}
{% set title %}Snip {{ snip }}{% endset %}
{% block body %}
<a href="{{ path('snip_index') }}" class="btn btn-primary">

View File

@ -1,9 +1,9 @@
{% extends "base/base.html.twig" %}
{% extends 'base/single.column.html.twig' %}
{% block body %}
<div class="row">
<div class="col-sm">
<h4>{{ app.user.name }}</h4>
<h3>{{ app.user.name }}</h3>
<br/>
{% if is_granted('ROLE_ADMIN') %}
<br/><br/>
@ -16,7 +16,7 @@
{% endif %}
</div>
<div class="col-sm">
<h4>Change profile</h4>
<h3>Change profile</h3>
{{ form(form) }}
</div>
</div>

View File

@ -1,4 +1,4 @@
{% extends 'base/base.html.twig' %}
{% extends 'base/single.column.html.twig' %}
{% block title %}Snip {{ snip }}{% endblock %}