Added delete post page

This commit is contained in:
2023-09-13 23:26:06 +04:00
parent c0942490c8
commit 0daa6af899
15 changed files with 205 additions and 49 deletions

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html data-bs-theme="light" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Update Post</title>
<link rel="icon" type="image/png" href="/static/img/shipit.png">
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
</head>
<body>
<div class="container" style="margin-top: 4rem;">
<div class="row">
<div class="col-md-10 col-lg-6 mx-auto">
<h3>Are you sure you want to delete {{post.title}}?</h3>
<div style="display: flex; margin-top: 4rem;">
<form action="/delete-post/{{post.slug}}" method="POST" style="margin-right: 4rem;">
<input type="submit" value="Yes" class="btn btn-danger">
</form>
<a href="/blog" class="btn btn-primary">No</a>
</div>
</div>
</div>
</div>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

View File

@@ -45,7 +45,7 @@
<button type="submit" class="btn btn-primary">Save</button>
</form>
<form action="/update-post/{{post.slug}}" method="POST" enctype="multipart/form-data" style="margin-bottom: 4.5rem;">
<p style="font-size: medium;">Current: <a href="/{{post.image_url}}" target=”_blank”>{{post.image_url}}</a></p>
<p style="font-size: medium;">Current: <a href="/{{post.image_path}}" target=”_blank”>{{post.image_path}}</a></p>
<div class="form-group" style="margin-bottom: 1.5rem;">
<label for="post-image">Image</label>
<input type="file" class="form-control-file" name="image" id="post-image">

View File

@@ -3,7 +3,7 @@
{% block title %}Blog{% endblock title %}
{% block content %}
<header class="masthead" style="background: url(&quot;static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<header class="masthead" style="background: url(&quot;/static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<div class="overlay"></div>
<div class="container">
<div class="row">
@@ -21,11 +21,15 @@
<div class="col-md-10 col-lg-8 mx-auto">
{% for post in posts %}
<div class="post-preview">
<a href="#">
<a href="/blog/{{post.slug}}">
<h2 class="post-title">{{post.title}}</h2>
<h3 class="post-subtitle">{{post.text}}</h3>
</a>
<p class="post-meta">Posted at&nbsp;<a href="#">{{post.created_at}}</a></p>
<p class="post-meta"><b>Posted at:</b>&nbsp;{{post.created_at.strftime('%Y-%m-%d %H:%M')}}</p>
{% if user %}
<a href="/update-post/{{post.slug}}" style="text-decoration: none; margin-right: 0.7rem;">Update</a>
<a href="/delete-post/{{post.slug}}" style="text-decoration: none;">Delete</a>
{% endif %}
</div>
<hr>
{% endfor %}
@@ -39,6 +43,11 @@
</button>
</div>
{% endif %}
{% if user %}
<a href="/add-post" class="btn btn-primary" style="text-decoration: none;">
Add
</a>
{% endif %}
</div>
</div>
</div>

View File

@@ -3,7 +3,7 @@
{% block title %}Just a Page{% endblock title %}
{% block content %}
<header class="masthead" style="background: url(&quot;static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<header class="masthead" style="background: url(&quot;/static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<div class="overlay"></div>
<div class="container">
<div class="row">

View File

@@ -2,14 +2,15 @@
{% block title %}Blog Post{% endblock title %}
{% block content %}
<header class="masthead" style="background: url(&quot;static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<header class="masthead" style="background: url(&quot;/static/img/bryan-goff-f7YQo-eYHdM-unsplash.jpg&quot;);">
<div class="overlay"></div>
<div class="container">
<div class="row">
<div class="col-md-10 col-lg-8 mx-auto position-relative">
<div class="site-heading">
<h1><strong>Title</strong></h1><span class="subheading">Date</span>
<h1><strong>{{post.title}}</strong></h1><span class="subheading">{{post.created_at.strftime('%Y-%m-%d %H:%M')}}</span>
</div>
</div>
</div>
@@ -19,25 +20,8 @@
<div class="container">
<div class="row">
<div class="col-md-10 col-lg-8 mx-auto">
<p>Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.</p>
<p>Science cuts two ways, of course; its products can be used for both good and evil. But there's no turning back from science. The early warnings about technological dangers also come from science.</p>
<p>What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.</p>
<p>A Chinese tale tells of some men sent to harm a young girl who, upon seeing her beauty, become her protectors rather than her violators. That's how I felt seeing the Earth for the first time. I could not help but love and cherish her.</p>
<p>For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us.</p>
<h2 class="section-heading">Heading</h2>
<p>There can be no thought of finishing for aiming for the stars. Both figuratively and literally, it is a task to occupy the generations. And no matter how much progress one makes, there is always the thrill of just beginning.</p>
<p>There can be no thought of finishing for aiming for the stars. Both figuratively and literally, it is a task to occupy the generations. And no matter how much progress one makes, there is always the thrill of just beginning.</p>
<figure>
<blockquote class="blockquote">
<p class="mb-0">The dreams of yesterday are the hopes of today and the reality of tomorrow. Science has not yet mastered prophecy. We predict too much for the next year and yet far too little for the next ten.</p>
</blockquote>
</figure>
<p>Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.</p>
<h2 class="section-heading">Reaching for the Stars</h2>
<p>As we got further and further away, it [the Earth] diminished in size. Finally it shrank to the size of a marble, the most beautiful you can imagine. That beautiful, warm, living object looked so fragile, so delicate, that if you touched it with a finger it would crumble and fall apart. Seeing this has to change a man.</p><a href="#"><img class="img-fluid" src="/static/img/post-sample-image.jpg"></a><span class="text-muted caption">To go places and do things that have never been done before thats what living is all about.</span>
<p>Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.</p>
<p>As I stand out here in the wonders of the unknown at Hadley, I sort of realize theres a fundamental truth to our nature, Man must explore, and this is exploration at its greatest.</p>
<p><span>Placeholder text by&nbsp;</span><a href="http://spaceipsum.com">Space Ipsum</a><span>&nbsp;Photographs by&nbsp;</span><a href="https://www.flickr.com/photos/nasacommons/">NASA on The Commons</a>.</p>
<img class="img-fluid" src="/{{post.image_path}}">
{{post.text|safe}}
</div>
</div>
</div>