chris-website/source/project.d

54 lines
1.6 KiB
D
Raw Normal View History

2020-06-24 08:08:28 +00:00
import std.array;
import std.algorithm;
import dyaml;
import vibe.vibe;
import page;
2020-06-24 13:53:18 +00:00
import staticpaths;
2020-06-24 08:08:28 +00:00
import utils;
/**
* Represents a project, like an unfinished application
*/
class Project : Page {
2020-06-24 13:53:18 +00:00
protected immutable string PROJECT_ICON_DIR = IMG_DIR ~ "projects/icons/";
protected immutable string PROJECT_IMAGE_DIR = IMG_DIR ~ "projects/images/";
2020-06-24 08:08:28 +00:00
protected string m_state;
protected string[] m_platforms;
protected string[] m_technologies;
protected string m_icon;
protected string[] m_images;
2020-06-24 13:53:18 +00:00
protected string m_description;
2020-06-24 22:23:02 +00:00
protected string m_sourceCode;
2020-06-24 08:08:28 +00:00
/**
* Creates a project from a file
*/
this(string file) {
super(file);
}
@safe
override protected void loadHeader(Node headerNode) {
super.loadHeader(headerNode);
this.m_state = headerNode.getOr!string("state", "unknown");
2020-06-24 13:53:18 +00:00
this.m_platforms = headerNode.getArray!string("platforms", []);
this.m_technologies = headerNode.getArray!string("technologies", []);
this.m_icon = PROJECT_ICON_DIR ~ headerNode.getOr!string("icon", "");
this.m_images = headerNode.getArray!string("images", [])
.map!(x => PROJECT_IMAGE_DIR ~ x).array;
this.m_description = headerNode.getOr!string("description", "<no description>");
2020-06-24 22:23:02 +00:00
this.m_sourceCode = headerNode.getOr!string("sourceCode", null);
2020-06-24 08:08:28 +00:00
}
@property string state() { return m_state; }
@property string[] platforms() { return m_platforms; }
@property string[] technologies() { return m_technologies; }
@property string icon() { return m_icon; }
@property string[] images() { return m_images; }
2020-06-24 13:53:18 +00:00
@property string description() { return m_description; }
2020-06-24 22:23:02 +00:00
@property string sourceCode() { return m_sourceCode; }
2020-06-24 08:08:28 +00:00
}