This commit is contained in:
parent
b36abcd3bf
commit
0d40b85f76
13 changed files with 232 additions and 58 deletions
File diff suppressed because one or more lines are too long
|
@ -414,6 +414,45 @@ main {
|
|||
line-height: 35px;
|
||||
}
|
||||
}
|
||||
|
||||
.scribble {
|
||||
&::after {
|
||||
border-bottom: 1px solid var(--c-primary);
|
||||
content: "";
|
||||
display: block;
|
||||
margin: 40px auto 0;
|
||||
width: 80%;
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
border-bottom-color: var(--c-primary-inv);
|
||||
}
|
||||
}
|
||||
|
||||
&:last-of-type::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
font-size: 0.86rem;
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
text-decoration: none;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1100px) {
|
||||
h1 {
|
||||
padding-top: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
|
|
28
site/blueprints/pages/scribble.yml
Normal file
28
site/blueprints/pages/scribble.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
title: Scribble
|
||||
|
||||
num: '{{ page.date.toDate("YmdHis") }}'
|
||||
|
||||
create:
|
||||
title: "{{ page.date.toDate('Y-m-d H:i') }}"
|
||||
slug: "{{ page.date.toDate('Ymd-Hi') }}"
|
||||
fields:
|
||||
- date
|
||||
|
||||
sections:
|
||||
meta:
|
||||
type: fields
|
||||
fields:
|
||||
date:
|
||||
type: date
|
||||
label: Date
|
||||
required: true
|
||||
time:
|
||||
step: 1
|
||||
default: now
|
||||
text:
|
||||
type: textarea
|
||||
label: Scribble
|
||||
font: monospace
|
||||
size: small
|
||||
files:
|
||||
type: files
|
24
site/blueprints/pages/scribbles.yml
Normal file
24
site/blueprints/pages/scribbles.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
title: Scribbles Page
|
||||
|
||||
sections:
|
||||
fields:
|
||||
type: fields
|
||||
fields:
|
||||
text:
|
||||
type: textarea
|
||||
font: monospace
|
||||
size: small
|
||||
drafts:
|
||||
extends: sections/scribbles
|
||||
label: Drafts
|
||||
status: draft
|
||||
unlisted:
|
||||
extends: sections/scribbles
|
||||
label: Unlisted
|
||||
status: unlisted
|
||||
listed:
|
||||
extends: sections/scribbles
|
||||
label: Published
|
||||
status: listed
|
||||
seo:
|
||||
extends: sections/seo
|
11
site/blueprints/sections/scribbles.yml
Normal file
11
site/blueprints/sections/scribbles.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
type: pages
|
||||
search: true
|
||||
image: false
|
||||
template: scribble
|
||||
sortBy: date desc
|
||||
empty: No scribbles yet
|
||||
layout: table
|
||||
columns:
|
||||
date:
|
||||
label: Published on
|
||||
width: 1/4
|
|
@ -9,6 +9,10 @@ return [
|
|||
'pattern' => 'feed',
|
||||
'action' => fn () => go('/blog.rss')
|
||||
],
|
||||
[
|
||||
'pattern' => 'feed/scribbles',
|
||||
'action' => fn () => go('/scribbles.rss')
|
||||
],
|
||||
[
|
||||
'pattern' => 'index.xml',
|
||||
'action' => fn () => go('/blog.rss')
|
||||
|
@ -32,6 +36,15 @@ return [
|
|||
'action' => function($tag) {
|
||||
return page('blog')->render(['tag' => $tag]);
|
||||
}
|
||||
]
|
||||
],
|
||||
[
|
||||
'pattern' => 'scribbles/(:num)/(:num)/(:num)-(:num)',
|
||||
'action' => function ($year, $month, $day, $time) {
|
||||
$path = $year . $month . $day . '-' . $time;
|
||||
$page = page('scribbles/' . $path);
|
||||
if (!$page) return site()->errorPage();
|
||||
return site()->visit($page);
|
||||
}
|
||||
],
|
||||
]
|
||||
];
|
||||
|
|
11
site/controllers/scribbles.php
Normal file
11
site/controllers/scribbles.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
return function (Page $page): array {
|
||||
$scribbles = $page->children()->listed();
|
||||
|
||||
return [
|
||||
'scribbles' => $scribbles->flip()->paginate(20)
|
||||
];
|
||||
};
|
19
site/models/scribble.php
Normal file
19
site/models/scribble.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
/**
|
||||
* @method object date()
|
||||
* @method object text()
|
||||
*/
|
||||
class ScribblePage extends Page
|
||||
{
|
||||
/**
|
||||
* @param array|string|null $options
|
||||
*/
|
||||
public function url($options = null): string
|
||||
{
|
||||
$date = $this->date()->toDate('Y/m/d-Hi');
|
||||
return '/scribbles/' . $date;
|
||||
}
|
||||
}
|
21
site/snippets/scribble.php
Normal file
21
site/snippets/scribble.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @var ScribblePage $scribble
|
||||
* @var bool $singlePage
|
||||
*/
|
||||
|
||||
$headlineLevel = $singlePage ? 1 : 2;
|
||||
$title = $scribble->date()->toDate('j. F Y @ h:i');
|
||||
?>
|
||||
|
||||
<article class="scribble">
|
||||
<h<?= $headlineLevel ?>>
|
||||
<?php if (!$singlePage): ?>
|
||||
<a href="<?= $scribble->url() ?>"><?= $title ?></a>
|
||||
<?php else: ?>
|
||||
<?= $title ?>
|
||||
<?php endif ?>
|
||||
</h<?= $headlineLevel ?>>
|
||||
|
||||
<?= $scribble->text()->kirbytext() ?>
|
||||
</article>
|
|
@ -14,59 +14,4 @@ $articles = $page
|
|||
->sortBy('date', 'desc')
|
||||
->limit(10);
|
||||
|
||||
$writer = new XMLWriter();
|
||||
$writer->openMemory();
|
||||
$writer->setIndent(true);
|
||||
$writer->setIndentString(' ');
|
||||
|
||||
$writer->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
$writer->startElement('rss');
|
||||
$writer->writeAttribute('version', '2.0');
|
||||
$writer->writeAttributeNs('xmlns', 'atom', null, 'http://www.w3.org/2005/Atom');
|
||||
|
||||
$writer->startElement('channel');
|
||||
$writer->writeElement('title', $site->title()->toString());
|
||||
$writer->writeElement('link', url());
|
||||
$writer->writeElement('description', $site->description()->toString());
|
||||
$writer->writeElement('language', 'en-GB');
|
||||
$writer->writeElement(
|
||||
'lastBuildDate',
|
||||
$articles->first()->date()->toDate(DATE_RSS)
|
||||
);
|
||||
$writer->writeElement('generator', 'Kirby CMS');
|
||||
$writer->writeElement('docs', 'https://www.rssboard.org/rss-specification');
|
||||
|
||||
$writer->startElementNs('atom', 'link', null);
|
||||
$writer->writeAttribute('href', url('/feed'));
|
||||
$writer->writeAttribute('rel', 'self');
|
||||
$writer->writeAttribute('type', 'application/rss+xml');
|
||||
$writer->endElement(); // atom:link
|
||||
|
||||
$writer->startElement('image');
|
||||
$writer->writeElement('url', url('/assets/img/favicon/favicon.png'));
|
||||
$writer->writeElement('title', $site->title()->toString());
|
||||
$writer->writeElement('link', url());
|
||||
$writer->endElement(); // image
|
||||
|
||||
foreach ($articles as $article) {
|
||||
/** @var Kirby\Cms\Page $article */
|
||||
$writer->startElement('item');
|
||||
|
||||
$writer->writeElement('title', $article->title()->toString());
|
||||
$writer->writeElement('link', url($article->url()));
|
||||
$writer->writeElement('guid', url($article->url()));
|
||||
$writer->writeElement('pubDate', $article->date()->toDate(DATE_RSS));
|
||||
|
||||
$writer->startElement('description');
|
||||
$writer->writeCdata($article->text()->kirbytext()->toString());
|
||||
$writer->endElement(); // description
|
||||
|
||||
$writer->endElement(); // item
|
||||
}
|
||||
|
||||
$writer->endElement(); // channel
|
||||
$writer->endElement(); // rss
|
||||
|
||||
$writer->endDocument();
|
||||
echo $writer->outputMemory();
|
||||
echo (new Mmk2410\KirbyHelpers\RssFeed($site, $articles, '/feed'))->generate();
|
||||
|
|
12
site/templates/scribble.php
Normal file
12
site/templates/scribble.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @var ScribblePage $page
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<?php snippet('scribble', ['scribble' => $page, 'singlePage' => true]) ?>
|
||||
|
||||
<a href="<?= page('scribbles')->url() ?>">More mindless drivel</a>
|
||||
<?php endslot() ?>
|
34
site/templates/scribbles.php
Normal file
34
site/templates/scribbles.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
* @var Kirby\Cms\Pages $scribbles
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
||||
<?= $page->text()->kirbytext() ?>
|
||||
|
||||
<?php foreach($scribbles as $scribble): ?>
|
||||
<?php snippet('scribble', ['scribble' => $scribble, 'singlePage' => false]) ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php if ($scribbles->pagination()->hasPages()): ?>
|
||||
<nav class="pagination">
|
||||
<?php if ($scribbles->pagination()->hasNextPage()): ?>
|
||||
<a class="page-item next" href="<?= $scribbles->pagination()->nextPageURL() ?>">
|
||||
‹ older scribbles
|
||||
</a>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($scribbles->pagination()->hasPrevPage()): ?>
|
||||
<a class="page-item prev" href="<?= $scribbles->pagination()->prevPageURL() ?>">
|
||||
newer scribbles ›
|
||||
</a>
|
||||
<?php endif ?>
|
||||
</nav>
|
||||
<?php endif ?>
|
||||
|
||||
<?php endslot() ?>
|
17
site/templates/scribbles.rss.php
Normal file
17
site/templates/scribbles.rss.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Kirby $kirby
|
||||
* @var Kirby\Cms\Site $site
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
|
||||
$kirby->response()->type('application/rss+xml');
|
||||
|
||||
$scribbles = $page
|
||||
->children()
|
||||
->template('scribble')
|
||||
->listed()
|
||||
->sortBy('date', 'desc')
|
||||
->limit(25);
|
||||
|
||||
echo (new Mmk2410\KirbyHelpers\RssFeed($site, $scribbles, '/feed/scribbles'))->generate();
|
Loading…
Add table
Reference in a new issue