Initial commit
This commit is contained in:
26
frontend/templates/base.html
Normal file
26
frontend/templates/base.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Yggtorrent App{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Les films de Lulu</h1>
|
||||
{% if user %}
|
||||
<p>Connecté en tant que {{ user }}</p>
|
||||
<form action="{{ url_for('logout') }}" method="GET" style="display:inline">
|
||||
<button type="submit">Déconnexion</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
26
frontend/templates/dashboard.html
Normal file
26
frontend/templates/dashboard.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Tableau de bord{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form id="search-form" action="/search" method="GET">
|
||||
<label>Catégorie</label>
|
||||
<select name="category_id">
|
||||
<option value="2178">Films d’animation</option>
|
||||
<option value="2179">Séries d’animation / Mangas</option>
|
||||
<option value="2181">Documentaires</option>
|
||||
<option value="2182">Émissions TV</option>
|
||||
<option value="2183">Films</option>
|
||||
<option value="2184">Séries</option>
|
||||
</select>
|
||||
|
||||
<label>Recherche</label>
|
||||
<input type="text" name="query" required>
|
||||
|
||||
<button type="submit">Rechercher</button>
|
||||
</form>
|
||||
|
||||
<div id="results">
|
||||
<!-- Les résultats de recherche seront injectés ici -->
|
||||
</div>
|
||||
{% endblock %}
|
||||
13
frontend/templates/login.html
Normal file
13
frontend/templates/login.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Connexion{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form action="/login" method="POST">
|
||||
<label>Nom d'utilisateur</label>
|
||||
<input type="text" name="username" required>
|
||||
<label>Mot de passe</label>
|
||||
<input type="password" name="password" required>
|
||||
<button type="submit">Se connecter</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
86
frontend/templates/search_results.html
Normal file
86
frontend/templates/search_results.html
Normal file
@@ -0,0 +1,86 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Résultats pour "{{ query }}"</h2>
|
||||
<table id="results-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th onclick="sortTable(0)">Nom ⇅</th>
|
||||
<th onclick="sortTable(1)">Taille ⇅</th>
|
||||
<th onclick="sortTable(2)">Âge ⇅</th>
|
||||
<th>Lien</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in results %}
|
||||
<tr>
|
||||
<td>{{ item.title }}</td>
|
||||
<td>{{ item.size }}</td>
|
||||
<td data-age="{{ item.age_days }}">{{ item.age_human }}</td>
|
||||
<td>
|
||||
<button onclick="getTorrentLink('{{ item.id }}', this)">Obtenir le lien</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function parseSize(sizeStr) {
|
||||
// Convertit "6.2 Go", "700 Mo" en octets
|
||||
const units = { "o": 1, "Ko": 1024, "Mo": 1024**2, "Go": 1024**3, "To": 1024**4 };
|
||||
const match = sizeStr.match(/([\d\.]+)\s*(o|Ko|Mo|Go|To)/);
|
||||
if (!match) return 0;
|
||||
return parseFloat(match[1]) * (units[match[2]] || 1);
|
||||
}
|
||||
|
||||
function sortTable(colIndex) {
|
||||
const table = document.getElementById("results-table");
|
||||
const tbody = table.tBodies[0];
|
||||
const rows = Array.from(tbody.rows);
|
||||
const asc = table.asc = !table.asc;
|
||||
|
||||
rows.sort((a, b) => {
|
||||
let aText = a.cells[colIndex].innerText.trim();
|
||||
let bText = b.cells[colIndex].innerText.trim();
|
||||
|
||||
if (colIndex === 1) { // Taille
|
||||
return asc ? parseSize(aText) - parseSize(bText) : parseSize(bText) - parseSize(aText);
|
||||
} else if (colIndex === 2) { // Âge
|
||||
const aVal = parseInt(a.cells[colIndex].dataset.age || 0);
|
||||
const bVal = parseInt(b.cells[colIndex].dataset.age || 0);
|
||||
return asc ? aVal - bVal : bVal - aVal;
|
||||
} else { // Nom
|
||||
return asc ? aText.localeCompare(bText) : bText.localeCompare(aText);
|
||||
}
|
||||
});
|
||||
|
||||
rows.forEach(row => tbody.appendChild(row));
|
||||
}
|
||||
|
||||
async function getTorrentLink(torrentId, btn) {
|
||||
btn.disabled = true;
|
||||
btn.innerText = "Chargement...";
|
||||
|
||||
try {
|
||||
const response = await fetch(`/torrent/${torrentId}`);
|
||||
const links = await response.json(); // <-- lire comme JSON
|
||||
|
||||
if (links && links.length > 0) {
|
||||
// Construire une liste HTML
|
||||
const listHTML = links.map(link =>
|
||||
`<li><a href="${link.link}" target="_blank">${link.name} (${(link.size / 1024 / 1024).toFixed(2)} Mo)</a></li>`
|
||||
).join("");
|
||||
|
||||
btn.innerHTML = `<ul>${listHTML}</ul>`;
|
||||
} else {
|
||||
btn.innerText = "Aucun fichier trouvé";
|
||||
}
|
||||
} catch (err) {
|
||||
btn.innerText = "Erreur";
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user