39 rivejä
1.2 KiB
C
39 rivejä
1.2 KiB
C
|
#ifndef TEMPLATE_H
|
||
|
#define TEMPLATE_H
|
||
|
#include <functional>
|
||
|
#include <string_view>
|
||
|
#include "config.h"
|
||
|
#include "templatepage.h"
|
||
|
#include "utils.h"
|
||
|
#include "response.h"
|
||
|
#include "searchresult.h"
|
||
|
#include "revision.h"
|
||
|
class Template
|
||
|
{
|
||
|
private:
|
||
|
const Config *config;
|
||
|
std::map<std::string, TemplatePage> pagesMap;
|
||
|
std::string resolveIncludes(std::string_view content);
|
||
|
|
||
|
std::string getPartPath(std::string_view partname);
|
||
|
std::string loadResolvedPart(std::string_view partname);
|
||
|
std::string loadPartContent(std::string_view partname);
|
||
|
TemplatePage createPage(std::string name);
|
||
|
|
||
|
public:
|
||
|
Template(const Config &config);
|
||
|
/* TODO: returning this as a reference is by no means a risk free business,
|
||
|
because between requests, different vars can be set conditionally,
|
||
|
thus creating a mess
|
||
|
*/
|
||
|
TemplatePage &getPage(const std::string &pagename);
|
||
|
|
||
|
std::string renderSearch(const std::vector<std::string> &results,
|
||
|
std::function<std::string(std::string)> callback) const;
|
||
|
std::string renderSearch(const std::vector<std::string> &results) const;
|
||
|
std::string renderSearch(const std::vector<SearchResult> &results) const;
|
||
|
std::string renderRevisionList(const std::vector<Revision> &revisions, bool withpage = false) const;
|
||
|
};
|
||
|
|
||
|
#endif // TEMPLATE_H
|