88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
#include "web.h"
|
|
#include <fstream>
|
|
Web::Web()
|
|
{}
|
|
|
|
Web::Web(const QList<Path*>& list) : list(list)
|
|
{}
|
|
|
|
void Web::siteHtml()
|
|
{
|
|
std::ofstream file("./data/HTML-exports/index.html");
|
|
if (!file.is_open()) {
|
|
qWarning("Impossible d'ouvrir le fichier index.html");
|
|
return;
|
|
}
|
|
|
|
file << R"(<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Liste des parcours</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial;
|
|
margin: 40px;
|
|
background-color: whitesmoke;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: black;
|
|
font-style: bold;
|
|
}
|
|
ul {
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
padding: 0;
|
|
list-style-type: none;
|
|
}
|
|
li {
|
|
background: white;
|
|
margin: 10px 0;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 0 6px rgba(0,0,0,0.1);
|
|
transition: background-color 0.3s ease;
|
|
}
|
|
li:hover {
|
|
background-color: black;
|
|
}
|
|
a {
|
|
text-decoration: none;
|
|
color: purple;
|
|
font-weight: bold;
|
|
font-size: 1.2em;
|
|
}
|
|
a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Liste des parcours</h1>
|
|
<ul>
|
|
)";
|
|
|
|
for (const Path* p : list) {
|
|
if (!p) continue;
|
|
|
|
// Nom de fichier sécurisé
|
|
QString safeName = p->getName().simplified().replace(" ", "_");
|
|
QString fileName = "parcours_" + safeName + ".html";
|
|
|
|
file << " <li><a href=\"pages/"
|
|
<< fileName.toStdString()
|
|
<< "\">"
|
|
<< p->getName().toStdString()
|
|
<< "</a></li>\n";
|
|
}
|
|
|
|
file << R"( </ul>
|
|
</body>
|
|
</html>
|
|
)";
|
|
|
|
file.close();
|
|
}
|
|
|