2020-12-28 23:17:30 +01:00
|
|
|
#ifndef PAGED_ARTICLE_H
|
|
|
|
#define PAGED_ARTICLE_H
|
|
|
|
|
2021-11-01 19:53:35 +01:00
|
|
|
#include "core/containers/vector.h"
|
|
|
|
#include "core/string.h"
|
2022-02-14 23:20:47 +01:00
|
|
|
#include <map>
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2022-02-05 16:55:07 +01:00
|
|
|
#include "web/file_cache.h"
|
2022-02-05 15:30:48 +01:00
|
|
|
#include "web/http/web_node.h"
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2022-02-05 15:30:48 +01:00
|
|
|
#include "web/http/request.h"
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2022-02-15 00:00:50 +01:00
|
|
|
// This class will load and process all md files from the folder set to it's articles_folder property,
|
|
|
|
// and serve every file from the directory set to it's serve_folder property.
|
|
|
|
// if it finds a summary.md, it will serve it as the root.
|
|
|
|
// It uses pagination.
|
|
|
|
// THe links is generates currently look like: <url>/01_test.md
|
|
|
|
// files are served under <url>/files/<file>
|
|
|
|
|
2022-01-08 12:53:50 +01:00
|
|
|
class PagedArticle : public WebNode {
|
|
|
|
RCPP_OBJECT(PagedArticle, WebNode);
|
2020-12-28 23:17:30 +01:00
|
|
|
|
|
|
|
public:
|
2022-01-08 12:53:50 +01:00
|
|
|
void handle_request_main(Request *request);
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2022-02-14 23:27:26 +01:00
|
|
|
void render_index(Request *request);
|
2022-02-14 23:20:47 +01:00
|
|
|
void render_preview(Request *request);
|
|
|
|
|
2020-12-28 23:17:30 +01:00
|
|
|
void load();
|
2022-02-04 22:05:51 +01:00
|
|
|
void load_folder(const String &folder, const String &path);
|
2022-02-05 13:19:34 +01:00
|
|
|
String get_index_page();
|
2022-02-05 13:27:05 +01:00
|
|
|
String get_summary();
|
|
|
|
|
|
|
|
virtual void generate_summary();
|
2022-02-05 02:45:11 +01:00
|
|
|
|
|
|
|
void _notification(const int what);
|
2020-12-28 23:17:30 +01:00
|
|
|
|
|
|
|
PagedArticle();
|
|
|
|
~PagedArticle();
|
|
|
|
|
2022-02-04 22:05:51 +01:00
|
|
|
String articles_folder;
|
2022-02-04 23:39:45 +01:00
|
|
|
bool serve_folder_relative;
|
2022-02-04 22:05:51 +01:00
|
|
|
String serve_folder;
|
|
|
|
|
|
|
|
protected:
|
2022-02-05 13:19:34 +01:00
|
|
|
String index_page;
|
2022-02-05 13:27:05 +01:00
|
|
|
String summary;
|
2022-02-04 22:05:51 +01:00
|
|
|
std::map<String, String *> pages;
|
|
|
|
FileCache *file_cache;
|
2020-12-28 23:17:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|