2022-10-03 07:46:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "MarkdownContentParser.h"
|
2022-10-04 07:20:39 +00:00
|
|
|
#include "File.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <unordered_map>
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
class MarkdownDocument;
|
|
|
|
|
2022-10-03 07:46:41 +00:00
|
|
|
class ContentFile
|
|
|
|
{
|
|
|
|
public:
|
2022-10-04 07:20:39 +00:00
|
|
|
using FileMetadata = std::unordered_map<std::string, std::string>;
|
|
|
|
using FileContentBody = std::vector<std::string>;
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
ContentFile(const Path& filename);
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
virtual ~ContentFile();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
Path getFilename() const;
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
virtual void load();
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
std::string getMetadataItem(const std::string& key) const;
|
2022-10-04 07:20:39 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
virtual std::string getOutputLocation() const;
|
2022-10-04 07:20:39 +00:00
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
MarkdownDocument* getContentBody() const
|
2022-10-04 07:20:39 +00:00
|
|
|
{
|
2022-12-05 13:16:10 +00:00
|
|
|
return mContentBody.get();
|
2022-10-04 07:20:39 +00:00
|
|
|
}
|
2022-10-03 07:46:41 +00:00
|
|
|
|
2022-12-05 17:50:49 +00:00
|
|
|
void doLinkTagSubstitution(const Path& basePath);
|
|
|
|
|
2022-12-05 13:16:10 +00:00
|
|
|
void write(const Path& path);
|
2022-12-05 17:50:49 +00:00
|
|
|
|
|
|
|
void setProcessedOutput(const std::string& output)
|
|
|
|
{
|
|
|
|
mProcessedOutput = output;
|
|
|
|
}
|
2022-10-03 07:46:41 +00:00
|
|
|
protected:
|
2022-10-09 16:39:46 +00:00
|
|
|
Path mFilename;
|
2022-10-04 07:20:39 +00:00
|
|
|
FileMetadata mMetadata;
|
2022-12-05 13:16:10 +00:00
|
|
|
std::unique_ptr<MarkdownDocument> mContentBody;
|
|
|
|
std::string mProcessedOutput;
|
2022-10-03 07:46:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ContentArticle : public ContentFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2022-10-09 16:39:46 +00:00
|
|
|
ContentArticle(const Path& filename)
|
2022-10-03 07:46:41 +00:00
|
|
|
: ContentFile(filename)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void load() override
|
|
|
|
{
|
2022-10-04 07:20:39 +00:00
|
|
|
ContentFile::load();
|
2022-10-03 07:46:41 +00:00
|
|
|
}
|
|
|
|
};
|