2022-10-09 16:39:46 +00:00
|
|
|
#include "WebsiteGenerator.h"
|
|
|
|
|
|
|
|
void WebsiteGenerator::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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Path WebsiteGenerator::getConfigPath() const
|
|
|
|
{
|
|
|
|
return mProjectPath / "config";
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::readConfig()
|
|
|
|
{
|
|
|
|
const auto lines = File(getConfigPath()).readLines();
|
|
|
|
|
|
|
|
enum class LineState
|
|
|
|
{
|
|
|
|
UNSET,
|
|
|
|
IN_SECTION_TAG,
|
|
|
|
BEFORE_EQUALS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& lines : lines)
|
|
|
|
{
|
|
|
|
auto line_state =
|
|
|
|
//if ()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::parseContentFiles()
|
|
|
|
{
|
|
|
|
findContentFiles();
|
|
|
|
|
|
|
|
for (auto& page : mPages)
|
|
|
|
{
|
|
|
|
page.load();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::parseTemplateFiles()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::doSubstitutions()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::write()
|
|
|
|
{
|
|
|
|
// Setup output dir
|
|
|
|
const auto output_dir = mProjectPath / "output_custom";
|
|
|
|
std::filesystem::create_directory(output_dir);
|
|
|
|
|
|
|
|
// Write each page
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebsiteGenerator::findContentFiles()
|
|
|
|
{
|
|
|
|
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 WebsiteGenerator::getContentPath() const
|
|
|
|
{
|
|
|
|
return mProjectPath / "content";
|
|
|
|
}
|
|
|
|
|
|
|
|
Path WebsiteGenerator::getPagesPath() const
|
|
|
|
{
|
|
|
|
return getContentPath() / "pages";
|
|
|
|
}
|
|
|
|
|
|
|
|
Path WebsiteGenerator::getArticlesPath() const
|
|
|
|
{
|
|
|
|
return getContentPath() / "articles";
|
|
|
|
}
|