diff --git a/modules/list_page/list_page.cpp b/modules/list_page/list_page.cpp index a5b1dea..63e543d 100644 --- a/modules/list_page/list_page.cpp +++ b/modules/list_page/list_page.cpp @@ -124,21 +124,26 @@ void ListPage::render_entries(const Vector &list_entries) { } String ListPage::render_page(const int page_index, const int page_count, const Vector &list_entries, const int efrom, const int eto) { - String r = ""; + HTMLBuilder b; + + b.div(main_div_class); for (int i = efrom; i < eto; ++i) { - r += render_entry(list_entries[i]); + b.w(render_entry(list_entries[i])); } - r += Utils::get_pagination(get_full_uri(), page_count, page_index, max_visible_navigation_links); + b.w(Utils::get_pagination(get_full_uri(), page_count, page_index, max_visible_navigation_links)); + b.cdiv(); - return r; + return b.result; } String ListPage::render_entry(const String &list_entry) { HTMLBuilder b; - b.div("list_entry")->w(list_entry)->cdiv(); + b.div(main_div_class); + b.div(empty_div_class)->w(list_entry)->cdiv(); + b.cdiv(); return b.result; } @@ -146,7 +151,7 @@ String ListPage::render_entry(const String &list_entry) { void ListPage::render_no_entries_response() { HTMLBuilder b; - b.div("list_entry")->w("No conteny yet!")->cdiv(); + b.div(empty_div_class)->w(placeholder_text)->cdiv(); _no_entries_response = b.result; } @@ -169,6 +174,10 @@ ListPage::ListPage() : max_visible_navigation_links = 6; entry_per_page = 4; + main_div_class = "list_page"; + entry_div_class = "list_entry"; + empty_div_class = "list_entry_empty"; + placeholder_text = "No content yet!"; } ListPage::~ListPage() { diff --git a/modules/list_page/list_page.h b/modules/list_page/list_page.h index ebc3f22..4075bc3 100644 --- a/modules/list_page/list_page.h +++ b/modules/list_page/list_page.h @@ -8,6 +8,25 @@ #include "core/http/request.h" +// 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" + +// HTML (If there are entries): +// render_menu() +//
// Set the class via the main_div_class property +//
md file 1
// Set the class via the entry_div_class property +//
md file 2
+// ... +// +//
+ +// HTML (If there are no entries): +// render_menu() +//
// Set the class via the main_div_class property +//
No content yet!
// Set the class via the empty_div_class property, text via placeholder_text property +//
+ class ListPage : public WebNode { RCPP_OBJECT(ListPage, WebNode); @@ -31,6 +50,11 @@ public: int entry_per_page; String folder; + String main_div_class; + String entry_div_class; + String empty_div_class; + String placeholder_text; + protected: Vector _pages; String _no_entries_response;