T'JAMPENS QUENTIN p2406187 1690eadfae Start index at 0
2025-06-20 18:33:49 +02:00

86 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("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>
)";
int index = 0;
for (const Path* p : list) {
QString fileName = QString("parcours%1.html").arg(index);
QString name = p->getName();
file << " <li><a href=\"./pages/"
<< fileName.toStdString()
<< "\">"
<< name.toStdString()
<< "</a></li>\n";
++index;
}
file << R"( </ul>
</body>
</html>
)";
file.close();
}