Prepare article metadata parsing in WebsiteBuilder
Added changes to WebsiteBuilder that implements the metadata parsing function in the Article namespace.
This commit is contained in:
parent
0624e9bb60
commit
61a0513ad0
|
@ -33,6 +33,7 @@
|
||||||
// #include "Blog.h"
|
// #include "Blog.h"
|
||||||
#include "Common.hxx"
|
#include "Common.hxx"
|
||||||
#include "MarkdownParser.hxx"
|
#include "MarkdownParser.hxx"
|
||||||
|
#include "Article.hxx"
|
||||||
|
|
||||||
std::string blog_relative_path(std::string const &pathPrefix, std::string const &path) {
|
std::string blog_relative_path(std::string const &pathPrefix, std::string const &path) {
|
||||||
return path.substr(pathPrefix.length() - 1);
|
return path.substr(pathPrefix.length() - 1);
|
||||||
|
@ -136,6 +137,8 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
|
||||||
exit(RETURN_FAILED_UNKNOWN_ERROR);
|
exit(RETURN_FAILED_UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<Article::Metadata*> am;
|
||||||
|
|
||||||
for (std::string const &a : articles) {
|
for (std::string const &a : articles) {
|
||||||
std::string articlePath = blog_relative_path(prefix, a);
|
std::string articlePath = blog_relative_path(prefix, a);
|
||||||
std::regex yearMonth("(\\d+)");
|
std::regex yearMonth("(\\d+)");
|
||||||
|
@ -144,6 +147,12 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
|
||||||
std::string year = match->str(),
|
std::string year = match->str(),
|
||||||
month = (++match)->str();
|
month = (++match)->str();
|
||||||
|
|
||||||
|
// Go ahead and parse article metadata.
|
||||||
|
Article::Metadata *articleMetadata = (Article::Metadata*) malloc(sizeof(Article::Metadata));
|
||||||
|
Article::get_metadata(a, articleMetadata);
|
||||||
|
std::cout << "Parsed metadata for article \"" << articleMetadata->title << "\"\n";
|
||||||
|
am.push_back(articleMetadata);
|
||||||
|
|
||||||
// TODO: This code could be optimized by removing directory
|
// TODO: This code could be optimized by removing directory
|
||||||
// checks for every single article. Instead, add
|
// checks for every single article. Instead, add
|
||||||
// directory-checks for years and months to a queue (skipping
|
// directory-checks for years and months to a queue (skipping
|
||||||
|
|
Loading…
Reference in New Issue