refonte arborescence + correction des chemins

This commit is contained in:
ben
2025-12-09 17:14:35 +01:00
parent f0fbae505f
commit f79ee1e7b6
40 changed files with 185 additions and 144 deletions

View File

@@ -1,7 +0,0 @@
function confirmerSuppression(titre) {
const confirmation = confirm(`Êtes-vous sûr de vouloir supprimer l'article "${titre}" ?`);
if (confirmation) {
alert(`L'article "${titre}" a été supprimé.`);
// Ici tu peux rediriger ou supprimer réellement
}
}

View File

@@ -1,68 +0,0 @@
const form = document.getElementById('editArticleForm');
const imgField = document.getElementById('articleImage');
const titleField = document.getElementById('articleTitle');
const contentField = document.getElementById('articleContent');
const categoryField = document.getElementById('articleCategory');
const publishedField = document.getElementById('articlePublished');
const errorEmpty = document.getElementById('errorEmpty');
const errorImage = document.getElementById('errorImage');
const errorExists = document.getElementById('errorExists');
const successMsg = document.getElementById('successMsg');
// Simulation BDD pour vérifier doublons
const titresExistants = [
"article de test",
"nouveautés chiens",
"actualité du mois"
];
form.addEventListener('submit', function(e) {
e.preventDefault();
const titre = titleField.value.trim().toLowerCase();
const fichierImage = imgField.files[0];
// Reset messages
errorEmpty.classList.add('d-none');
errorImage.classList.add('d-none');
errorExists.classList.add('d-none');
successMsg.classList.add('d-none');
//Titre obligatoire
if (titre === "") {
errorEmpty.classList.remove('d-none');
return;
}
// Titre déjà existant ?
if (titresExistants.includes(titre)) {
errorExists.classList.remove('d-none');
return;
}
//Vérification image
if (fichierImage) {
const validFormats = ['image/jpeg', 'image/png', 'image/gif'];
if (!validFormats.includes(fichierImage.type)) {
errorImage.classList.remove('d-none');
return;
}
}
// Succès
successMsg.classList.remove('d-none');
console.log("Article modifié :", {
titre,
contenu: contentField.value,
categorie: categoryField.value,
publie: publishedField.checked,
image: fichierImage ? fichierImage.name : "Image inchangée"
});
});

View File

@@ -6,6 +6,9 @@
<title>Ajouter un article</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/ckeditor.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/translations/fr.js"></script>
@@ -17,6 +20,9 @@
max-width: 700px;
margin: 40px auto;
}
.ck-editor__editable {
min-height: 350px;
}
</style>
</head>
<body>
@@ -78,27 +84,39 @@
<!--Publié-->
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="articlePublished">
<label class="form-check-label" for="articlePublished">Publié</label>
<label class="form-check-label" for="articlePublished">Publié (sera publié sur le blog)</label>
</div>
<!--Boutons-->
<div class="d-flex gap-3 mt-4">
<a href="../../../blog/categories/articles/liste_article.html" class="btn btn-secondary w-50">Annuler</a>
<a href="../html/liste_article.html" class="btn btn-secondary w-50">Annuler</a>
<button type="submit" class="btn btn-primary w-50">Ajouter</button>
</div>
</form>
</div>
<script src="ajouter_article.js"></script>
<script src="../js/ajouter_article.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
ClassicEditor
.create(document.querySelector('#articleContent'))
.catch(error => {
console.error(error);
});
ClassicEditor
.create(document.querySelector('#articleContent'), {
language: 'fr',
toolbar: [
'heading',
'bold', 'italic', 'underline',
'bulletedList', 'numberedList',
'undo', 'redo'
]
})
.catch(error => {
console.error(error);
});
</script>
</body>

View File

@@ -50,7 +50,7 @@
</form>
</div>
<script src="ajouter.js"></script>
<script src="../js/ajouter_categorie.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@@ -33,22 +33,32 @@
</tr>
</thead>
<tbody>
<!--Exemple d'article-->
<tr>
<td>Mon premier article</td>
<td>Chien</td>
<td>Oui</td>
<td>
<a href="voir_article.html" class="btn btn-sm btn-outline-secondary">Voir</a>
<a href="modifier_article.html" class="btn btn-sm btn-outline-primary">Modifier</a>
<button class="btn btn-sm btn-outline-danger" onclick="confirmerSuppression('Mon premier article')">Supprimer</button>
</td>
</tr>
</tbody>
<tr>
<td>Mon premier article</td>
<td>Chien</td>
<td>Oui</td>
<td>
<a href="voir_article.html" class="btn btn-sm btn-outline-secondary">Voir</a>
<a href="../html/modifier_article.html" class="btn btn-sm btn-outline-primary">Modifier</a>
<button class="btn btn-sm btn-outline-danger delete-btn">Supprimer</button>
</td>
</tr>
<tr>
<td>Mon deuxième article</td>
<td>Chat</td>
<td>Oui</td>
<td>
<a href="voir_article.html" class="btn btn-sm btn-outline-secondary">Voir</a>
<a href="../html/modifier_article.html" class="btn btn-sm btn-outline-primary">Modifier</a>
<button class="btn btn-sm btn-outline-danger delete-btn">Supprimer</button>
</td>
</tr>
</tbody>
</table>
</div>
<script src="../js/liste_articles.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

View File

@@ -28,7 +28,7 @@
<!-- Bouton ajouter -->
<div class="d-flex justify-content-end mb-4">
<a href="../ajouter_categorie/ajouter_categorie.html" class="btn btn-primary">
<a href="../html/ajouter_categorie.html" class="btn btn-primary">
Ajouter une catégorie
</a>
</div>
@@ -48,7 +48,7 @@
</table>
</div>
<script src="liste_categorie.js"></script>
<script src="../js/liste_categorie.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@@ -6,6 +6,7 @@
<title>Modifier un article</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/ckeditor.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/translations/fr.js"></script>
<style>
@@ -17,9 +18,12 @@
margin-top: 40px;
}
.preview-img {
max-width: 15Opx;
max-width: 15px;
border-radius: 8px
}
.ck-editor__editable {
min-height: 350px;
}
</style>
</head>
@@ -99,7 +103,7 @@
<!--Boutons-->
<div class="d-flex gap-3 mt-4">
<a href="../../../blog/categories/articles/liste_article.html" class="btn btn-secondary w-50">Annuler</a>
<a href="../html/liste_article.html" class="btn btn-secondary w-50">Annuler</a>
<button type="submit" class="btn btn-primary w-50">Enregistrer</button>
</div>
@@ -109,37 +113,22 @@
<script>
ClassicEditor
.create(document.querySelector('#articleContent'))
.catch(error => {
console.error(error);
});
.create(document.querySelector('#articleContent'), {
language: 'fr',
toolbar: [
'heading',
'bold', 'italic', 'underline',
'bulletedList', 'numberedList',
'undo', 'redo'
]
})
</script>
<script src="modifier_article.js"></script>
<script src="../js/modifier_article.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -49,6 +49,7 @@
</form>
</div>
<script src="../js/modifier_categorie.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

View File

@@ -1,4 +1,4 @@
const form = document.getElementById('addArticleForm');
const form = document.getElementById('ajouterArticleForm');
const imgField = document.getElementById('articleImage');
const titleField = document.getElementById('articleTitle');
const contentField = document.getElementById('articleContent');
@@ -16,7 +16,7 @@ const titreExistants = ['décoration noel', 'coupe de chien'];
form.addEventListener('submit', function(e) {
e.preventDefault();
const titre = titleField.value.trim() .toLowerCase();
const titre = titleField.value.trim().toLowerCase();
const fichierImage = imgField.files[0];
// Reset messages
@@ -49,4 +49,11 @@ form.addEventListener('submit', function(e) {
// Simuler enregistrement
titreExistants.push(titre);
// Succès
successMsg.classList.remove('d-none');
// Redirection après 1 seconde
setTimeout(() => {
window.location.href = "../html/liste_article.html";
}, 1000);
});

View File

@@ -32,12 +32,16 @@ form.addEventListener("submit", function (e) {
return;
}
//Succès
successMessage.classList.remove("d-none");
// Succès
successMessage.classList.remove("d-none");
// Ajout d'une nouvelle catégorie
existingCategories.push(nom);
//Ajout d'une nouvelle catégorie en BDD
existingCategories.push(nom);
// Redirection après 1 seconde
setTimeout(() => {
window.location.href = "../html/liste_categorie.html";
}, 1000);
});

14
blog/js/liste_articles.js Normal file
View File

@@ -0,0 +1,14 @@
document.addEventListener("click", function (e) {
const btn = e.target.closest(".delete-btn");
if (!btn) return; // on a cliqué ailleurs
// On récupère la ligne de l'article
const row = btn.closest("tr");
const titre = row.querySelector("td").textContent.trim();
if (confirm(`Voulez-vous vraiment supprimer l'article : "${titre}" ?`)) {
row.remove(); // supprime la ligne
alert("Article supprimé !");
}
});

View File

@@ -20,7 +20,7 @@ function afficherCategories() {
<td>${cat.description || "-"}</td>
<td class="text-center">
<a href="../modifier_categorie/modifier_categorie.html?id=${cat.id}" class="btn btn-warning btn-sm">
<a href="../html/modifier_categorie.html?id=${cat.id}" class="btn btn-warning btn-sm">
Modifier
</a>

View File

@@ -0,0 +1,60 @@
const form = document.getElementById("editArticleForm");
const imgField = document.getElementById("articleImage");
const titleField = document.getElementById("articleTitle");
const contentField = document.getElementById("articleContent");
const categoryField = document.getElementById("articleCategory");
const publishedField = document.getElementById("articlePublished");
const errorEmpty = document.getElementById("errorEmpty");
const errorImage = document.getElementById("errorImage");
const errorExists = document.getElementById("errorExists");
const successMsg = document.getElementById("successMsg");
// Simulation BDD pour vérifier doublons
const titresExistants = [
"article de test",
"nouveautés chiens",
"actualité du mois",
];
form.addEventListener("submit", function (e) {
e.preventDefault();
const titre = titleField.value.trim().toLowerCase();
const fichierImage = imgField.files[0];
// Reset messages
errorEmpty.classList.add("d-none");
errorImage.classList.add("d-none");
errorExists.classList.add("d-none");
successMsg.classList.add("d-none");
//Titre obligatoire
if (titre === "") {
errorEmpty.classList.remove("d-none");
return;
}
// Titre déjà existant ?
if (titresExistants.includes(titre)) {
errorExists.classList.remove("d-none");
return;
}
//Vérification image
if (fichierImage) {
const validFormats = ["image/jpeg", "image/png", "image/gif"];
if (!validFormats.includes(fichierImage.type)) {
errorImage.classList.remove("d-none");
return;
}
}
// Succès
successMsg.classList.remove("d-none");
// Redirection après succès
setTimeout(() => {
window.location.href = "../html/liste_article.html";
}, 1500);
});

View File

@@ -21,6 +21,6 @@ form.addEventListener("submit", function (e) {
// Redirection après succès
setTimeout(() => {
window.location.href = "../../../blog/categories/liste_categorie/liste_categorie.html";
window.location.href = "../html/liste_categorie.html";
}, 1500);
});

View File

@@ -11,7 +11,7 @@
<style>
body {
background: #f4f6f981;
background: #f4f6f981;
height: 100vh;
display: flex;
justify-content: center;
@@ -27,10 +27,14 @@
<div class="card shadow forgot-password-card">
<div class="card-body p-4">
<h3 class="text-center mb-4">Mot de passe oublié</h3>
<p>
Nous avons besoin de votre adresse mail pour pouvoir réinitialiser
votre mot de passe.
</p>
<form>
<div class="mb-3">
<label class="form-label">Adresse e-mail</label>
<input
type="email"
class="form-control"
@@ -43,7 +47,9 @@
</button>
<div class="text-center mt-3">
<a href="../page_de_connexion/page_de_connexion.html" class="text-decoration-none"
<a
href="../html/page_de_connexion.html"
class="text-decoration-none"
>Retour à la connexion</a
>
</div>

View File

@@ -30,14 +30,15 @@
<form>
<div class="mb-3">
<label class="form-label">Mot de passe</label>
<input
type="password"
class="form-control"
id="password"
placeholder="••••••••"
/>
<label for="showPassword">
<label for="showPassword" class="mt-2">
<input type="checkbox" id="showPassword" />
Voir le mot de passe
</label>
@@ -46,12 +47,12 @@
<button class="btn btn-primary w-100">Se connecter</button>
<div class="text-center mt-3">
<a href="../mot_de_passe_oublie/mot_de_passe_oublie.html" class="text-decoration-none">Mot de passe oublié ?</a>
<a href="../html/mot_de_passe_oublie.html" class="text-decoration-none">Mot de passe oublié ?</a>
</div>
</form>
</div>
</div>
<script src="page_de_connexion.js"></script>
<script src="../js/page_de_connexion.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -52,7 +52,7 @@
id="password"
required
/>
<small id="passwordIndicator" class="fw-bold"</small>
<small id="passwordIndicator" class="fw-bold"></small>
</div>
<div class="mb-3">
@@ -65,7 +65,7 @@
id="confirmPassword"
required
/>
<label for="showPassword">
<label for="showPassword" class="mt-3">
<input type="checkbox" id="showPassword" />
Voir le mot de passe
</label>
@@ -89,7 +89,7 @@
</form>
</div>
</div>
<script src="reinitialisation_du_mot_de_passe.js"></script>
<script src="../js/reinitialisation_du_mot_de_passe.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -49,6 +49,12 @@ form.addEventListener('submit', function(e) {
errorMsg.textContent = 'Les mots de passe ne correspondent pas.';
return;
}
successMsg.style.display = 'block';
// Redirection après 1 seconde
setTimeout(() => {
window.location.href = "../html/page_de_connexion.html";
}, 1000);
});