mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 18:32:51 +00:00
khttpd: tidy body for directories and output .. href
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b7933ddbc7
commit
cd4605b380
1 changed files with 8 additions and 4 deletions
|
@ -32,18 +32,22 @@ static QByteArray bodyForPath(const QString &path, const QString &basedir)
|
||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
data.append("<html>");
|
data.append("<html>");
|
||||||
|
QDir::Filters dirfilter = (QDir::Files | QDir::AllDirs | QDir::NoDot);
|
||||||
|
if (path == basedir) {
|
||||||
|
dirfilter = (QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||||
|
}
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
foreach (const QFileInfo &fileinfo, dir.entryInfoList(QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot)) {
|
foreach (const QFileInfo &fileinfo, dir.entryInfoList(dirfilter)) {
|
||||||
const QString fullpath = path.toLocal8Bit() + QLatin1Char('/') + fileinfo.fileName();
|
const QString fullpath = path.toLocal8Bit() + QLatin1Char('/') + fileinfo.fileName();
|
||||||
// chromium does weird stuff if the link starts with two slashes - removes, the host and
|
// chromium does weird stuff if the link starts with two slashes - removes, the host and
|
||||||
// port part of the link and converts the first path to lower-case
|
// port part of the link and converts the first directory to lower-case
|
||||||
const QString cleanpath = QDir::cleanPath(fullpath.mid(basedir.size()));
|
const QString cleanpath = QDir::cleanPath(fullpath.mid(basedir.size()));
|
||||||
// qDebug() << Q_FUNC_INFO << fullpath << basedir << cleanpath;
|
// qDebug() << Q_FUNC_INFO << fullpath << basedir << cleanpath;
|
||||||
data.append("<p><a href=\"");
|
data.append("<a href=\"");
|
||||||
data.append(cleanpath.toLocal8Bit());
|
data.append(cleanpath.toLocal8Bit());
|
||||||
data.append("\">");
|
data.append("\">");
|
||||||
data.append(fileinfo.fileName().toLocal8Bit());
|
data.append(fileinfo.fileName().toLocal8Bit());
|
||||||
data.append("</a></p>");
|
data.append("</a><br>");
|
||||||
}
|
}
|
||||||
data.append("</html>");
|
data.append("</html>");
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue