2020-12-28 23:17:30 +01:00
|
|
|
#ifndef PAGED_ARTICLE_H
|
|
|
|
#define PAGED_ARTICLE_H
|
|
|
|
|
|
|
|
#include <map>
|
2021-11-01 19:53:35 +01:00
|
|
|
#include "core/containers/vector.h"
|
|
|
|
#include "core/string.h"
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2021-01-06 03:57:18 +01:00
|
|
|
#include "core/file_cache.h"
|
2020-12-28 23:17:30 +01:00
|
|
|
#include "core/object.h"
|
|
|
|
|
2021-05-27 17:37:23 +02:00
|
|
|
#include "core/http/request.h"
|
2020-12-28 23:17:30 +01:00
|
|
|
|
|
|
|
struct Article {
|
2021-11-01 19:53:35 +01:00
|
|
|
String url;
|
|
|
|
String summary_page;
|
|
|
|
std::map<String, String *> pages;
|
2021-01-06 03:57:18 +01:00
|
|
|
FileCache *file_cache;
|
2020-12-28 23:17:30 +01:00
|
|
|
|
2021-01-06 03:57:18 +01:00
|
|
|
Article() {
|
|
|
|
file_cache = new FileCache();
|
|
|
|
}
|
2020-12-28 23:17:30 +01:00
|
|
|
~Article() {
|
2021-11-01 19:53:35 +01:00
|
|
|
for (std::map<String, String *>::iterator it = pages.begin(); it != pages.end(); ++it) {
|
2020-12-28 23:17:30 +01:00
|
|
|
delete ((*it).second);
|
|
|
|
}
|
|
|
|
|
|
|
|
pages.clear();
|
2021-01-06 03:57:18 +01:00
|
|
|
|
|
|
|
delete file_cache;
|
2020-12-28 23:17:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PagedArticle : public Object {
|
|
|
|
RCPP_OBJECT(PagedArticle, Object);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void index(Request *request);
|
|
|
|
|
|
|
|
void load();
|
2021-11-01 19:53:35 +01:00
|
|
|
Article *load_folder(const String &folder, const String &path);
|
2020-12-28 23:17:30 +01:00
|
|
|
void generate_summaries();
|
|
|
|
void generate_summary(Article *article);
|
|
|
|
|
|
|
|
PagedArticle();
|
|
|
|
~PagedArticle();
|
|
|
|
|
2021-11-01 19:53:35 +01:00
|
|
|
std::map<String, Article *> pages;
|
|
|
|
String folder;
|
|
|
|
String base_path;
|
2020-12-28 23:17:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|