Skip to content

Commit

Permalink
apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Sep 27, 2024
1 parent 47ecd0c commit d93e6ea
Show file tree
Hide file tree
Showing 26 changed files with 235 additions and 143 deletions.
3 changes: 2 additions & 1 deletion src/main/java/ch/puzzle/eft/ExamFeedbackToolApplication.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package ch.puzzle.eft;

import nz.net.ultraq.thymeleaf.layoutdialect.LayoutDialect;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import nz.net.ultraq.thymeleaf.layoutdialect.LayoutDialect;

@SpringBootApplication
public class ExamFeedbackToolApplication {

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/ch/puzzle/eft/controller/ExamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

@RestController
@RequestMapping("/exams")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@


import ch.puzzle.eft.model.ErrorModel;
import jakarta.servlet.http.HttpServletRequest;
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;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

@ControllerAdvice
@Controller
public class ExceptionController implements ErrorController {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ch/puzzle/eft/controller/SiteController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package ch.puzzle.eft.controller;

import java.util.Objects;

import ch.puzzle.eft.model.ExamNumberForm;
import ch.puzzle.eft.service.ExamService;
import jakarta.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.server.ResponseStatusException;

import java.util.Objects;
import jakarta.validation.Valid;

@Controller
public class SiteController {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/puzzle/eft/model/ExamModel.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package ch.puzzle.eft.model;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;

import java.io.File;

public class ExamModel {
private final File file;
private static final Logger logger = LoggerFactory.getLogger(ExamModel.class);
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/ch/puzzle/eft/service/ExamService.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package ch.puzzle.eft.service;

import ch.puzzle.eft.model.ExamModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
Expand All @@ -17,6 +9,15 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import ch.puzzle.eft.model.ExamModel;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;

@Service
public class ExamService {
private static final Logger logger = LoggerFactory.getLogger(ExamService.class);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/puzzle/eft/service/ValidationService.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ch.puzzle.eft.service;

import org.springframework.stereotype.Service;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.stereotype.Service;

@Service
public class ValidationService {
private static final Pattern EXAM_NUMBER_PATTERN = Pattern.compile("^\\d{5}$");
Expand Down
43 changes: 31 additions & 12 deletions src/main/resources/static/styles/custom_bootstrap.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
:root {
--primary-rgb: 229, 0, 125;
--primary-hex: rgba(var(--bs-primary-rgb),1);
--primary-hex: rgba(var(--bs-primary-rgb), 1);
/*bootstrap*/
--bs-primary-rgb: var(--primary-rgb);
--bs-secondary-rgb: 0, 0,0;
--bs-secondary-rgb: 0, 0, 0;


--bs-primary-link-hover-color-rgb: 0,0,0;
--bs-primary-link-hover-color-rgb: 0, 0, 0;
--bs-secondary-link-hover-color-rgb: var(--bs-primary-rgb);

--button-primary-color: var(--primary-hex);
Expand All @@ -29,14 +28,34 @@
--bs-gradient: none;
}

.link-primary:focus, .link-primary:hover {
color: RGBA(var(--bs-primary-link-hover-color-rgb), var(--bs-link-opacity, 1)) !important;
-webkit-text-decoration-color: RGBA(var(--bs-primary-link-hover-color-rgb), var(--bs-link-underline-opacity, 1)) !important;
text-decoration-color: RGBA(var(--bs-primary-link-hover-color-rgb), var(--bs-link-underline-opacity, 1)) !important;
.link-primary:focus,
.link-primary:hover {
color: RGBA(
var(--bs-primary-link-hover-color-rgb),
var(--bs-link-opacity, 1)
) !important;
-webkit-text-decoration-color: RGBA(
var(--bs-primary-link-hover-color-rgb),
var(--bs-link-underline-opacity, 1)
) !important;
text-decoration-color: RGBA(
var(--bs-primary-link-hover-color-rgb),
var(--bs-link-underline-opacity, 1)
) !important;
}

.link-secondary:focus, .link-secondary:hover {
color: RGBA(var(--bs-secondary-link-hover-color-rgb), var(--bs-link-opacity, 1)) !important;
-webkit-text-decoration-color: RGBA(var(--bs-secondary-link-hover-color-rgb), var(--bs-link-underline-opacity, 1)) !important;
text-decoration-color: RGBA(var(--bs-secondary-link-hover-color-rgb), var(--bs-link-underline-opacity, 1)) !important;
.link-secondary:focus,
.link-secondary:hover {
color: RGBA(
var(--bs-secondary-link-hover-color-rgb),
var(--bs-link-opacity, 1)
) !important;
-webkit-text-decoration-color: RGBA(
var(--bs-secondary-link-hover-color-rgb),
var(--bs-link-underline-opacity, 1)
) !important;
text-decoration-color: RGBA(
var(--bs-secondary-link-hover-color-rgb),
var(--bs-link-underline-opacity, 1)
) !important;
}
2 changes: 1 addition & 1 deletion src/main/resources/static/styles/header.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#logo {
height: 70px;
}
}
5 changes: 3 additions & 2 deletions src/main/resources/static/styles/styles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@font-face {
font-family: OpenSans, sans-serif;
src: url('../fonts/Open_Sans/OpenSans-Regular.ttf') format('truetype');
url('../fonts/Open_Sans/OpenSans-Regular.woff2') format('woff2');
src:
url("../fonts/Open_Sans/OpenSans-Regular.ttf") format("truetype"),
url("../fonts/Open_Sans/OpenSans-Regular.woff2") format("woff2");
}

body {
Expand Down
24 changes: 13 additions & 11 deletions src/main/resources/templates/error.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.html}" lang="">
<body>
<section layout:fragment="content">
<div th:replace="~{fragments/internal-server-error}"></div>
<div th:replace="~{fragments/not-found-error}"></div>
<a href="/return" class="link-secondary">Zurück zur Startseite</a>
</section>
</body>
</html>
<!doctype html>
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.html}"
lang="">
<body>
<section layout:fragment="content">
<div th:replace="~{fragments/internal-server-error}"></div>
<div th:replace="~{fragments/not-found-error}"></div>
<a href="/return" class="link-secondary">Zurück zur Startseite</a>
</section>
</body>
</html>
5 changes: 4 additions & 1 deletion src/main/resources/templates/fragments/exam-file.html
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<a th:href="@{|/exams/download/${examFile.getSubjectName}/${examNumberForm.getExamNumber()}|}" th:text="${examFile.getSubjectName()}" class="link-primary"></a>
<a
th:href="@{|/exams/download/${examFile.getSubjectName}/${examNumberForm.getExamNumber()}|}"
th:text="${examFile.getSubjectName()}"
class="link-primary"></a>
30 changes: 25 additions & 5 deletions src/main/resources/templates/fragments/exam-number-input.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
<form action="#" th:action="@{/search}" th:object="${examNumberForm}" method="post" class="was-validated ">
<form
action="#"
th:action="@{/search}"
th:object="${examNumberForm}"
method="post"
class="was-validated">
<label for="examNumber">Prüfungsnummer eingeben:</label>
<span class="d-flex">
<input type="text" pattern="^\d+$" name="examNumber" id="examNumber" placeholder="20202" th:value="*{examNumber}" th:maxlength="5" class="form-control">
<button type="submit" id="submitButton" class="btn btn-outline-primary">Suchen</button>
<input
type="text"
pattern="^\d+$"
name="examNumber"
id="examNumber"
placeholder="20202"
th:value="*{examNumber}"
th:maxlength="5"
class="form-control" />
<button type="submit" id="submitButton" class="btn btn-outline-primary">
Suchen
</button>
</span>

<p th:if="${#fields.hasErrors('examNumber')}" th:errors="*{examNumber}" class="text-danger">Prüfungsnummer Error</p>
</form>
<p
th:if="${#fields.hasErrors('examNumber')}"
th:errors="*{examNumber}"
class="text-danger">
Prüfungsnummer Error
</p>
</form>
17 changes: 13 additions & 4 deletions src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<footer class="w-100 position-absolute z-1 bottom-0 bg-white">
<hr class="mt-0">
<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}">
<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>
<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>
17 changes: 12 additions & 5 deletions src/main/resources/templates/fragments/header.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<header class="d-flex p-2 pb-0 align-items-center justify-content-between">
<a href="/">
<img alt="image not found" class="m-4" id="logo" th:src="@{images/UNILU_Schriftzug_Standard_schwarz_DE.png}">
<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-->
<p class="me-3 fs-3 text-end">Sven Studi</p>
<!--Todo wenn login funktioniert auf eingeloggten user ändern-->
<div class="me-3 d-flex gap-3 flex-row">
<a class="link-primary" th:href="@{/search}">Prüfungslaufnummer</a>
<a class="link-primary" th:href="'#'">Kontakt</a><!--Todo wenn contact.html existiert-->
<a class="link-primary" th:href="'#'">Logout</a> <!--Todo wenn login funktioniert-->
<a class="link-primary" th:href="'#'">Kontakt</a>
<!--Todo wenn contact.html existiert-->
<a class="link-primary" th:href="'#'">Logout</a>
<!--Todo wenn login funktioniert-->
</div>
</div>
</header>
<hr class="mt-0">
<hr class="mt-0" />
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div th:if="${session.get('errorModel') != null and session.get('errorModel').getError().equals('unknown')}">
<div
th:if="${session.get('errorModel') != null and session.get('errorModel').getError().equals('unknown')}">
<h1>Ein unerwarteter Fehler ist aufgetreten.</h1>
<p th:text="${session.get('errorModel').getErrorMessage()}"></p>
<p>Kontaktiere
<a class="link-secondary" href="mailto: [email protected]">[email protected].</a>
<p>
Kontaktiere
<a class="link-secondary" href="mailto: [email protected]">
[email protected].
</a>
</p>
</div>
</div>
12 changes: 8 additions & 4 deletions src/main/resources/templates/fragments/not-found-error.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div th:if="${session.get('errorModel') == null or session.get('errorModel').getError() == '404'}">
<div
th:if="${session.get('errorModel') == null or session.get('errorModel').getError() == '404'}">
<h1>Die gesuchte Seite wurde nicht gefunden.</h1>
<p>Versuche eine Prüfung zu
<p>
Versuche eine Prüfung zu
<a href="/search" class="link-secondary">suchen</a>
oder gehe zurück zur <a href="/" class="link-secondary">Startseite</a>.
oder gehe zurück zur
<a href="/" class="link-secondary">Startseite</a>
.
</p>
</div>
</div>
18 changes: 11 additions & 7 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.html}" lang="">
<!doctype html>
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout.html}"
lang="">
<body>
<section layout:fragment="content">
<span class="display-4">Willkommen bei der Prüfungsabfrage der Uni Luzern</span>
</section>
<section layout:fragment="content">
<span class="display-4">
Willkommen bei der Prüfungsabfrage der Uni Luzern
</span>
</section>
</body>
</html>
</html>
Loading

0 comments on commit d93e6ea

Please sign in to comment.