Skip to content

Commit

Permalink
adding sitemap, styling twig files
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmonroe committed Nov 5, 2020
1 parent cb022a7 commit 81ed68a
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 13 deletions.
12 changes: 10 additions & 2 deletions config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
# path: /
# controller: App\Controller\SecurityController::login

hometown:
#homepage:
#path: /
#controller: App\Controller\SecurityController::login

home:
path: /
controller: App\Controller\SecurityController::login
controller: App\Controller\SecurityController::sitemap

sitemap:
path: /sitemap
controller: App\Controller\SecurityController::sitemap

post_ledger:
path: /post
Expand Down
2 changes: 1 addition & 1 deletion public/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ nav {

#login-container {
margin-left: 25%;
margin-top: 15%;
margin-top: 5%;
}
9 changes: 6 additions & 3 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ class SecurityController extends AbstractController
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
// if ($this->getUser()) {
// return $this->redirectToRoute('target_path');
// }

// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();

// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();

Expand All @@ -34,4 +32,9 @@ public function logout()
return $this->redirectToRoute('app_login');
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}

public function sitemap()
{
return $this->render('sitemap.html.twig');
}
}
8 changes: 8 additions & 0 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,19 @@ public function delete(Request $request, User $user): Response
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($user);
$entityManager->flush();

$this->_delete_yourself();
}
}
return $this->redirectToRoute('user_index');
} else {
return $this->redirectToRoute('app_login');
}
}

private function _delete_yourself(){
// if you delete yourself, automatically, destroy session and logout
session_destroy();
return $this->redirectToRoute('app_login');
}
}
2 changes: 1 addition & 1 deletion src/Form/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('title', TextType::class, ['attr' => ['class' => 'form-control', 'maxlength' => 32]])
->add('body', TextAreaType::class,
['attr' => ['class' => 'form-control', 'cols' => 4, 'maxlength' =>255]]
['attr' => ['class' => 'form-control', 'cols' => 5, 'maxlength' =>255]]
);

}
Expand Down
4 changes: 4 additions & 0 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<a class="nav-link" href="{{ path('post_index') }}">Posts</a>
</li>
<li class="nav-delimiter-adj"><span>|</span></li>
<li>
<a class="nav-link" href="{{ path('sitemap') }}">Site Map</a>
</li>
<li class="nav-delimiter-adj"><span>|</span></li>
<li>
<a class="nav-link" href="{{ path('app_logout') }}">Logout</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions templates/post/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<th>ID</th>
<th>USER</th>
<th>TITLE</th>
<th>BODY <small>snippet</small></th>
<th>BODY <small class="alert alert-warning" style="padding:2px 4px">snippet</small></th>
<th>DATE</th>
</tr>
</thead>
Expand All @@ -39,7 +39,7 @@
</tr>
{% else %}
<tr>
<td colspan="5"><p class="alert alert-warning">There are no posts submitted.</p></td>
<td colspan="8" class="alert alert-warning text-center"><i class="material-icons">info_outline</i> There are no posts submitted.</td>
</tr>
{% endfor %}
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions templates/security/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<form id="login-form" name="login-form" class="form-horizontal" role="form" method="post">
{% if app.user %}
<div class="mb-3">
<p>You are logged in as {{ app.user.username }}, <a href="{{ path('app_logout') }}">Logout</a></p>
<p class="text-center">You are logged in as {{ app.user.username }}, <a href="{{ path('app_logout') }}">Logout</a></p>
</div>
{% endif %}

Expand All @@ -23,11 +23,11 @@

<div class="form-group">
<label class="col-md-4 control-label" for="inputUsername"><i class="material-icons">person</i> Username</label>
<input type="text" value="{{ last_username }}" name="username" id="inputUsername" class="form-control" maxlength="16" required autofocus>
<input type="text" value="{{ last_username }}" name="username" id="inputUsername" class="form-control" minlength="3" maxlength="16" required autofocus>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="inputPassword"><i class="material-icons">lock</i> Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" maxlength="16" required>
<input type="password" name="password" id="inputPassword" class="form-control" minlength="4" maxlength="16" required>
</div>

<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
Expand Down
51 changes: 51 additions & 0 deletions templates/sitemap.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% extends 'base.html.twig' %}

{% block title %}Site Map{% endblock %}

{% block body %}
<div class="row">
<div class="col-md-12">
{% if app.user == null %}
<p class="alert alert-warning text-center"><i class="material-icons">info_outline</i> You are not currently logged in. You can view Site Map as a directory. </p>
{% endif %}

<h2 class="h2-mt-10"><i class="material-icons">view_headline</i> Site Map</h2>

<p class="alert alert-info text-center">
<i class="material-icons">info_outline</i> Don't forget to clear cache! $_ php bin/console cache:clear
</p>

<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Users</th>
<th>Posts</th>
<th>Misc</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="{{ path('user_index') }}">ledger</a></td>
<td><a href="{{ path('post_index') }}">ledger</a></td>
<td><a href="{{ path('app_login') }}">login</a></td>
</tr>
<tr>
<td><a href="{{ path('user_new') }}">add</a></td>
<td><a href="{{ path('post_new') }}">add</a></td>
<td><a href="{{ path('app_logout') }}">logout</a></td>
</tr>
<tr>
<td><a href="{{ path('user_edit', {'id': 0}) }}">edit</a></td>
<td><a href="{{ path('post_edit', {'id': 0}) }}">edit</a></td>
<td></td>
</tr>
<tr>
<td><a href="{{ path('user_show', {'id': 0}) }}">profile</a></td>
<td><a href="{{ path('post_show', {'id': 0}) }}">profile</a></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/user/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</tr>
{% else %}
<tr>
<td colspan="8"><p class="alert alert-warning"><i class="material-icons">info_outline</i> There are no registered users.</p></td>
<td colspan="8" class="alert alert-warning text-center"><i class="material-icons">info_outline</i> There are no registered users.</td>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 81ed68a

Please sign in to comment.