Ajout galerie publique pour tous les users / anonymes
This commit is contained in:
@@ -85,6 +85,12 @@ public class PhotoController {
|
|||||||
return "mes-photos";
|
return "mes-photos";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/galerie")
|
||||||
|
public String galerie(Model model) {
|
||||||
|
model.addAttribute("photos", photoService.listPublicPhotos());
|
||||||
|
return "galerie";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface PhotoRepository extends JpaRepository<Photo, Long> {
|
public interface PhotoRepository extends JpaRepository<Photo, Long> {
|
||||||
|
|
||||||
List<Photo> findByProprietaire_Email(String email);
|
List<Photo> findByProprietaire_Email(String email);
|
||||||
|
List<Photo> findByVisibilite(Photo.Visibilite visibilite);
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ public class SecurityConfig {
|
|||||||
http
|
http
|
||||||
.userDetailsService(customUserDetailsService) // Utiliser directement le UserDetailsService
|
.userDetailsService(customUserDetailsService) // Utiliser directement le UserDetailsService
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/register", "/login", "/css/**", "/js/**").permitAll()
|
.requestMatchers("/register", "/login", "/css/**", "/js/**", "/photo/*/raw", "/galerie").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin(form -> form
|
.formLogin(form -> form
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ public interface PhotoService {
|
|||||||
Photo store(MultipartFile file, String visibilite, String ownerEmail) throws IOException;
|
Photo store(MultipartFile file, String visibilite, String ownerEmail) throws IOException;
|
||||||
Path loadAsPath(String uuidFile);
|
Path loadAsPath(String uuidFile);
|
||||||
List<Photo> listByOwner(String email);
|
List<Photo> listByOwner(String email);
|
||||||
|
List<Photo> listPublicPhotos();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,4 +64,9 @@ public class PhotoServiceImpl implements PhotoService {
|
|||||||
public List<Photo> listByOwner(String email) {
|
public List<Photo> listByOwner(String email) {
|
||||||
return photoRepository.findByProprietaire_Email(email);
|
return photoRepository.findByProprietaire_Email(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Photo> listPublicPhotos() {
|
||||||
|
return photoRepository.findByVisibilite(Photo.Visibilite.PUBLIC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/main/resources/templates/galerie.html
Normal file
17
src/main/resources/templates/galerie.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head><meta charset="utf-8"><title>Galerie</title></head>
|
||||||
|
<body>
|
||||||
|
<h1>Galerie publique</h1>
|
||||||
|
|
||||||
|
<p><a th:href="@{/}">Accueil</a></p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li th:each="p : ${photos}">
|
||||||
|
<span th:text="${p.nomFichierOriginal}">nom</span>
|
||||||
|
—
|
||||||
|
<a th:href="@{'/photo/' + ${p.id} + '/raw'}" target="_blank">Voir</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<h1>Bienvenue sur FotoSharing<span th:if="${prenom}" th:text="' : ' + ${prenom}"></span></h1>
|
<h1>Bienvenue sur FotoSharing<span th:if="${prenom}" th:text="' : ' + ${prenom}"></span></h1>
|
||||||
<p><a th:href="@{/upload}">Uploader une photo</a></p>
|
<p><a th:href="@{/upload}">Uploader une photo</a></p>
|
||||||
<p><a th:href="@{/mes-photos}">Voir mes photos</a></p>
|
<p><a th:href="@{/mes-photos}">Voir mes photos</a></p>
|
||||||
|
<p><a th:href="@{/galerie}">Voir la galerie publique</a></p>
|
||||||
<p>
|
<p>
|
||||||
<form th:action="@{/logout}" method="post" style="display: inline;">
|
<form th:action="@{/logout}" method="post" style="display: inline;">
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
|
|||||||
@@ -19,5 +19,6 @@
|
|||||||
Erreur d'authentification.
|
Erreur d'authentification.
|
||||||
</div>
|
</div>
|
||||||
<p><a th:href="@{/register}">Créer un compte</a></p>
|
<p><a th:href="@{/register}">Créer un compte</a></p>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -22,5 +22,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -13,5 +13,6 @@
|
|||||||
<label>Mot de passe: <input th:field="*{motDePasse}" type="password"/></label><br/>
|
<label>Mot de passe: <input th:field="*{motDePasse}" type="password"/></label><br/>
|
||||||
<button type="submit">Créer</button>
|
<button type="submit">Créer</button>
|
||||||
</form>
|
</form>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
</label><br/>
|
</label><br/>
|
||||||
<button type="submit">Envoyer</button>
|
<button type="submit">Envoyer</button>
|
||||||
</form>
|
</form>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
<div th:if="${error}" th:text="${error}"></div>
|
<div th:if="${error}" th:text="${error}"></div>
|
||||||
<div th:if="${message}" th:text="${message}"></div>
|
<div th:if="${message}" th:text="${message}"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17
target/classes/templates/galerie.html
Normal file
17
target/classes/templates/galerie.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head><meta charset="utf-8"><title>Galerie</title></head>
|
||||||
|
<body>
|
||||||
|
<h1>Galerie publique</h1>
|
||||||
|
|
||||||
|
<p><a th:href="@{/}">Accueil</a></p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li th:each="p : ${photos}">
|
||||||
|
<span th:text="${p.nomFichierOriginal}">nom</span>
|
||||||
|
—
|
||||||
|
<a th:href="@{'/photo/' + ${p.id} + '/raw'}" target="_blank">Voir</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<h1>Bienvenue sur FotoSharing<span th:if="${prenom}" th:text="' : ' + ${prenom}"></span></h1>
|
<h1>Bienvenue sur FotoSharing<span th:if="${prenom}" th:text="' : ' + ${prenom}"></span></h1>
|
||||||
<p><a th:href="@{/upload}">Uploader une photo</a></p>
|
<p><a th:href="@{/upload}">Uploader une photo</a></p>
|
||||||
<p><a th:href="@{/mes-photos}">Voir mes photos</a></p>
|
<p><a th:href="@{/mes-photos}">Voir mes photos</a></p>
|
||||||
|
<p><a th:href="@{/galerie}">Voir la galerie publique</a></p>
|
||||||
<p>
|
<p>
|
||||||
<form th:action="@{/logout}" method="post" style="display: inline;">
|
<form th:action="@{/logout}" method="post" style="display: inline;">
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
|
|||||||
@@ -19,5 +19,6 @@
|
|||||||
Erreur d'authentification.
|
Erreur d'authentification.
|
||||||
</div>
|
</div>
|
||||||
<p><a th:href="@{/register}">Créer un compte</a></p>
|
<p><a th:href="@{/register}">Créer un compte</a></p>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -22,5 +22,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -13,5 +13,6 @@
|
|||||||
<label>Mot de passe: <input th:field="*{motDePasse}" type="password"/></label><br/>
|
<label>Mot de passe: <input th:field="*{motDePasse}" type="password"/></label><br/>
|
||||||
<button type="submit">Créer</button>
|
<button type="submit">Créer</button>
|
||||||
</form>
|
</form>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
</label><br/>
|
</label><br/>
|
||||||
<button type="submit">Envoyer</button>
|
<button type="submit">Envoyer</button>
|
||||||
</form>
|
</form>
|
||||||
|
<p><a th:href="@{/galerie}">Galerie publique</a></p>
|
||||||
<div th:if="${error}" th:text="${error}"></div>
|
<div th:if="${error}" th:text="${error}"></div>
|
||||||
<div th:if="${message}" th:text="${message}"></div>
|
<div th:if="${message}" th:text="${message}"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user