83 lines
1.8 KiB
C++
83 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, sans-serif;
|
|
margin: 40px;
|
|
background-color: #f0f0f0;
|
|
color: #333;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: purple;
|
|
font-style: italic;
|
|
}
|
|
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: red;
|
|
}*/
|
|
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 = 1;
|
|
for (const Path* p : list) {
|
|
QString fileName = QString("parcours%1.html").arg(index);
|
|
QString name = p->getName();
|
|
file << " <li><a href=\"" << fileName.toStdString() << "\">"
|
|
<< name.toStdString() << "</a></li>\n";
|
|
++index;
|
|
}
|
|
|
|
file << R"( </ul>
|
|
</body>
|
|
</html>
|
|
)";
|
|
|
|
file.close();
|
|
}
|