stuff-from-scratch/apps/website-generator/WebsiteGenerator.h
2022-10-11 20:20:12 +01:00

84 lines
1.3 KiB
C++

#pragma once
#include "Directory.h"
#include "ContentFile.h"
#include <string>
#include <iostream>
#include <filesystem>
#include <vector>
class GeneratorConfig
{
public:
void setThemePath(const Path& path)
{
mThemesPath = path;
}
void setActiveTheme(const std::string& theme)
{
mActiveTheme = theme;
}
Path getThemePath() const
{
return mThemesPath;
}
std::string getActiveTheme() const
{
return mActiveTheme;
}
private:
Path mThemesPath;
std::string mActiveTheme;
};
class TemplateFile
{
public:
TemplateFile(const Path& path)
: mPath(path)
{
}
private:
Path mPath;
};
class WebsiteGenerator
{
public:
void findProject(const std::string& searchPath);
void readConfig();
void parseContentFiles();
void parseTemplateFiles();
void doSubstitutions();
void write();
private:
void findContentFiles();
Path getContentPath() const;
Path getPagesPath() const;
Path getArticlesPath() const;
Path getConfigPath() const;
std::filesystem::path mProjectPath;
GeneratorConfig mConfig;
std::vector<ContentPage> mPages;
std::vector<ContentArticle> mArticles;
std::unordered_map<std::string, TemplateFile> mTemplateFiles;
};