Added the new virtuals to the rest of the webnodes that benefit from it.

This commit is contained in:
Relintai 2022-02-14 23:25:01 +01:00
parent 642c39552f
commit 001339fc60
5 changed files with 31 additions and 7 deletions

View File

@ -23,6 +23,18 @@ void BrowsableFolderServeNode::_handle_request_main(Request *request) {
request->compile_and_send_body();
}
void BrowsableFolderServeNode::render(Request *request) {
String *s = _folder_indexes["/"];
if (!s) {
return;
}
request->body += (*s);
}
void BrowsableFolderServeNode::render_preview(Request *request) {
}
void BrowsableFolderServeNode::load() {
if (serve_folder == "") {
return;

View File

@ -12,6 +12,9 @@ class BrowsableFolderServeNode : public FolderServeNode {
public:
void _handle_request_main(Request *request);
void render(Request *request);
void render_preview(Request *request);
virtual void load();
void evaluate_dir(const String &path, const bool top_level = false);
@ -23,7 +26,7 @@ public:
~BrowsableFolderServeNode();
protected:
std::map<String, String*> _folder_indexes;
std::map<String, String *> _folder_indexes;
};
#endif

View File

@ -3,8 +3,8 @@
#include "core/string.h"
#include "web/http/web_node.h"
#include "web/file_cache.h"
#include "web/http/web_node.h"
class FolderServeNode : public WebNode {
RCPP_OBJECT(FolderServeNode, WebNode);

View File

@ -26,7 +26,7 @@ void ListPage::handle_request_main(Request *request) {
if (cs == "") {
render_menu(request);
request->body += _pages[0];
render(request);
request->compile_and_send_body();
return;
}
@ -50,6 +50,12 @@ void ListPage::handle_request_main(Request *request) {
request->compile_and_send_body();
}
void ListPage::render(Request *request) {
request->body += _pages[0];
}
void ListPage::render_preview(Request *request) {
}
void ListPage::load() {
if (folder == "") {
RLOG_ERR("Error: ListPage::load called, but a folder is not set!");

View File

@ -8,7 +8,7 @@
#include "web/http/request.h"
// This class will load and generate pages from a folder of md files. It supports pagination,
// This class will load and generate pages from a folder of md files. It supports pagination,
// it will put entry_per_page md files per page. It generates html on enter tree, and caches everything.
// Each md file gets rendered into a div with a class of "list_entry"
@ -33,20 +33,23 @@ class ListPage : public WebNode {
public:
void handle_request_main(Request *request);
void render(Request *request);
void render_preview(Request *request);
void load();
virtual void render_entries(const Vector<String> &list_entries);
virtual String render_page(const int page_index, const int page_count, const Vector<String> &list_entries, const int efrom, const int eto);
virtual String render_page(const int page_index, const int page_count, const Vector<String> &list_entries, const int efrom, const int eto);
virtual String render_entry(const String &list_entry);
virtual void render_no_entries_response();
void _notification(const int what);
void _notification(const int what);
ListPage();
~ListPage();
bool paginate;
int max_visible_navigation_links;
int max_visible_navigation_links;
int entry_per_page;
String folder;