Newer
Older
simple-opds / src / main / resources / templates / layout.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title layout:title-pattern="$CONTENT_TITLE - $LAYOUT_TITLE">SOPDS</title>

    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">

    <style>
        .sidebar {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            z-index: 100;
            padding: 48px 0 0;
            box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
        }

        .sidebar-sticky {
            position: relative;
            top: 0;
            height: calc(100vh - 48px);
            padding-top: .5rem;
            overflow-x: hidden;
            overflow-y: auto;
        }

        .sidebar .nav-link {
            font-weight: 500;
            color: #333;
            padding: 0.5rem 1rem;
        }

        .sidebar .nav-link.active {
            color: #007bff;
        }

        .main-content {
            margin-left: 240px;
            padding: 20px;
        }

        .book-cover {
            width: 120px;
            height: 160px;
            object-fit: cover;
            border: 1px solid #ddd;
        }

        .author-list, .genre-list, .series-list {
            column-count: 3;
            column-gap: 20px;
        }

        @media (max-width: 768px) {
            .sidebar {
                position: static;
                height: auto;
            }
            .main-content {
                margin-left: 0;
            }
            .author-list, .genre-list, .series-list {
                column-count: 1;
            }
        }
    </style>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container-fluid">
        <a class="navbar-brand" th:href="@{/}">
            <i class="bi bi-book-half"></i> SOPDS
        </a>

        <!-- Search Form -->
        <form class="d-flex mx-auto" th:action="@{/search}" method="get" style="width: 50%;">
            <input class="form-control me-2" type="search" name="q" placeholder="Поиск книг..." aria-label="Search">
            <button class="btn btn-outline-light" type="submit">
                <i class="bi bi-search"></i>
            </button>
        </form>

        <!-- User Menu -->
        <div class="navbar-nav">
            <div class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                   data-bs-toggle="dropdown" aria-expanded="false">
                    <i class="bi bi-person-circle"></i>
                    <span th:if="${user != null}" th:text="${user.username}">User</span>
                    <span th:unless="${user != null}">Гость</span>
                </a>
                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                    <li th:if="${user == null}">
                        <a class="dropdown-item" th:href="@{/login}">
                            <i class="bi bi-box-arrow-in-right"></i> Войти
                        </a>
                    </li>
                    <li th:if="${user == null}">
                        <a class="dropdown-item" th:href="@{/register}">
                            <i class="bi bi-person-plus"></i> Регистрация
                        </a>
                    </li>
                    <li th:if="${user != null}">
                        <a class="dropdown-item" th:href="@{/profile}">
                            <i class="bi bi-person"></i> Профиль
                        </a>
                    </li>
                    <li th:if="${user != null}">
                        <a class="dropdown-item" th:href="@{/logout}">
                            <i class="bi bi-box-arrow-right"></i> Выйти
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</nav>

<!-- Main Container -->
<div class="container-fluid">
    <div class="row">
        <!-- Sidebar -->
        <nav id="sidebar" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
            <div class="sidebar-sticky pt-3">
                <ul class="nav flex-column">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/}" th:classappend="${#httpServletRequest.requestURI == '/'} ? 'active'">
                            <i class="bi bi-house"></i> Главная
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/books}">
                            <i class="bi bi-book"></i> Все книги
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/authors}">
                            <i class="bi bi-people"></i> Авторы
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/series}">
                            <i class="bi bi-collection"></i> Серии
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/genres}">
                            <i class="bi bi-tags"></i> Жанры
                        </a>
                    </li>
                </ul>

                <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
                    <span>Жанры</span>
                </h6>
                <ul class="nav flex-column mb-2">
                    <li class="nav-item" th:each="genre : ${topGenres}">
                        <a class="nav-link" th:href="@{/books/genre/{id}(id=${genre.id})}">
                            <i class="bi bi-tag"></i>
                            <span th:text="${genre.genre}">Жанр</span>
                        </a>
                    </li>
                </ul>
            </div>
        </nav>

        <!-- Main content -->
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 main-content">
            <div layout:fragment="content">
                <!-- Content will be inserted here -->
            </div>
        </main>
    </div>
</div>

<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

<script>
    // Активация текущей страницы в сайдбаре
    document.addEventListener('DOMContentLoaded', function() {
        const currentPath = window.location.pathname;
        const navLinks = document.querySelectorAll('.nav-link');

        navLinks.forEach(link => {
            if (link.getAttribute('href') === currentPath) {
                link.classList.add('active');
            }
        });
    });
</script>
</body>
</html>