瀏覽代碼

Merge branch 'nathan_bootstrap' into 'master'

Ajout de bootstrap et amélioration des vues avec celui-ci

See merge request clement.krebs/twyrael!9
SPAETER NATHAN 4 年之前
父節點
當前提交
4a452fd60c

+ 1 - 1
src/Controller/HomeController.php

@@ -32,7 +32,7 @@ class HomeController extends AbstractController
         }
 
         $formBuilder = $this->createFormBuilder();
-        $formBuilder->add('text', \Symfony\Component\Form\Extension\Core\Type\TextType::class)
+        $formBuilder->add('text', \Symfony\Component\Form\Extension\Core\Type\TextType::class,['label' => 'Envoyer un message'])
             ->setAction($this->generateUrl('home'));
         $form = $formBuilder->getForm();
 

+ 1 - 0
src/Controller/IndexController.php

@@ -15,6 +15,7 @@ class IndexController extends AbstractController
     {
         return $this->render('index/index.html.twig', [
             'controller_name' => 'IndexController',
+            'username' => $this->get('session')->get('user'),
         ]);
     }
 }

+ 2 - 2
src/Controller/ProfileController.php

@@ -63,11 +63,11 @@ class ProfileController extends AbstractController
         return $this->render('profile/index.html.twig', [
             'controller_name' => 'ProfileController',
             'privateNotAllowed' => $privateNotAllowed,
-            'username' => $username,
+            'profileusername' => $username,
             'isPrivate' => $isPrivate,
             'description' => $description,
             'me' => $me,
-            'sessionUser' => $sessionUser,
+            'username' => $sessionUser,
             'follow' => $follow,
             'subscriptionsList' => $subscriptionsList,
             'followersList' => $followersList,

+ 53 - 16
templates/base.html.twig

@@ -1,19 +1,56 @@
 <!DOCTYPE html>
 <html>
-    <head>
-        <meta charset="UTF-8">
-        <title>{% block title %}Welcome!{% endblock %}</title>
-        {# Run `composer require symfony/webpack-encore-bundle`
-           and uncomment the following Encore helpers to start using Symfony UX #}
-        {% block stylesheets %}
-            {#{{ encore_entry_link_tags('app') }}#}
-        {% endblock %}
+	<head>
+		<meta charset="UTF-8">
+		<title>
+			{% block title %}Welcome!
+			{% endblock %}
+		</title>
+		{# Run `composer require symfony/webpack-encore-bundle` and uncomment the following Encore helpers to start using Symfony UX #}
+		{% block stylesheets %}
+			<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
+		{% endblock %}
 
-        {% block javascripts %}
-        {% endblock %}
-    </head>
-    <body>
-        {% block body %}{% endblock %}
-
-    </body>
-</html>
+		{% block javascripts %}{% endblock %}
+	</head>
+	<body>
+		<nav class="navbar navbar-expand-lg navbar-light bg-light">
+			<div class="container-fluid">
+				<a class="navbar-brand" href="{{ path('index') }}">Twyrael</a>
+				<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+					<span class="navbar-toggler-icon"></span>
+				</button>
+				<div class="collapse navbar-collapse" id="navbarSupportedContent">
+					<ul class="navbar-nav me-auto mb-2 mb-lg-0">
+						{% if username is defined and username is not null %}
+							<li class="nav-item">
+								<a class="nav-link" href="{{ path('home') }}">Accueil</a>
+							</li>
+							<li class="nav-item">
+								<a class="nav-link" href="{{ path('profile', {'username': username }) }}">Profil</a>
+							</li>
+							<li class="nav-item">
+								<a class="nav-link" href="{{ path('parameters', {'username': username }) }}">Paramètres</a>
+							</li>
+							<li class="nav-item">
+								<a class="nav-link" href="{{ path('disconnect') }}">Se déconnecter</a>
+							</li>
+						</ul>
+						<form class="d-flex">
+							<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
+							<button class="btn btn-outline-success" type="submit">Search</button>
+						</form>
+						{% else %}
+						<li class="nav-item">
+							<a class="nav-link" href="{{ path('register') }}">S'enregistrer</a>
+						</li>
+						<li class="nav-item">
+							<a class="nav-link" href="{{ path('login') }}">Se connecter</a>
+						{% endif %}
+					</ul>
+				</div>
+			</div>
+		</nav>
+		{% block body %}{% endblock %}
+	</body>
+</html></body></html>

+ 17 - 9
templates/hashtag/index.html.twig

@@ -1,14 +1,22 @@
 {% extends 'base.html.twig' %}
 
-{% block title %}Hello HashtagController!{% endblock %}
+{% block title %}Hello HashtagController!
+{% endblock %}
 
 {% block body %}
-    <ul>
-{% for msg in messages %}
-    <li>
-        <a href={{ path('profile', {'username': msg.sender.getUsername() }) }}>{{ msg.sender.getUsername() }}</a>
-        <div>{{ msg.text | striptags('<a>') | raw }}</div>
-    </li>
-{% endfor %}
-    </ul>
+	<div class="d-flex flex-column align-items-center">
+		{% for msg in messages %}
+			<div class="card" style="width: 75rem;">
+				<div class="card-body">
+					<h5 class="card-title">
+						<a href={{ path('profile', {'username': msg.sender.getUsername() } ) }}>{{ msg.sender.getUsername() }}</a>
+					</h5>
+					<h6 class="card-subtitle mb-2 text-muted">{{ msg.getDate()|date('H:i - d/m/Y') }}</h6>
+					<p class="card-text">{{ msg.text | striptags('<a>') | raw }}</p>
+					<a href="#" class="card-link">RT</a>
+					{# <a href="{{ path('rt_message', {'msgId': msg.getId() }) }}" class="card-link">RT</a> #}
+				</div>
+			</div>
+		{% endfor %}
+	</div>
 {% endblock %}

+ 24 - 15
templates/home/index.html.twig

@@ -1,20 +1,29 @@
 {% extends 'base.html.twig' %}
 
-{% block title %}Accueil{% endblock %}
+{% block title %}Accueil
+{% endblock %}
 
 {% block body %}
-    <a href="{{ path('profile', {'username': username }) }}">Aller sur mon profil</a><br>
-    {{ form_start(form) }}
-    {{ form_errors(form) }}
-    {{ form_widget(form) }} <input type="submit">
-    {{ form_end(form) }}
-    <ul>
-    {% for msg in messages %}
-                <li>
-                    <a href={{ path('profile', {'username': msg.sender.getUsername() }) }}>{{ msg.sender.getUsername() }}</a>
-                    <div>{{ msg.text | striptags('<a>') | raw }}</div>
-                </li>
-    {% endfor %}
-    </ul>
-
+	<div class="d-flex flex-column align-items-center">
+		<div class="card" style="width: 75rem;">
+			{{ form_start(form) }}
+			{{ form_errors(form) }}
+			{{ form_widget(form) }}
+			<button type="submit" class="btn btn-primary">Envoyer</button>
+			{{ form_end(form) }}
+		</div>
+		{% for msg in messages %}
+			<div class="card" style="width: 75rem;">
+				<div class="card-body">
+					<h5 class="card-title">
+						<a href={{ path('profile', {'username': msg.sender.getUsername() } ) }}>{{ msg.sender.getUsername() }}</a>
+					</h5>
+					<h6 class="card-subtitle mb-2 text-muted">{{ msg.getDate()|date('H:i - d/m/Y') }}</h6>
+					<p class="card-text">{{ msg.text | striptags('<a>') | raw }}</p>
+					<a href="#" class="card-link">RT</a>
+					{# <a href="{{ path('rt_message', {'msgId': msg.getId() }) }}" class="card-link">RT</a> #}
+				</div>
+			</div>
+		{% endfor %}
+	</div>
 {% endblock %}

+ 1 - 2
templates/index/index.html.twig

@@ -3,6 +3,5 @@
 {% block title %}Accueil{% endblock %}
 
 {% block body %}
-<a href="{{ path('register') }}">S'enregistrer</a>
-<a href="{{ path('login') }}">Se connecter</a>
+<h1>Bienvenue sur Twyrael.</h1>
 {% endblock %}

+ 10 - 10
templates/parameters/index.html.twig

@@ -1,15 +1,15 @@
 {% extends 'base.html.twig' %}
 
-{% block title %}Paramètres{% endblock %}
+{% block title %}Paramètres
+{% endblock %}
 
 {% block body %}
-<a href="{{ path('profile', {'username': username }) }}">Retourner sur mon profil</a><br>
-{{ form_start(form) }}
-    {{ form_errors(form) }}
-    {{ form_widget(form) }}
-    <input type="submit">
-    {% if message %}
-        <div>{{ message }}</div>
-    {% endif %}
-{{ form_end(form) }}
+	{{ form_start(form) }}
+	{{ form_errors(form) }}
+	{{ form_widget(form) }}
+	<button type="submit" class="btn btn-primary">Envoyer</button>
+	{% if message %}
+		<div>{{ message }}</div>
+	{% endif %}
+	{{ form_end(form) }}
 {% endblock %}

+ 64 - 48
templates/profile/index.html.twig

@@ -1,53 +1,69 @@
 {% extends 'base.html.twig' %}
 
-{% block title %}Profil de {{username}}{% endblock %}
+{% block title %}Profil de
+	{{profileusername}}
+{% endblock %}
 
 {% block body %}
-<a href="{{ path('home') }}">Retourner au flux de messages</a><br>
-Bonjour {{sessionUser}}, <a href="{{ path('disconnect') }}">Se déconnecter</a>
-<h1>{{ username }}</h1>
-{% if me %}
-    <a href="{{ path('parameters', {'username': username }) }}">Paramètres</a>
-{% endif %}
-{% if not me %}
-    {% if not follow %}
-    <a href="{{ path('follow',{'username': username }) }}">S'abonner</a>
-    
-    {% else %}
-    <a href="{{ path('unfollow',{'username': username }) }}">Se désabonner</a>
-    {% endif %}
-{% endif %}
-<dl>
-    <dt>Description :</dt>
-        <dd>{{ description }}</dd>
-    <dt>Ce profil est :</dt>
-        {% if isPrivate %}
-        <dd>Privé</dd>
-        {% else %}
-        <dd>Public</dd>
-        {% endif %}
-</dl>
-<h2>Abonnés :</h2>
-<ul>
-    {% for follow in followersList %}
-    <li>{{ follow.username }}</li>
-    {% endfor %}
-</ul>
-<h2>Abonnements :</h2>
-<ul>
-{% for sub in subscriptionsList %}
-    <li>{{ sub.username }}</li>
-{% endfor %}
-</ul>
-<h2>Messages :</h2>
-    {% if not privateNotAllowed %}
-    <ul>
-        {% for msg in messages %}
-        <li>
-            <div>{{ msg.sender.getUsername() }}</div>
-            <div>{{ msg.text }}</div>
-        </li>
-        {% endfor %}
-    </ul>
-    {% endif %}
+	<div class="d-flex flex-column align-items-center">
+		<div class="card" style="width: 75rem;">
+			<div class="card-body">
+				<h5 class="card-title">{{ profileusername }}</h5>
+				<p class="card-text">{{ description }}</p>
+				{% if isPrivate %}
+					<p class="card-text">Ce profil est privé.</p>
+				{% else %}
+					<p class="card-text">Ce profil est public.</p>
+				{% endif %}
+				{% if not me %}
+					{% if not follow %}
+						<p class="card-text">
+							<a href="{{ path('follow',{'username': profileusername }) }}">S'abonner</a>
+						</p>
+					{% else %}
+						<p class="card-text">
+							<a href="{{ path('unfollow',{'username': profileusername }) }}">Se désabonner</a>
+						</p>
+					{% endif %}
+				{% endif %}
+				<h5 class="card-title">Abonnements</h5>
+				<div class="card-group">
+					{% for follow in followersList %}
+						<div class="card">
+							<div class="card-body">
+								<a href="{{ path('profile', {'username': follow.username }) }}">{{ follow.username }}</a>
+							</div>
+						</div>
+					{% endfor %}
+				</div>
+				<h5 class="card-title">Abonnés</h5>
+				<div class="card-group">
+					{% for sub in subscriptionsList %}
+						<div class="card">
+							<div class="card-body">
+								<a href="{{ path('profile', {'username': sub.username }) }}">{{ sub.username }}</a>
+							</div>
+						</div>
+					{% endfor %}
+				</div>
+			</div>
+		</div>
+		{% if not privateNotAllowed %}
+			<h2>Messages</h2>
+			<div>
+				{% for msg in messages %}
+					<div class="card" style="width: 75rem;">
+						<div class="card-body">
+							<h5 class="card-title">
+								<a href={{ path('profile', {'username': msg.sender.getUsername() } ) }}>{{ msg.sender.getUsername() }}</a>
+							</h5>
+							<h6 class="card-subtitle mb-2 text-muted">{{ msg.getDate()|date('H:i - d/m/Y') }}</h6>
+							<p class="card-text">{{ msg.text | striptags('<a>') | raw }}</p>
+							<a href="#" class="card-link">RT</a>
+						</div>
+					</div>
+				{% endfor %}
+			</div>
+		</div>
+	{% endif %}
 {% endblock %}