129 lines
2.4 KiB
C++
129 lines
2.4 KiB
C++
#include "CommandLineArgs.h"
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <filesystem>
|
|
|
|
class GeneratorConfig
|
|
{
|
|
|
|
};
|
|
|
|
class ContentPage
|
|
{
|
|
public:
|
|
|
|
ContentPage(const std::string& filename)
|
|
: mFilename(filename)
|
|
{
|
|
|
|
}
|
|
|
|
std::string getFilename() const
|
|
{
|
|
return mFilename;
|
|
}
|
|
|
|
private:
|
|
|
|
std::string mFilename;
|
|
};
|
|
|
|
|
|
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()
|
|
{
|
|
const auto content_dir = mProjectPath / "content";
|
|
if (std::filesystem::is_directory(content_dir))
|
|
{
|
|
std::cout << "checking " << content_dir << std::endl;
|
|
const auto pages_dir = content_dir / "pages";
|
|
if (std::filesystem::is_directory(pages_dir))
|
|
{
|
|
std::cout << "checking " << pages_dir << std::endl;
|
|
for (const auto& entry : std::filesystem::directory_iterator(pages_dir))
|
|
{
|
|
if (std::filesystem::is_regular_file(entry) && entry.path().extension() == ".md")
|
|
{
|
|
mPages.push_back(ContentPage(entry.path()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
std::cout << "nope in " << content_dir << std::endl;
|
|
}
|
|
|
|
for(const auto& page : mPages)
|
|
{
|
|
std::cout << "Got page " << page.getFilename() << std::endl;
|
|
}
|
|
|
|
}
|
|
|
|
void parseTemplateFiles()
|
|
{
|
|
|
|
}
|
|
|
|
void doSubstitutions()
|
|
{
|
|
|
|
}
|
|
|
|
void write()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
|
std::filesystem::path mProjectPath;
|
|
GeneratorConfig mConfig;
|
|
std::vector<ContentPage> mPages;
|
|
};
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
auto args = CommandLineArgs::Create();
|
|
args->process(argc, argv);
|
|
args->recordLaunchPath();
|
|
|
|
WebsiteGenerator generator;
|
|
generator.findProject(args->getArg(1));
|
|
|
|
generator.readConfig();
|
|
|
|
// Find and process project files
|
|
generator.parseContentFiles();
|
|
|
|
// Find template files
|
|
|
|
// Substitute template files
|
|
|
|
|
|
|
|
return 0;
|
|
}
|