While I would usually try and stick to the conventional commits standard this commit is a big one. This commit Bumps us to 0.0.2 And completely changes how you interact with the program. Now it is easier as you only need to specify the project directory on the commandline (OR be in the directory of the site you want to build) Also introduced is the cssitegen.json file that all projects must use. This means that static information such as the basename, source, and destination are kept with the files. ProjectSettings is used to hopefully make managing a site easier, although future refactoring may join the RuntimeSettings and ProjectSettings into one class. There are some obvious issues with the project in its current state but pending testing with a live domain, it does appear to actually work as intended. (if this is true then the code just needs refactoring and tidying to qualify for a 0.1.0 Release.) Future features planned include - Code to generate pages from data - Template nesting (or a custom template templating language) - Introduction of image conversion to webp (with fallback to RawCpy) - consistency enforcement, to ensure that deleted source files mean deleted destination files.
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Text.Json.Serialization;
|
|
// project settings is a user accessible config to set the Source and destination of a site
|
|
// This may include more scope in the future such as holding the site base address etc..
|
|
|
|
class ProjectSettings
|
|
{
|
|
private string _Source;
|
|
private string _Destination;
|
|
private DirectoryInfo? _ProjectRoot;
|
|
public string? BaseUrl {get; private set;}
|
|
|
|
public string Source {get {
|
|
if (_ProjectRoot is null)
|
|
{
|
|
return _Source;
|
|
}
|
|
return Path.Combine(_ProjectRoot.FullName,_Source);
|
|
}}
|
|
public string Destination {get {
|
|
if (_ProjectRoot is null)
|
|
{
|
|
return _Destination;
|
|
}
|
|
return Path.Combine(_ProjectRoot.FullName,_Destination);
|
|
}}
|
|
|
|
[JsonConstructor]
|
|
public ProjectSettings(String source, String destination, string baseUrl) {
|
|
_Source = source;
|
|
_Destination = destination;
|
|
BaseUrl = baseUrl;
|
|
}
|
|
|
|
public void setProjectRoot(string projectRoot) {
|
|
_ProjectRoot = new(projectRoot);
|
|
}
|
|
public void setProjectRoot(DirectoryInfo projectRoot) {
|
|
_ProjectRoot = projectRoot;
|
|
}
|
|
|
|
public void setBaseUrl(string baseUrl) {
|
|
BaseUrl = baseUrl;
|
|
}
|
|
}
|