mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
new: Added post search module
This commit is contained in:
@@ -26,6 +26,12 @@ html, body {
|
||||
background-color: var(--background-color);
|
||||
}
|
||||
|
||||
input:focus {
|
||||
border: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
a, a:link, a:visited, a:active {
|
||||
text-decoration: none;
|
||||
color: var(--primary-text-color);
|
||||
@@ -101,4 +107,33 @@ a:hover {
|
||||
padding: 20px;
|
||||
border-radius: 4px;
|
||||
border: var(--secondary-text-color) 1px dashed;
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
width: 300px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 270px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
display: inline;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.search-button {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: inline;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: var(--secondary-color);
|
||||
}
|
||||
|
||||
.search-button:hover {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
25
templates/default/assets/css/search.css
Normal file
25
templates/default/assets/css/search.css
Normal file
@@ -0,0 +1,25 @@
|
||||
.search-post-title {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.search-post-item {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
color: var(--primary-text-color);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.search-post-item-wrap {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.search-post-item-date {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
.search-post-pagination-item {
|
||||
color: var(--secondary-text-color);
|
||||
padding-right: 10px;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
.tagged-name {
|
||||
.tagged-post-title {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
|
||||
4
templates/default/assets/js/archive.js
Normal file
4
templates/default/assets/js/archive.js
Normal file
@@ -0,0 +1,4 @@
|
||||
function search() {
|
||||
const keyword = document.getElementById("archive-search-input").value;
|
||||
window.location.href = "/search?keyword=" + keyword;
|
||||
}
|
||||
4
templates/default/assets/js/index.js
Normal file
4
templates/default/assets/js/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
function search() {
|
||||
const keyword = document.getElementById("index-search-input").value;
|
||||
window.location.href = "/search?keyword=" + keyword;
|
||||
}
|
||||
@@ -43,6 +43,10 @@ function goto(path) {
|
||||
window.location.href = path;
|
||||
}
|
||||
|
||||
function back() {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
function backToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
|
||||
4
templates/default/assets/js/search.js
Normal file
4
templates/default/assets/js/search.js
Normal file
@@ -0,0 +1,4 @@
|
||||
function search() {
|
||||
const keyword = document.getElementById("search-search-input").value;
|
||||
window.location.href = "/search?keyword=" + keyword;
|
||||
}
|
||||
@@ -38,6 +38,15 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pt-4">
|
||||
<div class="search-wrap">
|
||||
<input class="search-input" id="archive-search-input" type="text">
|
||||
|
||||
<button class="search-button" onclick="search()">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -107,6 +116,7 @@
|
||||
{{ .site_info.copyright }}
|
||||
</div>
|
||||
|
||||
<script src="../assets/js/archive.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<!-- body -->
|
||||
<div class="container p-3">
|
||||
<div class="row pt-lg-3">
|
||||
<h4 class="categorized-post-title"># {{ .categorized_post.category_name }}</h4>
|
||||
<h4 class="categorized-post-title"># {{ .categorized_post.title }}</h4>
|
||||
<div class="col-12 col-lg-9">
|
||||
<div>
|
||||
{{ range $i, $v := .categorized_post.posts }}
|
||||
|
||||
@@ -38,6 +38,15 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pt-4">
|
||||
<div class="search-wrap">
|
||||
<input class="search-input" id="index-search-input" type="text">
|
||||
|
||||
<button class="search-button" onclick="search()">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- body -->
|
||||
@@ -86,6 +95,7 @@
|
||||
{{ .site_info.copyright }}
|
||||
</div>
|
||||
|
||||
<script src="../assets/js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
<span class="toc-box-menu-item" onclick="backToTop()">
|
||||
<i class="fa-solid fa-circle-up"></i>
|
||||
</span>
|
||||
<span class="toc-box-menu-item" onclick="back()">
|
||||
<i class="fa-solid fa-right-from-bracket"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
117
templates/default/html/search.html
Normal file
117
templates/default/html/search.html
Normal file
@@ -0,0 +1,117 @@
|
||||
{{ define "search.html" }}
|
||||
|
||||
<html lang="{{ .site_info.language }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ .site_info.title }}</title>
|
||||
<link rel="icon" type="image/x-icon" href="{{ .site_info.logo }}"/>
|
||||
<link rel="stylesheet" href="../assets/css/lib/fontawesome.all.min.css">
|
||||
<link rel="stylesheet" href="../assets/css/lib/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="../assets/css/global.css">
|
||||
<link rel="stylesheet" href="../assets/css/search.css">
|
||||
<script src="../assets/js/lib/jquery.min.js"></script>
|
||||
<script src="../assets/js/lib/bootstrap.min.js"></script>
|
||||
<script src="../assets/js/lib/fontawesome.all.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="root-container">
|
||||
<!-- header -->
|
||||
<div class="container p-3">
|
||||
<div class="row pt-3 pt-md-4 pt-lg-5">
|
||||
<div class="col main-logo">
|
||||
<div class="main-logo-img" style="background-image: url('{{ .site_info.logo }}');"></div>
|
||||
<div class="main-logo-txt">
|
||||
{{ .site_info.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- menu -->
|
||||
<div class="container p-3">
|
||||
<div class="row pt-lg-3">
|
||||
<div class="col mx-auto post-menu">
|
||||
{{ range $i, $v := .menu.Items }}
|
||||
<i class="{{ $v.Icon }} m-icon"></i>
|
||||
<a class="main-menu-link" href="{{ $v.Url }}"> {{ $v.Name }} </a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pt-4">
|
||||
<div class="search-wrap">
|
||||
<input class="search-input" id="search-search-input" type="text">
|
||||
|
||||
<button class="search-button" onclick="search()">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- body -->
|
||||
<div class="container p-3">
|
||||
<div class="row pt-lg-3">
|
||||
<h4 class="search-post-title"># {{ .search_post.title }}</h4>
|
||||
<div class="col-12 col-lg-9">
|
||||
<div>
|
||||
{{ range $i, $v := .search_post.posts }}
|
||||
<div class="row search-post-item">
|
||||
<div class="col search-post-item-wrap">
|
||||
<span class="d-none d-md-inline search-post-item-date">{{ $v.Date }} | </span>
|
||||
<span>
|
||||
<a href="/post/{{ $v.HtmlHash }}">{{ $v.Title }}</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col d-none d-md-block search-post-item-wrap">
|
||||
<span style="color: var(--secondary-text-color)">
|
||||
[
|
||||
{{ range $i2, $v2 := $v.TagHashes }}
|
||||
<a href="/tag/{{ $v2.Hash }}" style="color: var(--secondary-text-color)">{{ $v2.Name }}</a>
|
||||
{{ if lt (add $i2 1) (len $v.TagHashes) }}
|
||||
,
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
]
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pt-3 pt-lg-4">
|
||||
<div class="col-12 col-md-8">
|
||||
<div class="search-post-pagination">
|
||||
<span class="search-post-pagination-item">
|
||||
<a href="/search?page={{ .page_info.pre_page }}">
|
||||
<
|
||||
</a>
|
||||
</span>
|
||||
<span class="search-post-pagination-item">
|
||||
{{ .page_info.cur_page }} / {{ .page_info.all_page }}
|
||||
</span>
|
||||
<span class="search-post-pagination-item">
|
||||
<a href="/search?page={{ .page_info.nxt_page }}">
|
||||
>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- footer -->
|
||||
<div class="footer">
|
||||
{{ .site_info.copyright }}
|
||||
</div>
|
||||
|
||||
<script src="../assets/js/search.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
{{ end }}
|
||||
@@ -44,7 +44,7 @@
|
||||
<!-- body -->
|
||||
<div class="container p-3">
|
||||
<div class="row pt-lg-3">
|
||||
<h4 class="tagged-name"># {{ .tagged_post.tag_name }}</h4>
|
||||
<h4 class="tagged-post-title"># {{ .tagged_post.title }}</h4>
|
||||
<div class="col-12 col-md-8">
|
||||
<div>
|
||||
{{ range $i, $v := .tagged_post.posts }}
|
||||
|
||||
Reference in New Issue
Block a user