Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
6.7 kB
3
Indexable
Never
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Blog Application</title>
    <link rel="stylesheet" type="text/css"  th:href="@{/css/blog-posts.css}" />
</head>
<body>
<header>
        <div class="logo">My Blog Application</div>
    <form class="Search-bar" th:action="@{/blogapplication/searchAll}" >
        <input type="text" placeholder="Search"  name="search" />
        <button type="submit"></button>
    </form>
        <a th:href="@{/user/login}">Login</a>
        <a th:href="@{/blogapplication/new-post}">Write Post</a>
</header>
    <div class="body">
    <div class="aside-section">
        <aside>

        <form th:action="@{/blogapplication/filteredPosts}">
            <h2>SortBy</h2>
            <select name="sortValue" >
                <option value="1" selected>Date (Oldest to Newest)</option>
                <option value="2">Date (Newest to Oldest)</option>
            </select>
            <h2>Filter by Authors And Tags</h2>
            <div class="checkbox-container">
                <input type="hidden" name="mySearch" th:value="${search}">
                <div class="tags">
                    <div th:each="tag : ${tagNames}">
                        <input type="checkbox" name="selectedTags" th:value="${tag}" />
                        <div th:text="${tag}"></div>
                    </div>
                </div>
                <h2>Authors</h2>
                <div class="authors">
                    <div th:each="author : ${authors}">
                        <input type="checkbox" name="selectedAuthors" th:value="${author}">
                        <div th:text="${author}"></div>
                    </div>
                </div>
            </div>
       <!--        <div class="dateRange">
                    <h2>Range</h2>
                    <select name="selectedMonth" >
                        <option value="1" >Feb to March</option>
                        <option value="2" selected>March to April</option>
                        <option value="3" >April to May</option>
                    </select>
                </div> -->
                    <div style="padding:10px">
                        <button type="submit">Filter..!</button>
                    </div>
            </form>

        </aside>
    </div>
        <main class="main">
            <div class="container">
                <div th:each="post: ${blogposts}">
                     <div class="post">
                        <div th:text="${post.title}"></div><br/>
                            <span id="author">
                                <div th:text="${post.author}"></div>
                                <div th:text="${post.published_at}"></div><br/>
                            </span>
                        <div th:text="${post.excerpt}"></div><br/>
                         <a th:href="@{/blogapplication/viewPost/{postId}(postId = ${post.id})}">Read Post</a>
                     </div>
                </div>
            </div>
        </main>
    </div>
        <footer>
            <ul class="pagination">
                <ul th:if="${value == 0}" >
                    <div>Total Posts : <span th:text="${totalElements}"></span></div>
                    <li th:each="i : ${#numbers.sequence(1, totalPages)}" >
                        <a th:if="${i != totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/searchAll(search = ${search}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/searchAll(search = ${search}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="End" ></a>
                    </li>
                </ul>

                <ul th:if="${value == 1}" >
                    <div>Total Posts : <span th:text="${totalElements}"></span></div>
                    <li th:each="i : ${#numbers.sequence(1, totalPages)}" >
                        <a th:if="${i != totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="${i}" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="End" ></a>
                    </li>
                </ul>
                <ul th:if="${value == 2}" >
                    <div>Total Posts : <span th:text="${totalElements}"></span></div>
                    <li th:each="i : ${#numbers.sequence(1, totalPages)}" >
                        <a th:if="${i != totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="End" ></a>
                    </li>
                </ul>
                <ul th:if="${value == 3}" >
                    <div>Total Posts : <span th:text="${totalElements}"></span></div>
                    <li th:each="i : ${#numbers.sequence(1, totalPages)}" >
                        <a th:if="${i != totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/filteredPosts(selectedTags= ${tags}, selectedAuthors = ${posts},sortedValue = ${sortedValue}, offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="End" ></a>
                    </li>
                </ul>
                <ul th:if="${value == 4}" >
                    <div>Total Posts : <span th:text="${totalElements}"></span></div>
                    <li th:each="i : ${#numbers.sequence(1, totalPages)}" >
                        <a th:if="${i != totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/(offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="${i}" name="search" th:href="@{/blogapplication/(offSet = ${i})}"></a>
                        <a th:if="${i == totalPages}" th:text="End" ></a>
                    </li>
                </ul>
            </ul>
        </footer>
</body>
</html>