stuff-from-scratch/apps/website-generator/WebsiteGenerator.h

62 lines
955 B
C
Raw Normal View History

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-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-09 16:39:46 +00:00
private:
Path mThemesPath;
std::string mActiveTheme;
};
2022-10-03 07:46:41 +00:00
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;
};