Add ability to hide posts
This commit is contained in:
parent
7ee1664698
commit
561bcdc366
|
@ -7,6 +7,8 @@ import std.stdio;
|
||||||
import dyaml;
|
import dyaml;
|
||||||
import vibe.vibe;
|
import vibe.vibe;
|
||||||
|
|
||||||
|
import utils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when a page has syntax errors e.g.
|
* Exception thrown when a page has syntax errors e.g.
|
||||||
|
@ -34,6 +36,8 @@ class Page {
|
||||||
protected string m_title;
|
protected string m_title;
|
||||||
protected string m_content;
|
protected string m_content;
|
||||||
protected string m_contentSource;
|
protected string m_contentSource;
|
||||||
|
protected bool m_hidden;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option for the markdown parser: the amount of levels the header found in the markdown should
|
* Option for the markdown parser: the amount of levels the header found in the markdown should
|
||||||
|
@ -71,6 +75,7 @@ class Page {
|
||||||
*/
|
*/
|
||||||
@safe
|
@safe
|
||||||
protected void loadHeader(Node headerNode){
|
protected void loadHeader(Node headerNode){
|
||||||
|
this.m_hidden = headerNode.getOr!bool("hidden", false);
|
||||||
if (headerNode.containsKey("title")) {
|
if (headerNode.containsKey("title")) {
|
||||||
this.m_title = headerNode["title"].as!string;
|
this.m_title = headerNode["title"].as!string;
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,4 +129,5 @@ class Page {
|
||||||
@property string slug() { return m_slug; }
|
@property string slug() { return m_slug; }
|
||||||
@property string content() { return m_content; }
|
@property string content() { return m_content; }
|
||||||
@property string contentSource() { return m_contentSource; }
|
@property string contentSource() { return m_contentSource; }
|
||||||
|
@property bool isHidden() { return m_hidden; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ void initPages(T, string sortPred)(ref T[string] array, ref T*[] sortedRange, co
|
||||||
|
|
||||||
void sortThings() {
|
void sortThings() {
|
||||||
sortedRange = sort!(sortPred)(array.values)
|
sortedRange = sort!(sortPred)(array.values)
|
||||||
|
.filter!(x => !x.isHidden)
|
||||||
.map!"&a".array;
|
.map!"&a".array;
|
||||||
logf("sorted: %s", sortedRange);
|
logf("sorted: %s", sortedRange);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue