From 561bcdc366d9fa3d384e506b040869856c1a5ffc Mon Sep 17 00:00:00 2001 From: Henk Kalkwater Date: Sat, 27 Jun 2020 16:48:26 +0200 Subject: [PATCH] Add ability to hide posts --- source/page.d | 6 ++++++ source/watcher.d | 1 + 2 files changed, 7 insertions(+) diff --git a/source/page.d b/source/page.d index 99bc9eb..49e605f 100644 --- a/source/page.d +++ b/source/page.d @@ -7,6 +7,8 @@ import std.stdio; import dyaml; import vibe.vibe; +import utils; + /** * Exception thrown when a page has syntax errors e.g. @@ -34,6 +36,8 @@ class Page { protected string m_title; protected string m_content; protected string m_contentSource; + protected bool m_hidden; + /** * Option for the markdown parser: the amount of levels the header found in the markdown should @@ -71,6 +75,7 @@ class Page { */ @safe protected void loadHeader(Node headerNode){ + this.m_hidden = headerNode.getOr!bool("hidden", false); if (headerNode.containsKey("title")) { this.m_title = headerNode["title"].as!string; } else { @@ -124,4 +129,5 @@ class Page { @property string slug() { return m_slug; } @property string content() { return m_content; } @property string contentSource() { return m_contentSource; } + @property bool isHidden() { return m_hidden; } } diff --git a/source/watcher.d b/source/watcher.d index 1bb9263..88ea9ef 100644 --- a/source/watcher.d +++ b/source/watcher.d @@ -37,6 +37,7 @@ void initPages(T, string sortPred)(ref T[string] array, ref T*[] sortedRange, co void sortThings() { sortedRange = sort!(sortPred)(array.values) + .filter!(x => !x.isHidden) .map!"&a".array; logf("sorted: %s", sortedRange); }