From c519b9262d5dadbf1c565b8fd6b6f6bf2ff4238e Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Thu, 27 Feb 2014 22:21:45 +0100 Subject: [PATCH] Add simple breadcrumb navigation to the httpd --- src/Network/httpd.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Network/httpd.cxx b/src/Network/httpd.cxx index 745a14c9e..880e3ebf4 100644 --- a/src/Network/httpd.cxx +++ b/src/Network/httpd.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include
#include
@@ -188,6 +189,25 @@ public: } }; +static string makeLinksForPath( const string & request ) +{ + using namespace simgear::strutils; + string reply = "/"; + string path = "/"; + + string_list sl = split( request, "/" ); + for( string_list::iterator it = sl.begin(); it != sl.end(); ++it ) { + if( (*it).empty() ) continue; + path.append( *it ).append( "/" ); + reply.append("") + .append(*it) + .append("/"); + + } + return reply; +} // Handle http GET requests void HttpdChannel::foundTerminator (void) { @@ -295,7 +315,7 @@ void HttpdChannel::foundTerminator (void) { } else if ( node->nChildren() > 0 ) { // request is a path with children response += "

Contents of \""; - response += request; + response += makeLinksForPath( request ); response += "\"

"; response += getTerminator(); @@ -346,7 +366,7 @@ void HttpdChannel::foundTerminator (void) { response += urlEncode(request); response += "\">"; response += ""; - response += request; + response += makeLinksForPath(request); response += " = "; response += "