mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 955024e3444f8f6391ce7e7fb050693ac44d1cc0
parent 694b48eab7410529dcee991bf5c5dc073f72375d
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date:   Sat, 23 Dec 2023 09:47:33 +0100

Add blog subpage for poetry

Diffstat:
Acontent/5-write/2020-04-07-blog-example-page.md | 10++++++++++
Acontent/5-write/2020-12-06-made-for-people.md | 8++++++++
Acontent/5-write/page.md | 5+++++
Acontent/shared/page-new-blog.md | 9+++++++++
Asystem/extensions/blog.php | 248+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msystem/extensions/update-current.ini | 17+++++++++++++++++
Msystem/extensions/update-latest.ini | 11+++++++++++
Msystem/extensions/yellow-language.ini | 4++++
Msystem/extensions/yellow-system.ini | 6+++++-
Msystem/extensions/yellow-website.log | 1+
Asystem/layouts/blog-start.html | 22++++++++++++++++++++++
Asystem/layouts/blog.html | 23+++++++++++++++++++++++
12 files changed, 363 insertions(+), 1 deletion(-)

diff --git a/content/5-write/2020-04-07-blog-example-page.md b/content/5-write/2020-04-07-blog-example-page.md @@ -0,0 +1,10 @@ +--- +Title: Blog example page +Published: 2020-04-07 +Author: Datenstrom +Layout: blog +Tag: Example +--- +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. [--more--] + +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/content/5-write/2020-12-06-made-for-people.md b/content/5-write/2020-12-06-made-for-people.md @@ -0,0 +1,8 @@ +--- +Title: Made for people +Published: 2020-12-06 +Author: Datenstrom +Layout: blog +Tag: Example +--- +Datenstrom Yellow is for people who make small websites. Installing is unzipping one file and you are ready to go. The most important things for small websites are included. You can add features, languages and themes. Datenstrom Yellow works as content management system and static site generator. diff --git a/content/5-write/page.md b/content/5-write/page.md @@ -0,0 +1,5 @@ +--- +Title: write +Layout: blog-start +LayoutNew: blog +--- diff --git a/content/shared/page-new-blog.md b/content/shared/page-new-blog.md @@ -0,0 +1,8 @@ +--- +Title: Blog page +Published: @datetime +Author: @username +Layout: blog +Tag: Example +--- +This is a new blog page. +\ No newline at end of file diff --git a/system/extensions/blog.php b/system/extensions/blog.php @@ -0,0 +1,248 @@ +<?php +// Blog extension, https://github.com/annaesvensson/yellow-blog + +class YellowBlog { + const VERSION = "0.8.30"; + public $yellow; // access to API + + // Handle initialisation + public function onLoad($yellow) { + $this->yellow = $yellow; + $this->yellow->system->setDefault("blogStartLocation", "auto"); + $this->yellow->system->setDefault("blogNewLocation", "@title"); + $this->yellow->system->setDefault("blogShortcutEntries", "0"); + $this->yellow->system->setDefault("blogPaginationLimit", "5"); + } + + // Handle page content of shortcut + public function onParseContentShortcut($page, $name, $text, $type) { + $output = null; + if (substru($name, 0, 4)=="blog" && ($type=="block" || $type=="inline")) { + switch($name) { + case "blogauthors": $output = $this->getShortcutBlogauthors($page, $name, $text); break; + case "blogtags": $output = $this->getShortcutBlogtags($page, $name, $text); break; + case "blogyears": $output = $this->getShortcutBlogyears($page, $name, $text); break; + case "blogmonths": $output = $this->getShortcutBlogmonths($page, $name, $text); break; + case "blogpages": $output = $this->getShortcutBlogpages($page, $name, $text); break; + } + } + return $output; + } + + // Return blogauthors shortcut + public function getShortcutBlogauthors($page, $name, $text) { + $output = null; + list($startLocation, $shortcutEntries) = $this->yellow->toolbox->getTextArguments($text); + if (is_string_empty($startLocation)) $startLocation = $this->yellow->system->get("blogStartLocation"); + if (is_string_empty($shortcutEntries)) $shortcutEntries = $this->yellow->system->get("blogShortcutEntries"); + $blogStart = $this->getBlogStart($page, $startLocation); + if (!is_null($blogStart)) { + $pages = $this->getBlogPages($blogStart); + $page->setLastModified($pages->getModified()); + $authors = $pages->group("author", false, "count"); + if ($shortcutEntries!=0) $authors = array_slice($authors, 0, $shortcutEntries, true); + uksort($authors, "strnatcasecmp"); + $output = "<div class=\"".htmlspecialchars($name)."\">\n"; + $output .= "<ul>\n"; + foreach ($authors as $author=>$collection) { + $output .= "<li><a href=\"".$blogStart->getLocation(true).$this->yellow->lookup->normaliseArguments("author:$author")."\">"; + $output .= htmlspecialchars($author)."</a></li>\n"; + } + $output .= "</ul>\n"; + $output .= "</div>\n"; + } else { + $page->error(500, "Blogauthors '$startLocation' does not exist!"); + } + return $output; + } + + // Return blogtags shortcut + public function getShortcutBlogtags($page, $name, $text) { + $output = null; + list($startLocation, $shortcutEntries) = $this->yellow->toolbox->getTextArguments($text); + if (is_string_empty($startLocation)) $startLocation = $this->yellow->system->get("blogStartLocation"); + if (is_string_empty($shortcutEntries)) $shortcutEntries = $this->yellow->system->get("blogShortcutEntries"); + $blogStart = $this->getBlogStart($page, $startLocation); + if (!is_null($blogStart)) { + $pages = $this->getBlogPages($blogStart); + $page->setLastModified($pages->getModified()); + $tags = $pages->group("tag", false, "count"); + if ($shortcutEntries!=0) $tags = array_slice($tags, 0, $shortcutEntries, true); + uksort($tags, "strnatcasecmp"); + $output = "<div class=\"".htmlspecialchars($name)."\">\n"; + $output .= "<ul>\n"; + foreach ($tags as $tag=>$collection) { + $output .= "<li><a href=\"".$blogStart->getLocation(true).$this->yellow->lookup->normaliseArguments("tag:$tag")."\">"; + $output .= htmlspecialchars($tag)."</a></li>\n"; + } + $output .= "</ul>\n"; + $output .= "</div>\n"; + } else { + $page->error(500, "Blogtags '$startLocation' does not exist!"); + } + return $output; + } + + // Return blogyears shortcut + public function getShortcutBlogyears($page, $name, $text) { + $output = null; + list($startLocation, $shortcutEntries) = $this->yellow->toolbox->getTextArguments($text); + if (is_string_empty($startLocation)) $startLocation = $this->yellow->system->get("blogStartLocation"); + if (is_string_empty($shortcutEntries)) $shortcutEntries = $this->yellow->system->get("blogShortcutEntries"); + $blogStart = $this->getBlogStart($page, $startLocation); + if (!is_null($blogStart)) { + $pages = $this->getBlogPages($blogStart); + $page->setLastModified($pages->getModified()); + $years = $pages->group("published", false, "Y"); + if ($shortcutEntries!=0) $years = array_slice($years, 0, $shortcutEntries, true); + $output = "<div class=\"".htmlspecialchars($name)."\">\n"; + $output .= "<ul>\n"; + foreach ($years as $year=>$collection) { + $output .= "<li><a href=\"".$blogStart->getLocation(true).$this->yellow->lookup->normaliseArguments("published:$year")."\">"; + $output .= htmlspecialchars($this->yellow->language->getDateStandard($year))."</a></li>\n"; + } + $output .= "</ul>\n"; + $output .= "</div>\n"; + } else { + $page->error(500, "Blogyears '$startLocation' does not exist!"); + } + return $output; + } + + // Return blogmonths shortcut + public function getShortcutBlogmonths($page, $name, $text) { + $output = null; + list($startLocation, $shortcutEntries) = $this->yellow->toolbox->getTextArguments($text); + if (is_string_empty($startLocation)) $startLocation = $this->yellow->system->get("blogStartLocation"); + if (is_string_empty($shortcutEntries)) $shortcutEntries = $this->yellow->system->get("blogShortcutEntries"); + $blogStart = $this->getBlogStart($page, $startLocation); + if (!is_null($blogStart)) { + $pages = $this->getBlogPages($blogStart); + $page->setLastModified($pages->getModified()); + $months = $pages->group("published", false, "Y-m"); + if ($shortcutEntries!=0) $months = array_slice($months, 0, $shortcutEntries, true); + $output = "<div class=\"".htmlspecialchars($name)."\">\n"; + $output .= "<ul>\n"; + foreach ($months as $month=>$collection) { + $output .= "<li><a href=\"".$blogStart->getLocation(true).$this->yellow->lookup->normaliseArguments("published:$month")."\">"; + $output .= htmlspecialchars($this->yellow->language->getDateStandard($month))."</a></li>\n"; + } + $output .= "</ul>\n"; + $output .= "</div>\n"; + } else { + $page->error(500, "Blogmonths '$startLocation' does not exist!"); + } + return $output; + } + + // Return blogpages shortcut + public function getShortcutBlogpages($page, $name, $text) { + $output = null; + list($startLocation, $shortcutEntries, $filterTag) = $this->yellow->toolbox->getTextArguments($text); + if (is_string_empty($startLocation)) $startLocation = $this->yellow->system->get("blogStartLocation"); + if (is_string_empty($shortcutEntries)) $shortcutEntries = $this->yellow->system->get("blogShortcutEntries"); + $blogStart = $this->getBlogStart($page, $startLocation); + if (!is_null($blogStart)) { + $pages = $this->getBlogPages($blogStart)->remove($page); + $page->setLastModified($pages->getModified()); + if (!is_string_empty($filterTag)) $pages->filter("tag", $filterTag); + $pages->sort("published", false); + if ($shortcutEntries!=0) $pages->limit($shortcutEntries); + $output = "<div class=\"".htmlspecialchars($name)."\">\n"; + $output .= "<ul>\n"; + foreach ($pages as $pageBlog) { + $output .= "<li><a".($pageBlog->isExisting("tag") ? " class=\"".$this->getClass($pageBlog)."\"" : ""); + $output .=" href=\"".$pageBlog->getLocation(true)."\">".$pageBlog->getHtml("title")."</a></li>\n"; + } + $output .= "</ul>\n"; + $output .= "</div>\n"; + } else { + $page->error(500, "Blogpages '$startLocation' does not exist!"); + } + return $output; + } + + // Handle page layout + public function onParsePageLayout($page, $name) { + if ($name=="blog-start") { + $pages = $this->getBlogPages($page); + $pagesFilter = array(); + if ($page->isRequest("tag")) { + $pages->filter("tag", $page->getRequest("tag")); + array_push($pagesFilter, $pages->getFilter()); + } + if ($page->isRequest("author")) { + $pages->filter("author", $page->getRequest("author")); + array_push($pagesFilter, $pages->getFilter()); + } + if ($page->isRequest("published")) { + $pages->filter("published", $page->getRequest("published"), false); + array_push($pagesFilter, $this->yellow->language->getDateStandard($pages->getFilter())); + } + $pages->sort("published", false); + if (!is_array_empty($pagesFilter)) { + $text = implode(" ", $pagesFilter); + $page->set("titleHeader", $text." - ".$page->get("sitename")); + $page->set("titleContent", $page->get("title").": ".$text); + $page->set("title", $page->get("title").": ".$text); + $page->set("blogWithFilter", true); + } + $page->setPages("blog", $pages); + $page->setLastModified($pages->getModified()); + $page->setHeader("Cache-Control", "max-age=60"); + } + if ($name=="blog") { + $blogStartLocation = $this->yellow->system->get("blogStartLocation"); + if ($blogStartLocation=="auto") { + $blogStart = $page->getParent(); + } else { + $blogStart = $this->yellow->content->find($blogStartLocation); + } + $page->setPage("blogStart", $blogStart); + } + } + + // Handle content file editing + public function onEditContentFile($page, $action, $email) { + if ($page->get("layout")=="blog") $page->set("editNewLocation", $this->yellow->system->get("blogNewLocation")); + } + + // Return blog start page, null if not found + public function getBlogStart($page, $blogStartLocation) { + if ($blogStartLocation=="auto") { + $blogStart = null; + foreach ($this->yellow->content->top(true, false) as $pageTop) { + if ($pageTop->get("layout")=="blog-start") { + $blogStart = $pageTop; + break; + } + } + if ($page->get("layout")=="blog-start") $blogStart = $page; + } else { + $blogStart = $this->yellow->content->find($blogStartLocation); + } + return $blogStart; + } + + // Return blog pages for page + public function getBlogPages($page) { + if ($this->yellow->system->get("blogStartLocation")=="auto") { + $pages = $page->getChildren(); + } else { + $pages = $this->yellow->content->index(); + } + $pages->filter("layout", "blog"); + return $pages; + } + + // Return class for page + public function getClass($page) { + $class = ""; + if ($page->isExisting("tag")) { + foreach (preg_split("/\s*,\s*/", $page->get("tag")) as $tag) { + $class .= " tag-".$this->yellow->lookup->normaliseArguments($tag, false); + } + } + return trim($class); + } +} diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -1,5 +1,22 @@ # Datenstrom Yellow update settings +Extension: Blog +Version: 0.8.30 +Description: Blog for your website. +DownloadUrl: https://github.com/annaesvensson/yellow-blog/archive/refs/heads/main.zip +DocumentationUrl: https://github.com/annaesvensson/yellow-blog +DocumentationLanguage: en, de, sv +Published: 2023-11-01 17:49:02 +Developer: Anna Svensson +Tag: feature +system/extensions/blog.php: blog.php, create, update +system/layouts/blog.html: blog.html, create, update, careful +system/layouts/blog-start.html: blog-start.html, create, update, careful +content/shared/page-new-blog.md: page-new-blog.md, create, optional +content/2-blog/page.md: page.md, create, optional +content/2-blog/2020-04-07-blog-example-page.md: 2020-04-07-blog-example-page.md, create, optional +content/2-blog/2020-12-06-made-for-people.md: 2020-12-06-made-for-people.md, create, optional + Extension: Core Version: 0.8.125 Description: Core functionality of your website. diff --git a/system/extensions/update-latest.ini b/system/extensions/update-latest.ini @@ -570,6 +570,17 @@ Developer: Anna Svensson Tag: feature system/extensions/publish.php: publish.php, create, update +Extension: Readingtime +Version: 0.8.22 +Description: Show estimated reading time for page content. +DownloadUrl: https://github.com/schulle4u/yellow-readingtime/archive/refs/heads/main.zip +DocumentationUrl: https://github.com/schulle4u/yellow-readingtime +DocumentationLanguage: en, de +Published: 2023-05-23 13:25:56 +Developer: Steffen Schultz +Tag: feature, page, blog, readingtime +system/extensions/readingtime.php: readingtime.php, create, update + Extension: Russian Version: 0.8.43 Description: Russian language. diff --git a/system/extensions/yellow-language.ini b/system/extensions/yellow-language.ini @@ -4,6 +4,10 @@ Language: en LanguageLocale: en_GB LanguageDescription: English LanguageTranslator: Mark Seuffert +BlogDescription: Blog for your website. +BlogBy: by +BlogTag: Tags: +BlogMore: Read more… CoreDescription: Core functionality of your website. CoreNavigation: Main CorePagination: Page diff --git a/system/extensions/yellow-system.ini b/system/extensions/yellow-system.ini @@ -30,8 +30,12 @@ UpdateLatestFile: update-latest.ini UpdateCurrentFile: update-current.ini UpdateExtensionFile: extension.ini UpdateEventPending: none -UpdateEventDaily: 1703289651 +UpdateEventDaily: 1703376051 UpdateTrashTimeout: 7776660 +BlogStartLocation: /write/ +BlogNewLocation: @title +BlogShortcutEntries: 0 +BlogPaginationLimit: 5 EditSiteEmail: noreply EditLocation: /edit/ EditUploadNewLocation: /media/@group/@filename diff --git a/system/extensions/yellow-website.log b/system/extensions/yellow-website.log @@ -11,3 +11,4 @@ 2023-12-22 17:46:30 info Install extension 'German 0.8.43' 2023-12-22 17:46:30 info Install extension 'Swedish 0.8.43' 2023-12-22 17:46:45 info Add user 'asd' +2023-12-23 08:35:04 info Install extension 'Blog 0.8.30' diff --git a/system/layouts/blog-start.html b/system/layouts/blog-start.html @@ -0,0 +1,22 @@ +<?php $this->yellow->layout("header") ?> +<div class="content"> +<div class="main" role="main"> +<?php if ($this->yellow->page->get("blogWithFilter")): ?> +<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1> +<?php endif ?> +<?php $pages = $this->yellow->page->getPages("blog")->paginate($this->yellow->system->get("blogPaginationLimit")) ?> +<?php foreach ($pages as $page): ?> +<?php $page->set("entryClass", "entry") ?> +<?php if ($page->isExisting("tag")): ?> +<?php foreach (preg_split("/\s*,\s*/", $page->get("tag")) as $tag) { $page->set("entryClass", $page->get("entryClass")." tag-".$this->yellow->lookup->normaliseArguments($tag, false)); } ?> +<?php endif ?> +<div class="<?php echo $page->getHtml("entryClass") ?>"> +<div class="entry-title"><h1><a href="<?php echo $page->getLocation(true) ?>"><?php echo $page->getHtml("title") ?></a></h1></div> +<div class="entry-meta"><p><?php echo $page->getDateHtml("published") ?> <?php echo $this->yellow->language->getTextHtml("blogBy") ?> <?php $authorCounter = 0; foreach (preg_split("/\s*,\s*/", $page->get("author")) as $author) { if (++$authorCounter>1) echo ", "; echo "<a href=\"".$this->yellow->page->getLocation(true).$this->yellow->lookup->normaliseArguments("author:$author")."\">".htmlspecialchars($author)."</a>"; } ?></p></div> +<div class="entry-content"><?php echo $this->yellow->toolbox->createTextDescription($page->getContentHtml(), 0, false, "<!--more-->", "<a href=\"".$page->getLocation(true)."\">".$this->yellow->language->getTextHtml("blogMore")."</a>") ?></div> +</div> +<?php endforeach ?> +<?php $this->yellow->layout("pagination", $pages) ?> +</div> +</div> +<?php $this->yellow->layout("footer") ?> diff --git a/system/layouts/blog.html b/system/layouts/blog.html @@ -0,0 +1,23 @@ +<?php $this->yellow->layout("header") ?> +<div class="content"> +<div class="main" role="main"> +<?php $this->yellow->page->set("entryClass", "entry") ?> +<?php if ($this->yellow->page->isExisting("tag")): ?> +<?php foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("tag")) as $tag) { $this->yellow->page->set("entryClass", $this->yellow->page->get("entryClass")." tag-".$this->yellow->lookup->normaliseArguments($tag, false)); } ?> +<?php endif ?> +<div class="<?php echo $this->yellow->page->getHtml("entryClass") ?>"> +<div class="entry-title"><h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1></div> +<div class="entry-meta"><p><?php echo $this->yellow->page->getDateHtml("published") ?> <?php echo $this->yellow->language->getTextHtml("blogBy") ?> <?php $authorCounter = 0; foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("author")) as $author) { if (++$authorCounter>1) echo ", "; echo "<a href=\"".$this->yellow->page->getPage("blogStart")->getLocation(true).$this->yellow->lookup->normaliseArguments("author:$author")."\">".htmlspecialchars($author)."</a>"; } ?></p></div> +<div class="entry-content"><?php echo $this->yellow->page->getContentHtml() ?></div> +<?php echo $this->yellow->page->getExtraHtml("profile") ?> +<?php echo $this->yellow->page->getExtraHtml("link") ?> +<?php if ($this->yellow->page->isExisting("tag")): ?> +<div class="entry-tags"> +<p><?php echo $this->yellow->language->getTextHtml("blogTag") ?> <?php $tagCounter = 0; foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("tag")) as $tag) { if (++$tagCounter>1) echo ", "; echo "<a href=\"".$this->yellow->page->getPage("blogStart")->getLocation(true).$this->yellow->lookup->normaliseArguments("tag:$tag")."\">".htmlspecialchars($tag)."</a>"; } ?></p> +</div> +<?php endif ?> +<?php echo $this->yellow->page->getExtraHtml("comment") ?> +</div> +</div> +</div> +<?php $this->yellow->layout("footer") ?>