diff options
-rw-r--r-- | music.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -9,6 +9,7 @@ #include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> +#include <boost/algorithm/string/join.hpp> #include <boost/cast.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/foreach.hpp> @@ -136,13 +137,15 @@ void music::update(const MusicDirectory& dir) { void MusicDirectory::render(HTTP::Connection::p req) { req->add_header("content-type", "text/html"); + std::string base_path = boost::algorithm::join(req->base_path, "/"); + for(PathListings::iterator it = directories.begin(); it != directories.end(); it++) { std::string rel_path = it->string().substr(music::root_directory.string().size()); - req->send_data(boost::str(boost::format("<a href=\"/files%s\">%s</a><br />") % rel_path % rel_path)); + req->send_data(boost::str(boost::format("<a href=\"/%s%s\">%s</a><br />") % base_path % rel_path % rel_path)); } for(PathListings::iterator it = tracks.begin(); it != tracks.end(); it++) { std::string rel_path = it->string().substr(music::root_directory.string().size()); - req->send_data(boost::str(boost::format("<a href=\"/files%s\">%s</a><br />") % rel_path % rel_path)); + req->send_data(boost::str(boost::format("<a href=\"/%s%s\">%s</a><br />") % base_path % rel_path % rel_path)); } } |