Compare commits

..

No commits in common. "509d31e1d874c1f74883eb72c5cc1f27b25219c7" and "00f277797ed38e8a1574991e619383582a5988eb" have entirely different histories.

7 changed files with 8 additions and 97 deletions

View file

@ -1,43 +0,0 @@
package ru.redrise.marinesco;
import java.util.List;
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 ru.redrise.marinesco.data.AuthorRepository;
import ru.redrise.marinesco.data.BookRepository;
import ru.redrise.marinesco.library.Author;
import ru.redrise.marinesco.library.Book;
@Controller
@RequestMapping("/author")
public class AuthorController {
private AuthorRepository authorRepository;
private BookRepository bookRepository;
public AuthorController(AuthorRepository authorRepository, BookRepository bookRepository){
this.authorRepository = authorRepository;
this.bookRepository = bookRepository;
}
@GetMapping("/{authorId}")
public String getPage(@PathVariable("authorId") Long authorId, Model model) {
final Author author = authorRepository.findById(authorId).orElse(null);
if (author == null){
model.addAttribute("Error", "Not found");
return "author";
}
List<Book> books = bookRepository.findAllByAuthorsContains(author);
model.addAttribute("author", author);
model.addAttribute("books", books);
return "author";
}
}

View file

@ -12,7 +12,7 @@ import ru.redrise.marinesco.library.Book;
@Controller
@RequestMapping("/book")
public class BookController {
private BookRepository bookRepository;
BookRepository bookRepository;
public BookController(BookRepository bookRepository){
this.bookRepository = bookRepository;

View file

@ -5,16 +5,12 @@ import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import ru.redrise.marinesco.library.Author;
import ru.redrise.marinesco.library.Book;
@Repository
public interface BookRepository extends CrudRepository<Book, Integer>{
List<Book> findBySeriesContainingIgnoreCase(String title);
List<Book> findByTitleContainingIgnoreCase(String title);
List<Book> findAllByAuthorsContains(Author author);
}

View file

@ -234,7 +234,3 @@ button:hover {
padding: 3px;
background-color: #D00000;
}
.book_title{
font-weight: bold;
}

View file

@ -1,37 +0,0 @@
<!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="${author} != null">
<h3><span th:text="${author.authorName}"></span></h3>
<div th:each="book : ${books}">
<a th:href="${'/book/' + book.id}">
<span class="book_title" th:text="${book.title}"></span>
</a>
<br />
<div th:if="${book.series} != ''" th:text="${'Series: ' + book.series}">
<br />
</div>
<a th:href="${'/download/?container=' + book.container + '&file=' + book.fsFileName}" th:text="Download"></a>
<span th:text="${' (' + book.fileExtension + ' ' + book.fileSizeForHumans + ')'}"></span>
<p></p>
</div>
</div>
</div>
</div>
<div th:replace="~{fragments/footer :: 'footer'}"></div>
</body>
</html>

View file

@ -17,7 +17,6 @@
<br /><a href="/manage_users">/manage_users</a>
<br /><a href="/settings">/settings</a>
<br /><a href="/book/59992766">/book/59992766</a>
<br /><a href="/author/1">/author/1</a>
<br /><a href="/h2">H2</a>
<br />
<br />

View file

@ -21,15 +21,15 @@
<h3>Titles</h3>
<div th:each="book : ${books}">
<a th:href="${'/book/' + book.id}">
<span class="book_title" th:text="${book.title}"></span>
<span th:text="${book.title}"></span>
</a>
<br />
<div th:if="${book.series} != ''" th:text="${'Series: ' + book.series}">
<br />
</div>
<a th:if="${#lists.size(book.authors)} == 1" th:href="${'/author/' + book.authors[0].id}" th:text="${book.authors[0].authorName}"></a>
<span th:if="${#lists.size(book.authors)} == 1" th:text="${book.authors[0].authorName}"></span>
<span th:if="${#lists.size(book.authors)} > 1" th:each="author : ${book.authors}" >
<a th:href="${'/author/' + author.id}" th:text="${author.authorName}"></a>,
<span th:text="${author.authorName} + ', '"></span>
</span>
<br />
<a th:href="${'/download/?container=' + book.container + '&file=' + book.fsFileName}"
@ -43,17 +43,17 @@
<div th:if="${series} != null">
<hr>
<h3>Series</h3>
<div th:each="book : ${books}">
<div th:each="book : ${series}">
<a th:href="${'/book/' + book.id}">
<span class="book_title" th:text="${book.title}"></span>
<span th:text="${book.title}"></span>
</a>
<br />
<div th:if="${book.series} != ''" th:text="${'Series: ' + book.series}">
<br />
</div>
<a th:if="${#lists.size(book.authors)} == 1" th:href="${'/author/' + book.authors[0].id}" th:text="${book.authors[0].authorName}"></a>
<span th:if="${#lists.size(book.authors)} == 1" th:text="${book.authors[0].authorName}"></span>
<span th:if="${#lists.size(book.authors)} > 1" th:each="author : ${book.authors}" >
<a th:href="${'/author/' + author.id}" th:text="${author.authorName}"></a>,
<span th:text="${author.authorName} + ', '"></span>
</span>
<br />
<a th:href="${'/download/?container=' + book.container + '&file=' + book.fsFileName}"