From b337b8f7de8e1fbe9775e30144c33c6d07a8346e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 6 Feb 2022 11:12:57 +0100 Subject: [PATCH] Added up directory links to the BrowsableFolderServeNode. --- .../browsable_folder_serve_node.cpp | 14 +++++++++++--- .../browsable_folder_serve_node.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web_modules/folder_serve_nodes/browsable_folder_serve_node.cpp b/web_modules/folder_serve_nodes/browsable_folder_serve_node.cpp index 2fdc333..fd23e20 100644 --- a/web_modules/folder_serve_nodes/browsable_folder_serve_node.cpp +++ b/web_modules/folder_serve_nodes/browsable_folder_serve_node.cpp @@ -68,16 +68,24 @@ void BrowsableFolderServeNode::evaluate_dir(const String &path, const bool top_l folders.sort_inc(); files.sort_inc(); - render_dir_page(dir_uri, folders, files); + render_dir_page(dir_uri, folders, files, top_level); } -void BrowsableFolderServeNode::render_dir_page(const String &dir_uri, const Vector &folders, const Vector &files) { +void BrowsableFolderServeNode::render_dir_page(const String &dir_uri, const Vector &folders, const Vector &files, const bool top_level) { HTMLBuilder b; String uri = get_full_uri(false); b.div("file_list"); { + if (!top_level) { + b.div("file_list_entry"); + { + b.a(uri + dir_uri.path_get_prev_dir())->w("..")->ca(); + } + b.cdiv(); + } + for (int i = 0; i < folders.size(); ++i) { b.div("file_list_entry"); { @@ -109,7 +117,7 @@ BrowsableFolderServeNode::BrowsableFolderServeNode() : } BrowsableFolderServeNode::~BrowsableFolderServeNode() { - for (std::map::iterator E = _folder_indexes.begin(); E != _folder_indexes.end(); E++) { + for (std::map::iterator E = _folder_indexes.begin(); E != _folder_indexes.end(); E++) { if (E->second) { delete E->second; } diff --git a/web_modules/folder_serve_nodes/browsable_folder_serve_node.h b/web_modules/folder_serve_nodes/browsable_folder_serve_node.h index 56a7911..17ed45e 100644 --- a/web_modules/folder_serve_nodes/browsable_folder_serve_node.h +++ b/web_modules/folder_serve_nodes/browsable_folder_serve_node.h @@ -15,7 +15,7 @@ public: virtual void load(); void evaluate_dir(const String &path, const bool top_level = false); - virtual void render_dir_page(const String &dir_uri, const Vector &folders, const Vector &files); + virtual void render_dir_page(const String &dir_uri, const Vector &folders, const Vector &files, const bool top_level); bool should_render_menu;