stuff-from-scratch/apps/website-generator/ContentFile.h

65 lines
1.1 KiB
C
Raw Normal View History

2022-10-03 07:46:41 +00:00
#pragma once
#include "MarkdownContentParser.h"
2022-10-04 07:20:39 +00:00
#include "File.h"
2023-12-21 09:18:44 +00:00
#include "String.h"
2022-10-04 07:20:39 +00:00
#include <iostream>
2023-12-27 12:20:02 +00:00
#include Map.h
2022-10-03 07:46:41 +00:00
class MarkdownDocument;
2022-10-03 07:46:41 +00:00
class ContentFile
{
public:
2023-12-27 12:20:02 +00:00
using FileMetadata = Map<String, String>;
2023-12-21 09:18:44 +00:00
using FileContentBody = Vector<String>;
2022-10-03 07:46:41 +00:00
ContentFile(const Path& filename);
2022-10-03 07:46:41 +00:00
virtual ~ContentFile();
2022-10-03 07:46:41 +00:00
Path getFilename() const;
2022-10-03 07:46:41 +00:00
virtual void load();
2022-10-03 07:46:41 +00:00
2023-12-21 09:18:44 +00:00
String getMetadataItem(const String& key) const;
2022-10-04 07:20:39 +00:00
2023-12-21 09:18:44 +00:00
virtual String getOutputLocation() const;
2022-10-04 07:20:39 +00:00
MarkdownDocument* getContentBody() const
2022-10-04 07:20:39 +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);
void write(const Path& path);
2022-12-05 17:50:49 +00:00
2023-12-21 09:18:44 +00:00
void setProcessedOutput(const String& output)
2022-12-05 17:50:49 +00:00
{
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;
2023-12-21 09:18:44 +00:00
Ptr<MarkdownDocument> mContentBody;
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
}
};