Created simple blog.

This commit is contained in:
WickedJack99
2025-07-28 15:04:22 +02:00
parent 93c17ca16c
commit 7b91d32f23
10 changed files with 2132 additions and 1 deletions

1994
Parsedown.php Normal file

File diff suppressed because it is too large Load Diff

20
Parsedown_LICENSE.txt Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1 +1,4 @@
# blog
# Testing
php -S localhost:8000

6
includes/footer.php Normal file
View File

@@ -0,0 +1,6 @@
</main>
<footer>
<p style="text-align:center;">&copy; <?= date('Y') ?> Jack's Blog</p>
</footer>
</body>
</html>

10
includes/header.php Normal file
View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Mein Blog</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<nav><a href="index.php">🏠 Home</a></nav>
<main>

18
index.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
include 'includes/header.php';
$posts = glob('posts/*.md');
rsort($posts);
?>
<h1>Blog</h1>
<ul>
<?php foreach ($posts as $post):
$slug = basename($post, '.md');
$firstLine = fgets(fopen($post, 'r'));
$title = trim(str_replace('#', '', $firstLine));
?>
<li><a href="post.php?slug=<?= urlencode($slug) ?>"><?= htmlspecialchars($title) ?></a></li>
<?php endforeach; ?>
</ul>
<?php include 'includes/footer.php'; ?>

18
post.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
include 'includes/header.php';
require_once 'Parsedown.php';
$slug = $_GET['slug'] ?? '';
$filepath = "posts/$slug.md";
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $slug) || !file_exists($filepath)) {
echo "<p>Beitrag nicht gefunden.</p>";
include 'includes/footer.php';
exit;
}
$md = file_get_contents($filepath);
$Parsedown = new Parsedown();
echo $Parsedown->text($md);
include 'includes/footer.php';

View File

@@ -0,0 +1,2 @@
# Chickpea Cake Recipe

View File

@@ -0,0 +1,13 @@
# My first blog post 👋🗺️
Yoo, Jack here, this is my first blog post to see the light.
Hello World 😊
On this blog I will post thoughts, and other stuff I want to share.
Huge thanks to [Emanuil Rusev](https://github.com/erusev) for developing Parsedown!
Code & structure inspired by OpenAIs ChatGPT assistance.
See you later alligator!

47
style.css Normal file
View File

@@ -0,0 +1,47 @@
html, body {
height: 100%;
margin: 0;
padding: 0;
background: #121212;
color: #e0e0e0;
font-family: sans-serif;
display: flex;
flex-direction: column;
}
a {
color: #90caf9;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
nav {
margin: 1rem auto;
padding: 0 1rem;
max-width: 800px;
width: 100%;
}
main {
flex: 1;
max-width: 800px;
margin: auto;
width: 100%;
padding: 1rem;
}
img {
max-width: 100%;
height: auto;
display: block;
margin: 1rem 0;
}
footer {
text-align: center;
padding: 1rem 0;
}