Mock book page
This commit is contained in:
parent
a1105f2830
commit
ae367797bb
8 changed files with 141 additions and 3 deletions
34
src/main/java/ru/redrise/marinesco/BookController.java
Normal file
34
src/main/java/ru/redrise/marinesco/BookController.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package ru.redrise.marinesco;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import ru.redrise.marinesco.data.InpEntryRepository;
|
||||||
|
import ru.redrise.marinesco.library.Author;
|
||||||
|
import ru.redrise.marinesco.library.InpEntry;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/book")
|
||||||
|
public class BookController {
|
||||||
|
InpEntryRepository inpEntryRepository;
|
||||||
|
|
||||||
|
public BookController(InpEntryRepository inpEntryRepository){
|
||||||
|
this.inpEntryRepository = inpEntryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{bookId}")
|
||||||
|
public String getPage(@PathVariable("bookId") Long bookId, Model model) {
|
||||||
|
InpEntry book = inpEntryRepository.findById(bookId).orElse(null);
|
||||||
|
if (book == null){
|
||||||
|
model.addAttribute("Error", "Not found");
|
||||||
|
return "book";
|
||||||
|
}
|
||||||
|
model.addAttribute("book", book);
|
||||||
|
return "book";
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,12 +2,20 @@ package ru.redrise.marinesco;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/")
|
||||||
public class RootController {
|
public class RootController {
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping
|
||||||
public String home(){
|
public String getPage(@ModelAttribute("search") String text) {
|
||||||
|
// TODO: SEARCH PAGE + CONTROLLER
|
||||||
|
log.info(text);
|
||||||
return "root";
|
return "root";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package ru.redrise.marinesco.library;
|
||||||
|
|
||||||
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import ru.redrise.marinesco.data.AuthorRepository;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AthorByIdConverter implements Converter<Long, Author>{
|
||||||
|
|
||||||
|
private AuthorRepository authorRepository;
|
||||||
|
|
||||||
|
public AthorByIdConverter(AuthorRepository authorRepository){
|
||||||
|
this.authorRepository = authorRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Author convert(Long id) {
|
||||||
|
return authorRepository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package ru.redrise.marinesco.library;
|
||||||
|
|
||||||
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import ru.redrise.marinesco.data.GenreRepository;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GenreByIdConverter implements Converter<String, Genre>{
|
||||||
|
|
||||||
|
private GenreRepository genreRepository;
|
||||||
|
|
||||||
|
public GenreByIdConverter(GenreRepository genreRepository){
|
||||||
|
this.genreRepository = genreRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Genre convert(String id) {
|
||||||
|
return genreRepository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -133,6 +133,9 @@ public class InpxScanner implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseInp(File inpxFile) throws Exception {
|
private void parseInp(File inpxFile) throws Exception {
|
||||||
|
log.warn("REMOVE TEMPORARY SOLUTION - BREAKER");
|
||||||
|
log.warn("REMOVE TEMPORARY SOLUTION - BREAKER");
|
||||||
|
log.warn("REMOVE TEMPORARY SOLUTION - BREAKER");
|
||||||
boolean breaker = false;
|
boolean breaker = false;
|
||||||
|
|
||||||
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(inpxFile))) {
|
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(inpxFile))) {
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
src: url('/styles/Arimo-VariableFont_wght.ttf');
|
src: url('/styles/Arimo-VariableFont_wght.ttf');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html{
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: Arimo;
|
font-family: Arimo;
|
||||||
background-color: #212121;
|
background-color: #212121;
|
||||||
|
|
40
src/main/resources/templates/book.html
Normal file
40
src/main/resources/templates/book.html
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Marinesco</title>
|
||||||
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||||
|
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
<div th:replace="~{fragments/header :: 'header'}"></div>
|
||||||
|
<div class="container base">
|
||||||
|
<span class="validationError" th:if="${Error} != null" th:text="${Error}"></span>
|
||||||
|
<div th:if="${book} != null">
|
||||||
|
<br /><span th:text="${'Title: ' + book.title}"></span>
|
||||||
|
<br /><span>Authors: </span>
|
||||||
|
<div th:each="author : ${book.authors}">
|
||||||
|
<span th:text="${' * ' + author.authorName}"></span>
|
||||||
|
</div>
|
||||||
|
<br /><span>Genres: </span>
|
||||||
|
<div th:each="genre : ${book.genres}">
|
||||||
|
<span th:text="${' * ' + genre.genreId + ' — ' + genre.humanReadableDescription}"></span>
|
||||||
|
</div>
|
||||||
|
<br /><span th:if="${book.series} != null" th:text="${'Series: ' + book.series}"></span>
|
||||||
|
<br /><span th:if="${book.serNo} != null" th:text="${'Series # : ' + book.serNo}"></span>
|
||||||
|
<br /><span th:text="${'Format: ' + book.fileExtension}"></span>
|
||||||
|
<br /><span th:if="${book.addedDate} != null" th:text="${'Added : ' + book.addedDate}"></span>
|
||||||
|
<br /><span th:text="${'Size: ' + book.fileSize + ' bytes'}"></span>
|
||||||
|
<p>
|
||||||
|
<a th:href="'/'" th:text="Download"></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -16,7 +16,14 @@
|
||||||
<br /><a href="/profile">/profile</a>
|
<br /><a href="/profile">/profile</a>
|
||||||
<br /><a href="/manage_users">/manage_users</a>
|
<br /><a href="/manage_users">/manage_users</a>
|
||||||
<br /><a href="/settings">/settings</a>
|
<br /><a href="/settings">/settings</a>
|
||||||
|
<br /><a href="/book/59992766">/book/59992766</a>
|
||||||
<br /><a href="/h2">H2</a>
|
<br /><a href="/h2">H2</a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<form action='' method='get'>
|
||||||
|
<input type='text' name='search'>
|
||||||
|
<button class="sign" type='submit'>Search</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
||||||
|
|
Loading…
Reference in a new issue