Break web generator to own cmake.
This commit is contained in:
parent
bd60a28eef
commit
ebd41bf4ee
14 changed files with 121 additions and 45 deletions
|
@ -29,12 +29,5 @@ target_link_libraries(sample_console PUBLIC console core network
|
|||
set_property(TARGET sample_console PROPERTY FOLDER apps)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
|
||||
# Website Generator
|
||||
add_executable(website_generator website-generator.cpp)
|
||||
#target_include_directories(website_generator PUBLIC
|
||||
# "${PROJECT_SOURCE_DIR}/src/console"
|
||||
# )
|
||||
target_link_libraries(website_generator PUBLIC core web)
|
||||
|
||||
set_property(TARGET website_generator PROPERTY FOLDER apps)
|
||||
add_subdirectory(website-generator)
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
auto command_line_args = CommandLineArgs::CreateUnique();
|
||||
command_line_args->Process(argc, argv);
|
||||
command_line_args->RecordLaunchPath();
|
||||
auto command_line_args = CommandLineArgs::Create();
|
||||
command_line_args->process(argc, argv);
|
||||
command_line_args->recordLaunchPath();
|
||||
|
||||
// Start the main app
|
||||
auto main_app = MainApplication::Create();
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
auto args = CommandLineArgs::CreateUnique();
|
||||
args->Process(argc, argv);
|
||||
args->RecordLaunchPath();
|
||||
auto args = CommandLineArgs::Create();
|
||||
args->process(argc, argv);
|
||||
args->recordLaunchPath();
|
||||
|
||||
// Start the main app
|
||||
auto main_app = MainApplication::Create();
|
||||
|
|
18
apps/website-generator/CMakeLists.txt
Normal file
18
apps/website-generator/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
list(APPEND website_generator_LIB_INCLUDES
|
||||
ContentFile.h
|
||||
ContentFile.cpp
|
||||
MarkdownContentParser.h
|
||||
MarkdownContentParser.cpp)
|
||||
|
||||
|
||||
add_executable(website_generator main.cpp ${website_generator_LIB_INCLUDES})
|
||||
|
||||
target_include_directories(website_generator PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
target_link_libraries(website_generator PUBLIC core web)
|
||||
|
||||
set_property(TARGET website_generator PROPERTY FOLDER apps/website-generator)
|
||||
|
0
apps/website-generator/ContentFile.cpp
Normal file
0
apps/website-generator/ContentFile.cpp
Normal file
0
apps/website-generator/ContentFile.h
Normal file
0
apps/website-generator/ContentFile.h
Normal file
0
apps/website-generator/MarkdownContentParser.cpp
Normal file
0
apps/website-generator/MarkdownContentParser.cpp
Normal file
0
apps/website-generator/MarkdownContentParser.h
Normal file
0
apps/website-generator/MarkdownContentParser.h
Normal file
|
@ -1,5 +1,7 @@
|
|||
#include "CommandLineArgs.h"
|
||||
|
||||
#include "Directory.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
@ -10,11 +12,11 @@ class GeneratorConfig
|
|||
|
||||
};
|
||||
|
||||
class ContentPage
|
||||
class ContentFile
|
||||
{
|
||||
public:
|
||||
|
||||
ContentPage(const std::string& filename)
|
||||
ContentFile(const std::string& filename)
|
||||
: mFilename(filename)
|
||||
{
|
||||
|
||||
|
@ -25,11 +27,32 @@ public:
|
|||
return mFilename;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
std::string mFilename;
|
||||
};
|
||||
|
||||
class ContentPage : public ContentFile
|
||||
{
|
||||
public:
|
||||
|
||||
ContentPage(const std::string& filename)
|
||||
: ContentFile(filename)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class ContentArticle : public ContentFile
|
||||
{
|
||||
public:
|
||||
|
||||
ContentArticle(const std::string& filename)
|
||||
: ContentFile(filename)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class WebsiteGenerator
|
||||
{
|
||||
|
@ -52,26 +75,16 @@ public:
|
|||
|
||||
void parseContentFiles()
|
||||
{
|
||||
const auto content_dir = mProjectPath / "content";
|
||||
if (std::filesystem::is_directory(content_dir))
|
||||
const auto pages_files = Directory::getFilesWithExtension(getPagesPath(), ".md");
|
||||
for (const auto& path : pages_files)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
mPages.push_back(ContentPage(path));
|
||||
}
|
||||
else
|
||||
|
||||
const auto article_files = Directory::getFilesWithExtension(getArticlesPath(), ".md");
|
||||
for (const auto& path : article_files)
|
||||
{
|
||||
std::cout << "nope in " << content_dir << std::endl;
|
||||
mArticles.push_back(ContentArticle(path));
|
||||
}
|
||||
|
||||
for(const auto& page : mPages)
|
||||
|
@ -79,6 +92,10 @@ public:
|
|||
std::cout << "Got page " << page.getFilename() << std::endl;
|
||||
}
|
||||
|
||||
for(const auto& article : mArticles)
|
||||
{
|
||||
std::cout << "Got article " << article.getFilename() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void parseTemplateFiles()
|
||||
|
@ -99,9 +116,25 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue