Skip to content

Commit

Permalink
Feature/62 Footer of application (#95)
Browse files Browse the repository at this point in the history
* Add footer fragment and first couple styling elements

* Add styling to footer

* get version number from pom.xml

---------

Co-authored-by: Nevio Di Gennaro <[email protected]>
  • Loading branch information
ManuelMoeri and nevio18324 authored Sep 26, 2024
1 parent 7d930c5 commit 759a993
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
import jakarta.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.servlet.resource.NoResourceFoundException;

@ControllerAdvice
@Controller
public class ExceptionController implements ErrorController {

private static final Logger logger = LoggerFactory.getLogger(ExceptionController.class);
private static final String ERROR_MODEL = "errorModel";

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/puzzle/eft/controller/SiteController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@Controller
public class SiteController {

private final ExamService examFileService;
private static final String SEARCH_TEMPLATE = "search";
private final ExamService examFileService;

public SiteController(ExamService examFileService) {
this.examFileService = examFileService;
Expand All @@ -27,6 +27,7 @@ public String viewIndexPage(Model model) {
return "index";
}


@GetMapping("/search")
public String viewSearchPage(Model model) {
model.addAttribute("examNumberForm", new ExamNumberForm(null));
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
spring.application.name=exam-feedback-tool
server.servlet.session.cookie.same-site=strict
server.error.path=redirect:/error

spring.application.version[email protected]@
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
12 changes: 12 additions & 0 deletions src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<footer class="w-100 position-absolute z-1 bottom-0 bg-white">
<hr class="mt-0">
<div class="p-3 align-items-center justify-content-between d-flex">
<a href="https://www.swissuniversities.ch/" target="_blank">
<img alt="Swissuniversities logo" height="22px" th:src="@{images/swissuniversities.png}">
</a>
<div class="d-flex justify-content-end gap-4">
<a class="link-primary" href="https://www.unilu.ch/impressum/" target="_blank">Impressum & Datenschutz</a>
<span th:text="${'Version ' + @environment.getProperty('spring.application.version')}"></span>
</div>
</div>
</footer>
8 changes: 1 addition & 7 deletions src/main/resources/templates/fragments/header.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<!DOCTYPE html>
<html>
<head>

</head>
<header class="d-flex p-2 pb-0 align-items-center justify-content-between">
<a href="/">
<img class="m-4" id="logo" th:src="@{images/UNILU_Schriftzug_Standard_schwarz_DE.png}" alt="image not found">
<img alt="image not found" class="m-4" id="logo" th:src="@{images/UNILU_Schriftzug_Standard_schwarz_DE.png}">
</a>
<div class="d-flex justify-content-end flex-column">
<p class="me-3 fs-3 text-end">Sven Studi</p><!--Todo wenn login funktioniert auf eingeloggten user ändern-->
Expand All @@ -17,4 +12,3 @@
</div>
</header>
<hr class="mt-0">
</html>
17 changes: 10 additions & 7 deletions src/main/resources/templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" lang="">
<html lang="" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<script th:src="@{javascript/bootstrap.bundle.min.js}" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"></script>
<link th:href="@{styles/bootstrap.min.css}" rel="stylesheet" type="text/css">
<link th:href="@{styles/custom_bootstrap.css}" rel="stylesheet" type="text/css">
<link th:href="@{styles/styles.css}" rel="stylesheet" type="text/css">
<link th:href="@{styles/header.css}" rel="stylesheet" type="text/css">
<script integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
th:src="@{javascript/bootstrap.bundle.min.js}"></script>
<link rel="stylesheet" th:href="@{styles/bootstrap.min.css}" type="text/css">
<link rel="stylesheet" th:href="@{styles/custom_bootstrap.css}" type="text/css">
<link rel="stylesheet" th:href="@{styles/styles.css}" type="text/css">
<link rel="stylesheet" th:href="@{styles/header.css}" type="text/css">
<link rel="stylesheet" th:href="@{styles/footer.css}" type="text/css">
<title>Universität Luzern - Prüfungen</title>
<link th:href="@{favicon.ico}" rel="icon" type="image/png">
<link rel="icon" th:href="@{favicon.ico}" type="image/png">
</head>
<body>
<header th:replace="~{fragments/header}"></header>
Expand All @@ -18,5 +20,6 @@
</section>
</div>
</div>
<footer th:replace="~{fragments/footer}"></footer>
</body>
</html>
21 changes: 21 additions & 0 deletions src/test/e2e/cypress/e2e/footer.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
beforeEach(() => {
cy.visit("/");
})

it('should display the right image', () => {
cy.get("footer").find("img")
.should('have.attr', 'src')
.and('include', 'swissuniversities.png');
})

it('should redirect to swissuniversities', () => {
cy.get("footer").find("a").eq(0)
.should('have.attr', 'href')
.and('include', 'https://www.swissuniversities.ch/');
});

it('should redirect to impressum', () => {
cy.get("footer").find("a").eq(1)
.should('have.attr', 'href')
.and('include', 'https://www.unilu.ch/impressum/');
});

0 comments on commit 759a993

Please sign in to comment.