Initial commit (v1.5.9)

This commit is contained in:
2026-09-15 21:45:47 +02:00
commit b8d3dd52ec
89 changed files with 13429 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
<%- include('partials/header') %>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-downloads" class="section">
<div class="header-row">
<h2>Téléchargements</h2>
<button id="btn-refresh-downloads" class="btn-icon-only">
<i data-lucide="refresh-cw"></i>
</button>
</div>
<div id="downloads-list" class="downloads-container">
<div class="empty-state">Aucun téléchargement actif</div>
</div>
</section>
</main>
<%- include('partials/footer') %>
+89
View File
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Agora — Connexion</title>
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#1a1a1a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Agora">
<link rel="apple-touch-icon" href="/images/icone-192.png">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/style.css">
<script src="/lucide.min.js"></script>
<script src="/app.auth.js"></script>
<style>
.error-msg {
color: var(--primary);
font-size: 0.95rem;
margin-top: 15px;
font-weight: 600;
}
</style>
<link rel="icon" type="image/svg+xml" href="/logo_svg.svg">
</head>
<body>
<div id="login-overlay" class="overlay active">
<div class="login-box">
<div class="logo-large">
<img src="/images/logo_svg.svg" alt="Logo" class="icon-xl">
<h1>Agora</h1>
</div>
<form id="login-form">
<input type="text" id="login-username" placeholder="Nom d'utilisateur" required autofocus autocomplete="username">
<div class="password-container">
<input type="password" id="login-password" placeholder="Mot de passe" required autocomplete="current-password">
<button type="button" class="toggle-password" tabindex="-1">
<i data-lucide="eye" class="eye-icon"></i>
</button>
</div>
<button type="submit">Connexion</button>
</form>
<div id="login-error" class="error-msg hidden"></div>
</div>
</div>
<script>
if (typeof lucide !== 'undefined') lucide.createIcons();
if (window.AuthHelpers) AuthHelpers.initPasswordToggles();
document.getElementById('login-form').addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('login-username').value.trim();
const password = document.getElementById('login-password').value;
const errorDiv = document.getElementById('login-error');
errorDiv.classList.add('hidden');
errorDiv.textContent = '';
try {
const res = await fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
});
const data = await res.json();
if (data.success) {
// Redirection vers la page par défaut
const defaultPage = document.cookie.split('; ').find(c => c.startsWith('defaultPage='));
const target = defaultPage ? defaultPage.split('=')[1] : '/trending';
window.location.href = target;
} else {
errorDiv.textContent = data.error || 'Identifiants invalides.';
errorDiv.classList.remove('hidden');
}
} catch (err) {
errorDiv.textContent = 'Erreur de connexion au serveur.';
errorDiv.classList.remove('hidden');
}
});
</script>
</body>
</html>
+45
View File
@@ -0,0 +1,45 @@
<%- include('partials/header') %>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-manual" class="section">
<div class="hero-header">
<h2>Ajout Manuel JDownloader</h2>
</div>
<div class="form-card" style="max-width: 600px; margin: 0 auto;">
<h3 style="margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;">Ajouter des liens manuellement</h3>
<div style="margin-bottom: 1.25rem;">
<label for="manual-title" style="display: block; font-weight: 600; margin-bottom: 0.5rem; color: white;">Nom du Film ou de la Série</label>
<input type="text" id="manual-title" placeholder="Ex: Inception, Breaking Bad S01..." style="width: 100%; padding: 12px; background: var(--bg-main); border: 1px solid var(--border); color: white; border-radius: var(--radius);">
</div>
<div style="margin-bottom: 1.25rem;">
<label style="display: block; font-weight: 600; margin-bottom: 0.5rem; color: white;">Type de contenu</label>
<div class="manual-type-selector">
<div class="type-option active" data-type="film">
<i data-lucide="film" style="width: 18px; height: 18px;"></i>
Film
</div>
<div class="type-option" data-type="series">
<i data-lucide="tv" style="width: 18px; height: 18px;"></i>
Série
</div>
</div>
<input type="hidden" id="manual-type" value="film">
</div>
<div style="margin-bottom: 1.5rem;">
<label for="manual-links" style="display: block; font-weight: 600; margin-bottom: 0.5rem; color: white;">Liens (un lien par ligne)</label>
<textarea id="manual-links" placeholder="Copiez-collez vos liens ici (1fichier, turbobit, etc.)&#10;Un lien par ligne..." style="width: 100%; height: 180px; padding: 12px; background: var(--bg-main); border: 1px solid var(--border); color: white; border-radius: var(--radius); font-family: monospace; line-height: 1.5; resize: vertical;"></textarea>
</div>
<button class="btn-primary" id="btn-manual-submit" style="width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 12px 24px; font-weight: bold;">
<i data-lucide="plus-circle"></i> Envoyer à JDownloader
</button>
</div>
</section>
</main>
<%- include('partials/footer') %>
+26
View File
@@ -0,0 +1,26 @@
</div>
<div id="modal-overlay" class="modal-overlay hidden">
<div class="modal-content">
<div class="modal-header">
<h3 id="modal-title">Titre</h3>
<button id="modal-close"><i data-lucide="x"></i></button>
</div>
<div id="modal-body" class="modal-body"></div>
</div>
</div>
<div id="toast" class="toast hidden">Notification</div>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(reg => console.log('SW enregistré!', reg.scope))
.catch(err => console.log('SW échec:', err));
});
}
</script>
<script src="/app.auth.js"></script>
<script src="/app.js"></script>
</body>
</html>
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Agora</title>
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#1a1a1a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Agora">
<link rel="apple-touch-icon" href="/images/icone-192.png">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/style.css">
<script src="/lucide.min.js"></script>
<link rel="icon" type="image/svg+xml" href="/logo_svg.svg">
</head>
<body>
<div id="app-container">
+93
View File
@@ -0,0 +1,93 @@
<nav class="sidebar" id="sidebar">
<script>
(function() {
if (localStorage.getItem('sidebar-collapsed') === 'true') {
document.getElementById('sidebar').classList.add('collapsed');
}
})();
</script>
<div class="brand">
<div class="brand-logo">
<img src="/images/logo_svg.svg" alt="Logo" class="brand-icon">
<span>Agora</span>
</div>
<button id="btn-sidebar-toggle" class="btn-sidebar-toggle" title="Réduire la barre latérale">
<i data-lucide="chevron-left" id="sidebar-toggle-icon"></i>
</button>
</div>
<ul class="nav-links">
<a href="/trending" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'trending' ? 'active' : '' %>" data-target="section-trending">
<i data-lucide="flame"></i>
<span>Tendances</span>
</li>
</a>
<a href="/recent" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'recent' ? 'active' : '' %>" data-target="section-recent">
<i data-lucide="clock"></i>
<span>Ajouts récents</span>
</li>
</a>
<a href="/search" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'search' ? 'active' : '' %>" data-target="section-search">
<i data-lucide="search"></i>
<span>Recherche</span>
</li>
</a>
<a href="/downloads" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'downloads' ? 'active' : '' %>" data-target="section-downloads">
<i data-lucide="download"></i>
<span>Téléchargements</span>
</li>
</a>
<a href="/manual" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'manual' ? 'active' : '' %>" data-target="section-manual">
<i data-lucide="plus-circle"></i>
<span>Ajout manuel</span>
</li>
</a>
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
<a href="/settings" style="text-decoration: none; color: inherit;">
<li class="<%= page === 'settings' ? 'active' : '' %>" data-target="section-settings">
<i data-lucide="settings"></i>
<span>Paramètres</span>
</li>
</a>
<% } %>
</ul>
<div class="nav-footer">
<button id="btn-logout" class="btn-text">
<i data-lucide="log-out"></i>
<span>Déconnexion</span>
</button>
</div>
</nav>
<script>
document.addEventListener('DOMContentLoaded', () => {
const sidebar = document.getElementById('sidebar');
const toggleBtn = document.getElementById('btn-sidebar-toggle');
const toggleIcon = document.getElementById('sidebar-toggle-icon');
if (!sidebar || !toggleBtn || !toggleIcon) return;
const updateIcon = (isCollapsed) => {
toggleIcon.setAttribute('data-lucide', isCollapsed ? 'chevron-right' : 'chevron-left');
if (window.lucide) {
window.lucide.createIcons({ root: toggleBtn });
}
};
// Sync initial icon state
const isCollapsed = sidebar.classList.contains('collapsed');
updateIcon(isCollapsed);
toggleBtn.addEventListener('click', () => {
const willCollapse = !sidebar.classList.contains('collapsed');
sidebar.classList.toggle('collapsed', willCollapse);
localStorage.setItem('sidebar-collapsed', willCollapse ? 'true' : 'false');
updateIcon(willCollapse);
});
});
</script>
+34
View File
@@ -0,0 +1,34 @@
<%- include('partials/header') %>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-recent" class="section">
<div class="hero-header">
<h2>Récemment Ajoutés</h2>
<p>Les derniers ajouts disponibles sur la source</p>
</div>
<div class="filter-pills" style="margin-bottom: 2rem;">
<label class="pill">
<input type="radio" name="recent-type" value="all" checked>
<span>Tout</span>
</label>
<label class="pill">
<input type="radio" name="recent-type" value="film">
<span>Films</span>
</label>
<label class="pill">
<input type="radio" name="recent-type" value="serie">
<span>Séries</span>
</label>
</div>
<div id="recent-grid" class="media-grid">
<div class="loader-wrapper">
<div class="loader"></div>
</div>
</div>
</section>
</main>
<%- include('partials/footer') %>
+55
View File
@@ -0,0 +1,55 @@
<%- include('partials/header') %>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-search" class="section">
<div class="hero-header">
<h2>Recherche Globale</h2>
</div>
<div class="search-hero">
<div class="search-input-wrapper">
<i data-lucide="search" class="search-icon-inside"></i>
<input type="text" id="search-input" placeholder="Titre du film, série...">
<button id="btn-search-trigger" class="btn-search-action">Go</button>
</div>
<p style="font-size: 0.8rem; color: var(--text-sec); margin-top: 8px; text-align: center;">
⚠️ <i>Recherche stricte (Seulement pour la LocalDB) : Saisissez exactement le titre du film/série recherché.</i>
</p>
<div class="filter-pills" style="margin-top: 15px;" id="search-filters-container">
<label class="pill">
<input type="radio" name="search-type" value="film" checked>
<span>Films</span>
</label>
<label class="pill">
<input type="radio" name="search-type" value="serie">
<span>Séries</span>
</label>
<label class="pill localdb-filter hidden">
<input type="radio" name="search-type" value="game">
<span>Jeux</span>
</label>
<label class="pill localdb-filter hidden">
<input type="radio" name="search-type" value="software">
<span>Logiciels</span>
</label>
<label class="pill localdb-filter hidden">
<input type="radio" name="search-type" value="book">
<span>Livres/BD</span>
</label>
<label class="pill localdb-filter hidden">
<input type="radio" name="search-type" value="music">
<span>Musique</span>
</label>
<label class="pill localdb-filter hidden">
<input type="radio" name="search-type" value="other">
<span>Autres</span>
</label>
</div>
</div>
<div id="search-results" class="media-grid"></div>
</section>
</main>
<%- include('partials/footer') %>
+410
View File
@@ -0,0 +1,410 @@
<%- include('partials/header') %>
<script src="/sortable.min.js"></script>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-settings" class="section">
<div class="hero-header">
<h2>Paramètres</h2>
</div>
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; justify-content: space-between;">
<span style="display: flex; align-items: center; gap: 8px;"><i data-lucide="refresh-cw"></i> Système & Mises à jour</span>
<span style="font-size: 0.75rem; background: rgba(255,255,255,0.1); padding: 4px 8px; border-radius: 4px; font-family: monospace;">v<%= appVersion %></span>
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Vérifiez si une nouvelle version d'Agora est disponible et consultez les instructions de mise à jour.
</p>
<button id="check-update-btn" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px;">
<i data-lucide="download-cloud" style="width: 16px; height: 16px;"></i> Vérifier les mises à jour
</button>
<div id="update-results-container" style="display: none; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border);">
<!-- Injecté par JS -->
</div>
</div>
<% } %>
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="database"></i> Sources de Recherche
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Sélectionnez la source principale (prioritaire) et les sources secondaires à utiliser.
</p>
<div style="margin-bottom: 1.5rem;">
<label style="display: block; font-weight: 600; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="list-ordered" style="color: var(--primary); width: 18px; height: 18px;"></i> Priorité & Activation des Sources
</label>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1.2rem;">
Activez les sources et glissez-déposez pour définir leur ordre de priorité. La première source active (cochée) sera la source principale.
</p>
<div id="sources-sortable-container" style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem;">
<!-- Les sources ordonnables seront injectées ici par JS -->
</div>
</div>
</div>
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="server"></i> Hébergeurs Préférés
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Glissez et déposez les hébergeurs pour définir leur ordre de préférence. Les liens de téléchargement seront triés selon cet ordre.
</p>
<div id="hosters-sortable-container" style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem;">
<% if (typeof preferredHosters !== 'undefined' && preferredHosters.length > 0) { %>
<% preferredHosters.forEach(function(hoster) {
const h = hoster.toLowerCase();
let domain = h + '.com';
if (h === 'turbobit') domain = 'turbobit.net';
if (h === 'rapidgator') domain = 'rapidgator.net';
if (h === 'mega') domain = 'mega.nz';
if (h === 'gofile') domain = 'gofile.io';
if (h === 'nitroflare') domain = 'nitroflare.com';
%>
<div class="sortable-item" data-hoster="<%= hoster %>" style="display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; cursor: grab;">
<div style="display: flex; align-items: center; gap: 12px;">
<i data-lucide="grip-vertical" style="color: var(--text-sec); width: 18px; height: 18px;"></i>
<img src="https://www.google.com/s2/favicons?domain=<%= domain %>&sz=32" alt="logo" style="width: 20px; height: 20px; border-radius: 4px;" onerror="this.style.display='none'; this.nextElementSibling.style.display='inline-block';">
<i data-lucide="server" style="color: var(--text-sec); width: 18px; height: 18px; display: none;"></i>
<span style="font-weight: 500; text-transform: capitalize;"><%= hoster %></span>
</div>
</div>
<% }); %>
<% } %>
</div>
<div style="display: flex; gap: 10px;">
<button id="save-hosters-btn" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1;">
<i data-lucide="save" style="width: 16px; height: 16px;"></i> Enregistrer l'ordre
</button>
</div>
</div>
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="plug"></i> Configuration des Plugins
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Modifiez les adresses et clés d'accès des plugins. Les modifications seront appliquées immédiatement sans redémarrage.
</p>
<form id="plugins-config-form">
<% if (typeof pluginsToConfigure !== 'undefined' && pluginsToConfigure.length > 0) { %>
<% pluginsToConfigure.forEach(function(plugin) { %>
<div style="background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem;">
<strong style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.8rem; color: var(--text-main); font-size: 0.95rem; text-transform: capitalize;">
<i data-lucide="box" style="width: 14px; height: 14px; color: var(--text-sec);"></i>
<%= plugin.name %>
</strong>
<%
const urlField = plugin.fields.find(f => f.key.endsWith('_URL'));
const urlEmpty = urlField && !urlField.default;
%>
<% if (plugin.name.includes('TMDB')) { %>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 12px; margin-top: -8px;">
<i data-lucide="info" style="width: 14px; height: 14px; vertical-align: middle;"></i>
Pour obtenir une clé d'API, créez un compte gratuit sur <a href="https://www.themoviedb.org/settings/api" target="_blank" style="color: var(--primary);">themoviedb.org</a>, générez une clé (API v3 Auth) et collez-la ci-dessous.
</p>
<% plugin.fields.forEach(function(field) { %>
<div style="margin-bottom: 0.8rem;">
<label for="config_<%= field.key %>" style="font-size: 0.8rem; color: var(--text-sec); margin-bottom: 4px; display: block;"><%= field.label %></label>
<% if (field.key.endsWith('_ENABLED') || field.key === 'JD_FORCED_START') { %>
<select id="config_<%= field.key %>" name="<%= field.key %>" style="width: 100%; padding: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-main); font-size: 0.9rem;">
<option value="true" <%= field.default === 'true' ? 'selected' : '' %>>Activé</option>
<option value="false" <%= field.default === 'false' ? 'selected' : '' %>>Désactivé</option>
</select>
<% } else { %>
<input type="text" id="config_<%= field.key %>" name="<%= field.key %>"
placeholder="<%= field.placeholder %>" value="<%= field.default || '' %>"
style="width: 100%; padding: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-main); font-size: 0.9rem;">
<% } %>
</div>
<% }); %>
<% } else { %>
<% plugin.fields.forEach(function(field) { %>
<div style="margin-bottom: 0.8rem;">
<label for="config_<%= field.key %>" style="font-size: 0.8rem; color: var(--text-sec); margin-bottom: 4px; display: block;"><%= field.label %></label>
<input type="text" id="config_<%= field.key %>" name="<%= field.key %>"
placeholder="<%= field.placeholder %>" value="<%= field.default || '' %>"
data-is-url="<%= field.key.endsWith('_URL') ? 'true' : 'false' %>"
data-plugin="<%= plugin.name %>"
style="padding: 8px; font-size: 0.9rem; width: 100%; border: 1px solid var(--border); background: var(--bg-main); color: var(--text-main); border-radius: 6px;">
</div>
<% }); %>
<% } %>
</div>
<% }); %>
<div style="display: flex; gap: 10px;">
<button type="submit" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1;">
<i data-lucide="save" style="width: 16px; height: 16px;"></i> Enregistrer & Recharger
</button>
</div>
<% } else { %>
<p style="font-size: 0.85rem; color: var(--text-sec);">Aucun plugin détecté.</p>
<% } %>
</form>
</div>
<% } %>
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;">
Page d'accueil par défaut</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Sélectionnez la page sur laquelle vous souhaitez être redirigé par défaut à l'ouverture de
l'application.
</p>
<select id="select-default-page" style="margin-top: 0.5rem; margin-bottom: 0;">
<option value="/trending">Tendances</option>
<option value="/recent">Ajouts récents</option>
<option value="/search">Recherche</option>
<option value="/downloads">Téléchargements</option>
<option value="/manual">Ajout manuel</option>
<option value="/settings">Paramètres</option>
</select>
</div>
<div class="form-card" style="max-width: 750px; margin: 0 auto;">
<label style="display: flex; align-items: center; justify-content: space-between; cursor: pointer;">
<span style="font-weight: 600;">Intégration JDownloader</span>
<input type="checkbox" id="toggle-jd" style="width: 20px; height: 20px;">
</label>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-top: 10px;">Si désactivé, le lien
1fichier sera affiché directement sous forme de pop-up sans être envoyé à JDownloader.</p>
</div>
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
<div class="form-card" style="max-width: 750px; margin: 1.5rem auto 0 auto;">
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="users" style="width: 20px; height: 20px;"></i> Gestion des Utilisateurs
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Gérez les comptes utilisateurs. Seuls les administrateurs ont accès à cette section.
</p>
<!-- Liste des utilisateurs -->
<div id="admin-users-list" style="display: flex; flex-direction: column; gap: 8px; margin-bottom: 1.5rem;">
<!-- Injecté par JS -->
</div>
<!-- Formulaire d'ajout -->
<div style="border-top: 1px solid var(--border); padding-top: 1rem;">
<label style="display: block; font-weight: 600; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="user-plus" style="color: var(--primary); width: 16px; height: 16px;"></i> Ajouter un utilisateur
</label>
<div style="display: flex; gap: 10px; margin-bottom: 12px; align-items: center;">
<input type="text" id="admin-new-username" placeholder="Nom d'utilisateur"
style="flex: 1; margin: 0; padding: 12px 16px;"
minlength="3" maxlength="32" pattern="[a-zA-Z0-9_.\-]+">
<select id="admin-new-role" style="width: auto; min-width: 130px; margin: 0; padding: 12px 16px;">
<option value="user">Utilisateur</option>
<option value="admin">Admin</option>
</select>
</div>
<button id="admin-add-user-btn" class="btn-action" style="width: 100%; padding: 12px 20px;">
Créer l'utilisateur
</button>
</div>
</div>
<% } %>
<!-- Modal pour afficher le mot de passe généré -->
<div id="admin-password-modal" class="modal-overlay hidden">
<div class="modal-content" style="max-width: 420px;">
<h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="key" style="width: 20px; height: 20px; color: var(--primary);"></i>
Mot de passe généré
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
Copiez ce mot de passe et transmettez-le à l'utilisateur. Il ne sera plus affiché.
</p>
<div id="admin-generated-password" style="background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-family: monospace; font-size: 1.1rem; text-align: center; color: var(--primary); font-weight: 700; letter-spacing: 1px; user-select: all; cursor: text; word-break: break-all;"></div>
<button id="admin-copy-password-btn" style="width: 100%; margin-top: 1rem; padding: 10px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); color: white; font-weight: 600; cursor: pointer;">
Copier le mot de passe
</button>
<button id="admin-close-modal-btn" style="width: 100%; margin-top: 0.5rem; padding: 10px; border-radius: 8px; background: var(--primary); border: none; color: white; font-weight: 600; cursor: pointer;">
Fermer
</button>
</div>
</div>
<div style="text-align: center; margin-top: 3rem; margin-bottom: 1rem;">
<p style="font-size: 0.85rem; color: var(--text-sec); display: inline-flex; align-items: center; gap: 6px; background: var(--bg-card); padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);">
<i data-lucide="info" style="width: 14px; height: 14px;"></i>
Agora v<%= appVersion %>
</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// --- Plugins Config Form ---
const form = document.getElementById('plugins-config-form');
if (form) {
form.addEventListener('submit', async (e) => {
e.preventDefault();
const btn = form.querySelector('button[type="submit"]');
const origHtml = btn.innerHTML;
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Enregistrement...';
btn.disabled = true;
if (window.lucide) lucide.createIcons();
const fd = new FormData(form);
const config = Object.fromEntries(fd.entries());
try {
const res = await fetch('/api/admin/plugins/save', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ config })
});
const data = await res.json();
if (data.success) {
window.showModal(
'Succès',
`<div style="padding: 1rem; text-align: center; color: var(--text-main);">
<i data-lucide="check-circle" style="color: #10b981; width: 48px; height: 48px; margin-bottom: 1rem;"></i>
<p>Configuration enregistrée avec succès.</p>
<p style="font-size: 0.9rem; color: var(--text-sec); margin-top: 0.5rem;">Plugins actifs : ${data.activeSources.join(', ')}</p>
</div>`
);
if (window.lucide) lucide.createIcons();
setTimeout(() => window.location.reload(), 2000);
} else {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
}
} catch (err) {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur lors de la sauvegarde.</p></div>`);
console.error(err);
} finally {
btn.innerHTML = origHtml;
btn.disabled = false;
if (window.lucide) lucide.createIcons();
}
});
}
// --- Hosters Sorting ---
const hostersContainer = document.getElementById('hosters-sortable-container');
if (hostersContainer) {
Sortable.create(hostersContainer, {
animation: 150,
handle: '.sortable-item', // Permet de draguer sur tout l'item
ghostClass: 'dragging-hoster', // Classe appliquée pendant le drag
});
document.getElementById('save-hosters-btn')?.addEventListener('click', async (e) => {
const btn = e.currentTarget;
const origHtml = btn.innerHTML;
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Enregistrement...';
btn.disabled = true;
if (window.lucide) lucide.createIcons();
const order = Array.from(hostersContainer.querySelectorAll('.sortable-item')).map(el => el.dataset.hoster);
try {
const res = await fetch('/api/admin/hosters/save', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ preferredHosters: order })
});
const data = await res.json();
if (data.success) {
window.showModal(
'Succès',
`<div style="padding: 1rem; text-align: center; color: var(--text-main);">
<i data-lucide="check-circle" style="color: #10b981; width: 48px; height: 48px; margin-bottom: 1rem;"></i>
<p>Ordre des hébergeurs enregistré avec succès !</p>
</div>`
);
if (window.lucide) lucide.createIcons();
} else {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
}
} catch (err) {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur réseau lors de la sauvegarde.</p></div>`);
} finally {
btn.innerHTML = origHtml;
btn.disabled = false;
if (window.lucide) lucide.createIcons();
}
});
}
// --- Updates Checking ---
const checkUpdateBtn = document.getElementById('check-update-btn');
if (checkUpdateBtn) {
checkUpdateBtn.addEventListener('click', async () => {
const btn = checkUpdateBtn;
const origHtml = btn.innerHTML;
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Vérification...';
btn.disabled = true;
if (window.lucide) lucide.createIcons();
const container = document.getElementById('update-results-container');
container.style.display = 'none';
container.innerHTML = '';
try {
const res = await fetch('/api/admin/check-update');
const data = await res.json();
if (data.success) {
container.style.display = 'block';
const isNew = data.currentVersion !== data.latestVersion;
let html = '';
if (isNew) {
html += `<div style="background: rgba(16, 185, 129, 0.1); border: 1px solid #10b981; padding: 12px; border-radius: 6px; margin-bottom: 1rem; color: #10b981; font-weight: 600; display: flex; align-items: center; gap: 8px;">
<i data-lucide="party-popper" style="width: 20px; height: 20px;"></i> Nouvelle version disponible : ${data.latestVersion} !
</div>`;
} else {
html += `<div style="background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); padding: 12px; border-radius: 6px; margin-bottom: 1rem; color: var(--text-main); font-weight: 500; display: flex; align-items: center; gap: 8px;">
<i data-lucide="check-circle" style="color: #10b981; width: 20px; height: 20px;"></i> Votre système est à jour (v${data.currentVersion}).
</div>`;
}
if (data.notes && data.notes.length > 0) {
html += `<h4 style="margin-bottom: 8px; font-size: 0.9rem;">Nouveautés :</h4><ul style="margin: 0 0 1rem 0; padding-left: 20px; color: var(--text-sec); font-size: 0.85rem; line-height: 1.5;">`;
data.notes.forEach(n => html += `<li>${n}</li>`);
html += `</ul>`;
}
html += `<h4 style="margin-bottom: 8px; font-size: 0.9rem;">Comment mettre à jour :</h4>
<div style="display: flex; flex-direction: column; gap: 10px;">
<div style="background: var(--bg-main); padding: 12px; border-radius: 6px; border: 1px solid var(--border);">
<strong style="display: block; font-size: 0.8rem; color: var(--primary); margin-bottom: 4px;">Via Docker</strong>
<code style="font-size: 0.85rem; color: var(--text-main); user-select: all; cursor: text;">${data.updateInfo.dockerCmd}</code>
</div>
<div style="background: var(--bg-main); padding: 12px; border-radius: 6px; border: 1px solid var(--border);">
<strong style="display: block; font-size: 0.8rem; color: var(--primary); margin-bottom: 4px;">Installation Manuelle (.zip)</strong>
<a href="${data.updateInfo.zipUrl}" target="_blank" style="font-size: 0.85rem; color: var(--text-main); text-decoration: underline;">Télécharger l'archive depuis le site</a>
${data.updateInfo.zipSha256 ? `<div style="margin-top: 8px; font-size: 0.8rem; color: var(--text-muted);">Somme de contrôle (SHA-256) :<br><code style="font-size: 0.75rem; user-select: all; background: rgba(0,0,0,0.2); padding: 2px 4px; border-radius: 4px; word-break: break-all;">${data.updateInfo.zipSha256}</code></div>` : ''}
</div>
</div>`;
container.innerHTML = html;
} else {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
}
} catch (err) {
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur réseau lors de la vérification.</p></div>`);
} finally {
btn.innerHTML = origHtml;
btn.disabled = false;
if (window.lucide) lucide.createIcons();
}
});
}
});
</script>
</section>
</main>
<%- include('partials/footer') %>
+282
View File
@@ -0,0 +1,282 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Agora — Installation</title>
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#1a1a1a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Agora">
<link rel="apple-touch-icon" href="/images/icone-192.png">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/style.css">
<script src="/lucide.min.js"></script>
<script src="/app.auth.js"></script>
<style>
.setup-container {
min-height: 100vh;
width: 100%;
display: flex;
align-items: flex-start;
justify-content: center;
padding: 2rem 1rem;
background: var(--bg-main);
overflow-y: auto;
}
.setup-box {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 16px;
padding: 2.5rem;
width: 100%;
max-width: 480px;
box-shadow: 0 8px 32px rgba(0,0,0,0.4);
margin: auto;
}
.setup-logo {
text-align: center;
margin-bottom: 2rem;
}
.setup-logo img {
width: 80px;
height: 80px;
margin-bottom: 1rem;
}
.setup-logo h1 {
font-size: 1.8rem;
font-weight: 700;
color: white;
margin: 0;
}
.setup-logo p {
color: var(--text-sec);
font-size: 0.9rem;
margin-top: 0.5rem;
}
.setup-badge {
display: inline-flex;
align-items: center;
gap: 6px;
background: rgba(229, 9, 20, 0.15);
color: var(--primary);
font-size: 0.75rem;
font-weight: 600;
padding: 4px 12px;
border-radius: 20px;
margin-bottom: 1.5rem;
border: 1px solid rgba(229, 9, 20, 0.3);
}
.setup-form { display: flex; flex-direction: column; gap: 1rem; }
.setup-form label {
display: block;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-sec);
margin-bottom: 6px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.setup-form input {
width: 100%;
padding: 12px 16px;
background: var(--bg-main);
border: 1px solid var(--border);
border-radius: 10px;
color: white;
font-size: 1rem;
transition: border-color 0.2s, box-shadow 0.2s;
box-sizing: border-box;
}
.setup-form input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}
.setup-form button[type="submit"] {
width: 100%;
padding: 14px;
background: var(--primary);
color: white;
border: none;
border-radius: 10px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: background 0.2s, transform 0.1s;
margin-top: 0.5rem;
}
.setup-form button[type="submit"]:hover { background: #c40812; }
.setup-form button[type="submit"]:active { transform: scale(0.98); }
.setup-form button[type="submit"]:disabled {
background: #4b5563;
color: #9ca3af;
cursor: not-allowed;
transform: none;
}
.setup-error {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.3);
color: #ef4444;
padding: 10px 14px;
border-radius: 8px;
font-size: 0.85rem;
font-weight: 500;
}
</style>
<link rel="icon" type="image/svg+xml" href="/logo_svg.svg">
</head>
<body>
<div class="setup-container">
<div class="setup-box">
<div class="setup-logo">
<img src="/images/logo_svg.svg" alt="Logo">
<h1>Agora</h1>
<p>Configuration initiale</p>
</div>
<div style="text-align: center;">
<span class="setup-badge">
<i data-lucide="shield" style="width: 14px; height: 14px;"></i>
Création du compte administrateur
</span>
</div>
<% if (error) { %>
<div class="setup-error" style="margin-bottom: 1rem;">
<%= error %>
</div>
<% } %>
<div id="setup-client-error" class="setup-error" style="margin-bottom: 1rem; display: none;"></div>
<form class="setup-form" id="setup-form" action="/setup" method="POST">
<div>
<label for="setup-username">Nom d'utilisateur</label>
<input type="text" id="setup-username" name="username" placeholder="admin" required
minlength="3" maxlength="32" pattern="[a-zA-Z0-9_.\-]+" autofocus autocomplete="username">
</div>
<div class="password-requirements" style="text-align: left;">
<strong>Exigences du mot de passe :</strong>
<ul style="margin-top: 8px;">
<li id="req-length" class="invalid" style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><span class="icon-holder"><i data-lucide="x" style="width:14px;height:14px;"></i></span> Au moins 8 caractères</li>
<li id="req-upper" class="invalid" style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><span class="icon-holder"><i data-lucide="x" style="width:14px;height:14px;"></i></span> Au moins une majuscule (A-Z)</li>
<li id="req-number" class="invalid" style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><span class="icon-holder"><i data-lucide="x" style="width:14px;height:14px;"></i></span> Au moins un chiffre (0-9)</li>
<li id="req-special" class="invalid" style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><span class="icon-holder"><i data-lucide="x" style="width:14px;height:14px;"></i></span> Au moins un caractère spécial</li>
<li id="req-match" class="invalid" style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><span class="icon-holder"><i data-lucide="x" style="width:14px;height:14px;"></i></span> Mots de passe identiques</li>
</ul>
</div>
<div>
<label for="setup-password">Mot de passe</label>
<div class="password-container">
<input type="password" id="setup-password" name="password" placeholder="Faut sécuriser le compte !"
required minlength="8" maxlength="128" autocomplete="new-password">
<button type="button" class="toggle-password" tabindex="-1">
<i data-lucide="eye" class="eye-icon"></i>
</button>
</div>
</div>
<div>
<label for="setup-confirm">Confirmer le mot de passe</label>
<div class="password-container">
<input type="password" id="setup-confirm" name="confirmPassword" placeholder="Retapez le mot de passe"
required minlength="8" maxlength="128" autocomplete="new-password">
<button type="button" class="toggle-password" tabindex="-1">
<i data-lucide="eye" class="eye-icon"></i>
</button>
</div>
</div>
<% if (typeof pluginsToConfigure !== 'undefined' && pluginsToConfigure.length > 0) { %>
<div style="margin: 2rem 0; border-top: 1px solid var(--border); padding-top: 1.5rem; text-align: left;">
<h3 style="margin-bottom: 1rem; color: var(--text-main); font-size: 1.1rem; display: flex; align-items: center; gap: 8px;">
<i data-lucide="plug" style="width: 18px; height: 18px; color: var(--primary);"></i>
Configuration des Plugins (Optionnel)
</h3>
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1.5rem; line-height: 1.4;">
Des sources ont été détectées. Vous pouvez les configurer maintenant ou plus tard dans les paramètres.
</p>
<% pluginsToConfigure.forEach(function(plugin) { %>
<div style="background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem;">
<strong style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.8rem; color: var(--text-main); font-size: 0.95rem; text-transform: capitalize;">
<i data-lucide="box" style="width: 14px; height: 14px; color: var(--text-sec);"></i>
<%= plugin.name %>
</strong>
<% plugin.fields.forEach(function(field) { %>
<div style="margin-bottom: 0.8rem;">
<label for="config_<%= field.key %>" style="font-size: 0.8rem; color: var(--text-sec); margin-bottom: 4px; display: block;"><%= field.label %></label>
<input type="text" id="config_<%= field.key %>" name="config[<%= field.key %>]"
placeholder="<%= field.placeholder %>" value="<%= field.default || '' %>"
style="padding: 8px; font-size: 0.9rem; width: 100%; border: 1px solid var(--border); background: var(--bg-main); color: var(--text-main); border-radius: 6px;">
</div>
<% }); %>
</div>
<% }); %>
</div>
<% } %>
<button type="submit" id="setup-submit-btn" disabled>Créer le compte administrateur</button>
<div style="text-align: center; margin-top: 3rem; margin-bottom: 1rem;">
<p style="font-size: 0.85rem; color: var(--text-sec); display: inline-flex; align-items: center; gap: 6px; background: var(--bg-card); padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);">
<i data-lucide="info" style="width: 14px; height: 14px;"></i>
Agora v<%= appVersion %>
</p>
</div>
</form>
</div>
</div>
<script>
if (typeof lucide !== 'undefined') lucide.createIcons();
// Initialize password visibility toggles using the shared library
if (window.AuthHelpers) {
AuthHelpers.initPasswordToggles();
}
const passwordInput = document.getElementById('setup-password');
const confirmInput = document.getElementById('setup-confirm');
const submitBtn = document.getElementById('setup-submit-btn');
const validateSetupInputs = () => {
if (!window.AuthHelpers) return;
const val = passwordInput.value;
const confirmVal = confirmInput.value;
// Use the shared library validation logic
const statuses = AuthHelpers.validateComplexity(val, confirmVal);
// Use the shared library UI updater
AuthHelpers.updateRequirementsUI(document.getElementById('setup-form'), statuses);
submitBtn.disabled = !statuses.allValid;
};
passwordInput.addEventListener('input', validateSetupInputs);
confirmInput.addEventListener('input', validateSetupInputs);
document.getElementById('setup-form').addEventListener('submit', function(e) {
const password = passwordInput.value;
const confirm = confirmInput.value;
const errorDiv = document.getElementById('setup-client-error');
errorDiv.style.display = 'none';
if (password !== confirm) {
e.preventDefault();
errorDiv.textContent = 'Les mots de passe ne correspondent pas.';
errorDiv.style.display = 'block';
return;
}
});
</script>
</body>
</html>
+30
View File
@@ -0,0 +1,30 @@
<%- include('partials/header') %>
<%- include('partials/sidebar') %>
<main class="content-wrapper">
<section id="section-trending" class="section">
<div class="hero-header">
<h2>🔥 Tendances du Moment</h2>
<p>Les contenus les plus populaires en ce moment</p>
</div>
<div class="filter-pills" style="margin-bottom: 2rem;">
<label class="pill">
<input type="radio" name="trending-type" value="film" checked>
<span>Films</span>
</label>
<label class="pill">
<input type="radio" name="trending-type" value="serie">
<span>Séries</span>
</label>
</div>
<div id="trending-grid" class="media-grid">
<div class="loader-wrapper">
<div class="loader"></div>
</div>
</div>
</section>
</main>
<%- include('partials/footer') %>