2022-10-03 07:46:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Directory.h"
|
|
|
|
#include "ContentFile.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class GeneratorConfig
|
|
|
|
{
|
2022-10-11 19:20:12 +00:00
|
|
|
public:
|
2022-10-09 16:39:46 +00:00
|
|
|
void setThemePath(const Path& path)
|
2022-10-03 07:46:41 +00:00
|
|
|
{
|
2022-10-09 16:39:46 +00:00
|
|
|
mThemesPath = path;
|
2022-10-03 07:46:41 +00:00
|
|
|
}
|
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void setActiveTheme(const std::string& theme)
|
2022-10-03 07:46:41 +00:00
|
|
|
{
|
2022-10-09 16:39:46 +00:00
|
|
|
mActiveTheme = theme;
|
2022-10-03 07:46:41 +00:00
|
|
|
}
|
|
|
|
|
2022-10-11 19:20:12 +00:00
|
|
|
Path getThemePath() const
|
|
|
|
{
|
|
|
|
return mThemesPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getActiveTheme() const
|
|
|
|
{
|
|
|
|
return mActiveTheme;
|
|
|
|
}
|
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
private:
|
|
|
|
Path mThemesPath;
|
|
|
|
std::string mActiveTheme;
|
|
|
|
};
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-11 19:20:12 +00:00
|
|
|
class TemplateFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TemplateFile(const Path& path)
|
|
|
|
: mPath(path)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2022-11-10 09:06:02 +00:00
|
|
|
|
2022-10-11 19:20:12 +00:00
|
|
|
private:
|
|
|
|
Path mPath;
|
|
|
|
};
|
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
class WebsiteGenerator
|
|
|
|
{
|
|
|
|
public:
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void findProject(const std::string& searchPath);
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void readConfig();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void parseContentFiles();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void parseTemplateFiles();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void doSubstitutions();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void write();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
void findContentFiles();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
Path getContentPath() const;
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
Path getPagesPath() const;
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
Path getArticlesPath() const;
|
|
|
|
|
|
|
|
Path getConfigPath() const;
|
2022-10-03 07:46:41 +00:00
|
|
|
|
|
|
|
std::filesystem::path mProjectPath;
|
|
|
|
GeneratorConfig mConfig;
|
|
|
|
std::vector<ContentPage> mPages;
|
|
|
|
std::vector<ContentArticle> mArticles;
|
2022-11-10 09:06:02 +00:00
|
|
|
std::unordered_map<std::string, std::unique_ptr<TemplateFile> > mTemplateFiles;
|
2022-10-03 07:46:41 +00:00
|
|
|
};
|