diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-04 02:18:43 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-04 02:18:43 +0100 |
commit | 2b03b8ef2b5002f00960d17c8f1f634eb3a3a70f (patch) | |
tree | 724fa665e6f9f35f567ebb29f01104470a225bc7 | |
parent | b73c8b20a034a4e8ac9ab8740453e35160c20833 (diff) |
Prefix paths with joined base_path.
-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)); } } |