aboutsummaryrefslogtreecommitdiff
path: root/src/content/markdown/Markdown.hpp
blob: 04b351cdfb7b03999708efc462b5b44a33cc8ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef MARKDOWN_H
#define MARKDOWN_H 1

#include "../../Content.hpp"
#include "../../Filesystem.hpp"

using Markdowns = std::unordered_map<std::string, std::shared_ptr<std::string> >;

class Markdown : public Content
{
public:
    explicit Markdown(std::string uriBasePath, std::string markdownFilesPath, std::string mainTemplatePath = "");

    bool Init(std::string const & uriBasePath);
    bool Init() override;
    void Shutdown() override;
    bool Render(RequestResponse & rr, RenderData & rd, std::string & out) override;

    std::string & GetUriBasePath() override;
    std::string const & GetMainTemplate() const override;
    Redirections & GetRedirections() override;

    bool HasMarkdownFile(std::string filePath) const;
    bool HasMarkdownURI(std::string uriPath) const;
    Markdowns & GetMarkdowns();
    std::shared_ptr<std::string> const & GetMarkdownHTML(std::string uriPath);

private:
    std::string m_UriBasePath;
    std::string m_MainTemplatePath;
    std::string m_MarkdownFilesPath;
    Redirections m_Redirections;
    Markdowns m_Markdowns;
};

#endif