Skip to content

Commit

Permalink
feat: tag v.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cheunglong committed Oct 16, 2023
1 parent fbddc64 commit fdb965a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 158 deletions.
135 changes: 16 additions & 119 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,23 @@ a:visited {
font-size: 0.32rem;
color: #878B99;
}
.head .btn-new {
margin: 0.4rem 0 0;
.btn, .btn:visited {
display: block;
border-radius: 0.5rem;
background-color: #6C6DE7;
font-size: 0.24rem;
line-height: 0.44rem;
width: 1.6rem;
text-align: center;
color: #fff;
box-shadow: 0 10px 30px 0 rgba(75, 103, 249, 0.35);
}
.head .btn-new:hover {
.btn:hover {
background-color: #5455ea;
}
.head .btn {
margin: 0.4rem 0 0;
font-size: 0.24rem;
line-height: 0.44rem;
width: 1.6rem;
}
.main .inner {
max-width: 960px;
margin: 0 auto;
Expand Down Expand Up @@ -138,58 +140,19 @@ a:visited {
font-size: 0.56rem;
font-weight: 700;
}
.comments .item {
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
margin: 0 0 0.3rem;
padding: 0.2rem 0.3rem;
background-color: #fff;
border-radius: 0.1rem;
box-shadow: 0 10px 30px -10px rgba(112, 135, 178, 0.2);
}
.comments .item:hover {
box-shadow: 0 10px 30px -10px rgba(213, 50, 113, 0.4);
}
.comment-hd {
font-weight: normal;
margin: 0;
}
.comments .userinfo .avatar {
width: 25px;
height: 25px;
border-radius: 100%;
object-fit: cover;
vertical-align: middle;
}
.comments .userinfo .username {
display: inline-block;
vertical-align: middle;
}
.comments .published {
color: #878b99;
}
.action {
.page-nav {
display: flex;
align-items: center;
justify-content: center;
padding: 0 0 0.3rem;
}
.action a {
width: 2rem;
border-radius: 2rem;
height: 0.5rem;
line-height: 0.5rem;
text-align: center;
font-size: 0.18rem;
margin: 0 0.15rem;
background-color: #fff;
box-shadow: 0 10px 30px -10px rgba(112, 135, 178, 0.2);
gap: .15rem;
}
.action a:hover {
box-shadow: 0 10px 30px -10px rgba(75, 103, 249, 0.35);
.page-nav .btn {
font-size: .12rem;
padding: .08rem .1rem;
text-transform: uppercase;
}
.foot {
margin: .5rem 0 0;
padding: 0 0 0.3rem;
text-align: center;
}
Expand All @@ -201,72 +164,6 @@ a:visited {
color: #5455ea;
font-weight: 700;
}
.hide {
display: none;
}
.rmBackGround {
background-image: none;
}
#loader {
text-align: center;
position: fixed;
z-index: 3;
left: 0;
top: 0;
height: 100%;
width: 100%;
opacity: 0;
visibility: hidden;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
background-color: rgba(255, 255, 255, 0.95);
}
.loading #loader {
opacity: 1;
visibility: visible;
}
.loading #loader div {
display: inline-block;
width: 50px;
height: 50px;
vertical-align: middle;
-webkit-border-radius: 3px;
border-radius: 3px;
background-color: #fff;
-webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
}
.loading #loader div:before {
content: '';
width: 26px;
height: 26px;
display: block;
margin: 8px auto 0;
-webkit-border-radius: 20px;
border-radius: 20px;
-webkit-animation: loading 0.5s linear forwards infinite;
animation: loading 0.5s linear forwards infinite;
border-top: 4px solid #0089fa;
border-right: 4px solid #ff002b;
border-bottom: 4px solid #ffa900;
border-left: 4px solid #00a753;
}
.loading #loader:after {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
@keyframes loading {
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes loading {
100% {
-webkit-transform: rotate(360deg);
}
}
@media (orientation: portrait) and (max-width: 750px) {
body {
background-position: 20% -5%;
Expand Down
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type PageQuery struct {

type PostQuery struct {
Id uint64 `uri:"id" binding:"required"`
Title string `uri:"title" binding:"required"`
Title string `uri:"title"`
}

type PureConfig struct {
Expand Down Expand Up @@ -200,12 +200,17 @@ func GenerateFeed(c *gin.Context) {
}

for _, disdiscussion := range discussions.Nodes {
body := []rune(disdiscussion.Body)
descriptionLength := 200
if (descriptionLength > len(body)) {
descriptionLength = len(body)
}
feed.Items = append(feed.Items, &feeds.Item{
Title: string(disdiscussion.Title),
Description: string([]rune(disdiscussion.Body)[:200]),
Description: string(body[:descriptionLength]),
Author: &feeds.Author{Name: config.Website.Name, Email: config.Website.Email},
Created: disdiscussion.CreatedAt.Time,
Link: &feeds.Link{Href: fmt.Sprintf("%s/post/%d/%s", config.Website.Host, disdiscussion.Number, disdiscussion.Title)},
Link: &feeds.Link{Href: fmt.Sprintf("%s/post/%d", config.Website.Host, disdiscussion.Number)},
})
}

Expand All @@ -218,9 +223,10 @@ func main() {
r.SetFuncMap(funcMap)
r.LoadHTMLGlob("templates/**/*")
r.Static("/assets", "./assets")
r.StaticFile("/manifest.json", "./templates/manifest.json")
r.GET("/", cache.CacheByRequestURI(memoryCache, 30*time.Second), FetchPosts)
r.GET("/category/:category_id/:category_name", cache.CacheByRequestURI(memoryCache, 30*time.Second), FetchPosts)
r.GET("/post/:id/:title", cache.CacheByRequestURI(memoryCache, 1*time.Hour), FetchPost)
r.GET("/post/:id", cache.CacheByRequestURI(memoryCache, 1*time.Hour), FetchPost)
r.GET("/atom.xml", cache.CacheByRequestURI(memoryCache, 24*time.Hour), GenerateFeed)
r.GET("/404", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "error.html", nil)
Expand Down
2 changes: 1 addition & 1 deletion manifest.json → templates/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"background_color": "#f7f8fe",
"theme_color": "#f37587",
"icons": [{
"src": "/css/img/logo.png",
"src": "/assets/images/logo.png",
"sizes": "512x512",
"type": "image/png"
}]
Expand Down
34 changes: 17 additions & 17 deletions templates/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="icon" type="image/png" href="/assets/images/logo.png">
<link rel="apple-touch-icon" type="image/png" href="/assets/images/logo.png">
<link rel="icon" type="image/png" sizes="144x144" href="/assets/images/logo.png">
<link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/main.css?2">
<link rel="manifest" href="/manifest.json">
<title>侦爱清单</title>
<meta name="description" content="骗不骗,清单来验;真不真,清单辨认。"/>
Expand All @@ -27,7 +27,7 @@ <h1 class="siteinfo">
<div class="siteintro">
<h2>骗你,<span>我是小猪</span></h2>
<p><span>骗不骗,清单验;</span><span>真不真,清单认。</span></p>
<a class="btn-new" target="_blank" href="https://github.com/xiongbao/checklist.love/discussions">我要补充</a>
<a class="btn" target="_blank" href="https://github.com/xiongbao/checklist.love/discussions/new?category=%E6%8A%95%E7%A8%BF">我要补充</a>
</div>
</div>
</header>
Expand All @@ -36,7 +36,7 @@ <h2>骗你,<span>我是小猪</span></h2>
<div class="posts">
{{range .Posts.Nodes}}
{{ if .Category.Id | isExisted }}
<a class="item" href="/post/{{.Number}}/{{.Title}}">
<a class="item" href="/post/{{.Number}}">
<h2 class="post-title">{{ .Title}}</h2>
<p class="post-tags">
{{range .Lables.Nodes}}
Expand All @@ -47,20 +47,20 @@ <h2 class="post-title">{{ .Title}}</h2>
{{ end }}
{{end}}
</div>
</div>
<div class="page-nav">
{{ if .Posts.PageInfo.HasPreviousPage }}
<a class="page-link prev"
href="/?pre={{.Posts.PageInfo.StartCursor}}">
<span class="ico"></span><span class="txt">Prev</span>
</a>
{{ end }}
{{ if .Posts.PageInfo.HasNextPage}}
<a class="page-link next"
href="/?next={{.Posts.PageInfo.EndCursor}}">
<span class="txt">Next</span><span class="ico"></span>
</a>
{{ end }}
<div class="page-nav">
{{ if .Posts.PageInfo.HasPreviousPage }}
<a class="btn prev"
href="/?pre={{.Posts.PageInfo.StartCursor}}">
<span class="ico"></span><span class="txt">Prev</span>
</a>
{{ end }}
{{ if .Posts.PageInfo.HasNextPage}}
<a class="btn next"
href="/?next={{.Posts.PageInfo.EndCursor}}">
<span class="txt">Next</span><span class="ico"></span>
</a>
{{ end }}
</div>
</div>
</main>
{{template "footer.html"}}
Expand Down
36 changes: 19 additions & 17 deletions templates/pages/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

<body>

<div class="index">
<div class="detail">
<header class="head">
<div class="inner">
<h1 class="siteinfo">
<a class="siteinfo" href="/">
<i class="logo"></i><span class="name">侦爱清单</span>
</h1>
</a>
<article class="post-detail">
<h1 class="post-title">{{ .Post.Title }}</h1>
<p class="post-tags">
Expand All @@ -36,20 +36,22 @@ <h1 class="post-title">{{ .Post.Title }}</h1>
</div>
</header>
<main class="main">
<script src="https://giscus.app/client.js"
data-repo="{{$.Repo}}"
data-repo-id="{{$.RepoId}}"
data-mapping="number"
data-term="{{.Post.Number}}"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="preferred_color_scheme"
data-lang="zh-CN"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
<div class="inner">
<script src="https://giscus.app/client.js"
data-repo="{{$.Repo}}"
data-repo-id="{{$.RepoId}}"
data-mapping="number"
data-term="{{.Post.Number}}"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="preferred_color_scheme"
data-lang="zh-CN"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
</div>
</main>
{{template "footer.html"}}
</div>
Expand Down

0 comments on commit fdb965a

Please sign in to comment.