abschluss
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
<div class="post">
|
||||
<a href="/post/{{ $post->getId() }}">{{ $post->getTitle() }}</a>
|
||||
<p>{{ $post->getContent(50) }}</p>
|
||||
<p>Datum: 2025-03-04</p>
|
||||
<p>Datum: {{ $post->getDateTime() }}</p>
|
||||
<p>Autor: {{ $post->getAuthor() }}</p>
|
||||
</div>
|
||||
{% endforeach; %}
|
||||
|
@ -6,7 +6,30 @@
|
||||
<div id="overview">
|
||||
<h1>{{ $post->getTitle() }}</h1>
|
||||
<section class="post-view">
|
||||
<p>{{ $post->getContent() }}</p>
|
||||
{% if ($isLoggedIn): %}
|
||||
<form id="editForm" method="post" action="/post/{{ $post->getId() }}/edit" style="display:none;">
|
||||
<textarea name="content" rows="10" cols="80">{{ $post->getContent() }}</textarea>
|
||||
<br>
|
||||
<button type="submit">Speichern</button>
|
||||
<button type="button" onclick="toggleEdit(false)">Abbrechen</button>
|
||||
<input type="hidden" name="_csrf_token" value="{{ $csrf }}">
|
||||
</form>
|
||||
<p id="postContent">{{ $post->getContent() }}</p>
|
||||
<button id="editBtn" onclick="toggleEdit(true)">Bearbeiten</button>
|
||||
<form action="/post/delete/{{ $post->getId() }}" method="post" onsubmit="return confirm('Beitrag wirklich löschen?');">
|
||||
<input type="hidden" name="_csrf_token" value="{{ $csrf }}">
|
||||
<button type="submit">Löschen</button>
|
||||
</form>
|
||||
<script>
|
||||
function toggleEdit(edit) {
|
||||
document.getElementById('editForm').style.display = edit ? 'block' : 'none';
|
||||
document.getElementById('postContent').style.display = edit ? 'none' : 'block';
|
||||
document.getElementById('editBtn').style.display = edit ? 'none' : 'inline';
|
||||
}
|
||||
</script>
|
||||
{% else: %}
|
||||
<p>{{ $post->getContent() }}</p>
|
||||
{% endif; %}
|
||||
</section>
|
||||
<a href="/">back</a>
|
||||
</div>
|
||||
|
@ -8,7 +8,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="blog">
|
||||
<a href="/">Home</a> - <a href="/login">Login</a>
|
||||
<a href="/">Home</a> -
|
||||
{% if (@$isLoggedIn): %}
|
||||
<a href="/post/new">neuer Post</a> -
|
||||
<a href="/logout">Logout</a>
|
||||
{% else: %}
|
||||
<a href="/login">Login</a>
|
||||
{% endif; %}
|
||||
<hr>
|
||||
{% yield content %}
|
||||
</div>
|
||||
|
16
views/post_new.twig
Normal file
16
views/post_new.twig
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends layout %}
|
||||
|
||||
{% block title %}Neuen Post anlegen{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Neuen Blogpost anlegen</h1>
|
||||
<form method="post" action="/post/new">
|
||||
<label for="title">Titel:</label><br>
|
||||
<input type="text" id="title" name="title" required><br><br>
|
||||
<label for="content">Inhalt:</label><br>
|
||||
<textarea id="content" name="content" rows="10" cols="80" required></textarea><br><br>
|
||||
<input type="hidden" name="_csrf_token" value="{{ $csrf }}">
|
||||
<button type="submit">Anlegen</button>
|
||||
</form>
|
||||
<a href="/">Zurück</a>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user