Rewrite for Kirby

This commit is contained in:
Marcel Kapfer 2024-03-17 22:34:51 +01:00
parent 07201d05de
commit f854d60108
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09
116 changed files with 4156 additions and 8875 deletions

16
site/templates/about.php Normal file
View file

@ -0,0 +1,16 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<h1><?= $page->title() ?></h1>
<div style="text-align: center; margin: 20px 0;">
<img src="<?= $page->image('profile.png')->url() ?>" style="width: 300px" />
<div style="font-size: 40px">
<strong><?= $page->intro_title() ?></strong>
</div>
<div style="font-size: 25px">
<?= $page->intro_text() ?>
</div>
</div>
<?= $page->text()->kirbytext() ?>
<?php endslot() ?>

View file

@ -0,0 +1,33 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<h1><?= $page->title() ?></h1>
<p id="date"><?= $page->date()->toDate('Y-m-d') ?></p>
<p id="readingtime"><?= $page->readingTime() ?></p>
<p>
<div class="tagories">
<?php if ($page->categories()->isNotEmpty()): ?>
<span id="categories">
<?php foreach ($page->categories()->split() as $category): ?>
<a href="/blog/category/<?= $category ?>"><?= $category ?></a>
<?php endforeach ?>
</span>
<?php endif ?>
<?php if ($page->tags()->isNotEmpty()): ?>
<span id="tags">
<?php foreach ($page->tags()->split() as $tag): ?>
<a href="/blog/tag/<?= $tag ?>"><?= $tag ?></a>
<?php endforeach ?>
</span>
<?php endif ?>
</div>
</p>
<?= $page->text()->kirbytext() ?>
<div class="comment">
<p>I would like to hear what you think about this post. Feel free to write me a mail!</p>
<a class="btn" href="mailto:comment@mmk2410.org?subject=Reply to: <?= $page->title()?>">Reply by mail</a>
</div>
<?php endslot() ?>

27
site/templates/blog.php Normal file
View file

@ -0,0 +1,27 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<h1><?= $page->title() ?></h1>
<?= $page->text()->kirbytext() ?>
<?php foreach($articles as $article): ?>
<?php snippet('article', ['article' => $article]) ?>
<?php endforeach ?>
<?php if ($articles->pagination()->hasPages()): ?>
<nav class="pagination">
<?php if ($articles->pagination()->hasNextPage()): ?>
<a class="page-item next" href="<?= $articles->pagination()->nextPageURL() ?>">
older posts
</a>
<?php endif ?>
<?php if ($articles->pagination()->hasPrevPage()): ?>
<a class="page-item prev" href="<?= $articles->pagination()->prevPageURL() ?>">
newer posts
</a>
<?php endif ?>
</nav>
<?php endif ?>
<?php endslot() ?>

View file

@ -0,0 +1,31 @@
<?php
$feed = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"></rss>');
$feed->channel->title = $site->title()->toString();
$feed->channel->description = $site->description()->toString();
$feed->channel->link = url();
$feed->channel->language = 'en-us';
$feed->channel->lastBuildDate = date(DATE_RSS);
$feed->channel->generator = 'Kirby';
$atomLink = $feed->channel->addChild('atom:link', null, 'atom');
$atomLink->addAttribute('href', url('/feed'));
$atomLink->addAttribute('rel', 'self');
$atomLink->addAttribute('type', 'application/rss+xml');
$articles = $page->children()->template('article')->sortBy('date', 'desc')->limit(10);
foreach ($articles as $article) {
$xmlArticle = $feed->channel->addChild('item');
$xmlArticle->title = $article->title()->toString();
$xmlArticle->link = url($article->url());
$xmlArticle->description = Escape::xml($article->text()->kirbytext());
$xmlArticle->pubDate = $article->date()->toDate(DATE_RSS);
$xmlArticle->guid = url($article->url());
}
$kirby->response()->type('application/rss+xml');
echo $feed->asXML();

View file

@ -0,0 +1,6 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<h1><?= $page->title() ?></h1>
<?= $page->text()->kirbytext() ?>
<?php endslot() ?>

29
site/templates/home.php Normal file
View file

@ -0,0 +1,29 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<header>
<h1><?= $site->title() ?></h1>
<h3><?= $page->subtitle() ?></h3>
</header>
<?= $page->text()->kirbytext() ?>
<h4>Read more from me</h4>
<?php foreach ($page->internal_menu()->toStructure() as $item): ?>
<a class="btn" href="<?= $item->link()->toUrl() ?>"><?= $item->title() ?></a>
<?php endforeach ?>
<h4>Find me on other places</h4>
<?php foreach ($page->external_menu()->toStructure() as $item): ?>
<a class="btn" href="<?= $item->link()->toUrl() ?>"><?= $item->title() ?></a>
<?php endforeach ?>
<h2>Latest Posts</h2>
<?php foreach(page('blog')->children()->listed()->flip()->limit(3) as $article): ?>
<?php snippet('article', ['article' => $article]) ?>
<?php endforeach ?>
<a class="btn" href="<?= page('blog')->url() ?>">Read more posts</a>
<?php endslot() ?>

34
site/templates/quotes.php Normal file
View file

@ -0,0 +1,34 @@
<?php snippet('layout', slots: true) ?>
<?php slot() ?>
<h1><?= $page->title() ?></h1>
<?= $page->text()->kirbytext() ?>
<?php foreach($quotes as $quote): ?>
<article>
<h2><a href="<?= $quote->url() ?>"><?= $quote->title() ?></a></h2>
<p id="date"><?= $quote->date()->toDate('Y-m-d') ?></p>
<p>
<?= $quote->text()->kirbytext() ?>
</p>
</article>
<?php endforeach ?>
<?php if ($quotes->pagination()->hasPages()): ?>
<nav class="pagination">
<?php if ($quotes->pagination()->hasNextPage()): ?>
<a class="page-item next" href="<?= $quotes->pagination()->nextPageURL() ?>">
ältere Einträge
</a>
<?php endif ?>
<?php if ($quotes->pagination()->hasPrevPage()): ?>
<a class="page-item prev" href="<?= $quotes->pagination()->prevPageURL() ?>">
neuere Einträge
</a>
<?php endif ?>
</nav>
<?php endif ?>
<?php endslot() ?>