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
|
|
|
|
{
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class WebsiteGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void findProject(const std::string& searchPath)
|
|
|
|
{
|
|
|
|
const auto config_path = std::filesystem::path(searchPath) / "config.toml";
|
|
|
|
if (std::filesystem::exists(config_path))
|
|
|
|
{
|
|
|
|
mProjectPath = searchPath;
|
|
|
|
std::cout << "Found config.toml in " << searchPath << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void readConfig()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void parseContentFiles()
|
|
|
|
{
|
|
|
|
findContentFiles();
|
|
|
|
|
2022-10-04 07:20:39 +00:00
|
|
|
for (auto& page : mPages)
|
2022-10-03 07:46:41 +00:00
|
|
|
{
|
|
|
|
page.load();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void parseTemplateFiles()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void doSubstitutions()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void write()
|
|
|
|
{
|
2022-10-04 07:20:39 +00:00
|
|
|
// Setup output dir
|
|
|
|
const auto output_dir = mProjectPath / "output_custom";
|
|
|
|
std::filesystem::create_directory(output_dir);
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-10-04 07:20:39 +00:00
|
|
|
// Write each page
|
2022-10-03 07:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-10-04 07:20:39 +00:00
|
|
|
void findContentFiles()
|
2022-10-03 07:46:41 +00:00
|
|
|
{
|
|
|
|
const auto pages_files = Directory::getFilesWithExtension(getPagesPath(), ".md");
|
|
|
|
for (const auto& path : pages_files)
|
|
|
|
{
|
|
|
|
mPages.push_back(ContentPage(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto article_files = Directory::getFilesWithExtension(getArticlesPath(), ".md");
|
|
|
|
for (const auto& path : article_files)
|
|
|
|
{
|
|
|
|
mArticles.push_back(ContentArticle(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Path getContentPath() const
|
|
|
|
{
|
|
|
|
return mProjectPath / "content";
|
|
|
|
}
|
|
|
|
|
|
|
|
Path getPagesPath() const
|
|
|
|
{
|
|
|
|
return getContentPath() / "pages";
|
|
|
|
}
|
|
|
|
|
|
|
|
Path getArticlesPath() const
|
|
|
|
{
|
|
|
|
return getContentPath() / "articles";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::filesystem::path mProjectPath;
|
|
|
|
GeneratorConfig mConfig;
|
|
|
|
std::vector<ContentPage> mPages;
|
|
|
|
std::vector<ContentArticle> mArticles;
|
|
|
|
};
|