From 2fa6e786260f39911d743fdcedbc400bcb5b3a61 Mon Sep 17 00:00:00 2001 From: yvling Date: Thu, 19 Dec 2024 15:21:36 +0800 Subject: [PATCH] new: Added friends page and adjust page style --- config.yaml | 24 ++++++-- config/mFriend.go | 13 ++++ config/mSite.go | 9 +-- internal/mApp/mHandler.go | 18 ++++++ internal/mApp/mRouter.go | 1 + templates/default/assets/css/about.css | 8 +-- templates/default/assets/css/friend.css | 43 +++++++++++++ templates/default/assets/css/tag.css | 4 +- templates/default/assets/js/index.js | 21 ------- templates/default/html/about.html | 36 +++++------ templates/default/html/archive.html | 56 +++++------------ templates/default/html/category.html | 18 ++---- templates/default/html/friend.html | 80 +++++++++++++++++++++++++ templates/default/html/post.html | 3 +- templates/default/html/search.html | 36 ++++------- templates/default/html/tag.html | 18 ++---- 16 files changed, 240 insertions(+), 148 deletions(-) create mode 100644 config/mFriend.go create mode 100644 templates/default/assets/css/friend.css create mode 100644 templates/default/html/friend.html diff --git a/config.yaml b/config.yaml index d4b1251..15f1a97 100644 --- a/config.yaml +++ b/config.yaml @@ -54,6 +54,9 @@ site: - name: Archive icon: fa-solid fa-box-archive url: /archive + - name: Friends + icon: fa-solid fa-user-group + url: /friend - name: About icon: fa-solid fa-circle-info url: /about @@ -71,20 +74,29 @@ site: number: 10 archive: title: Archive - number: 10 + number: 15 search: title: Search - number: 10 + number: 15 category: title: Category - number: 10 + number: 15 tag: title: Tag - number: 10 + number: 15 # about config about: - title: About me + title: About src: _blog/src/about dst: _blog/dst/about - filename: index \ No newline at end of file + filename: index + + # friends link + friend: + title: Friends + list: + - name: + link: + avatar: + description: \ No newline at end of file diff --git a/config/mFriend.go b/config/mFriend.go new file mode 100644 index 0000000..663bf1f --- /dev/null +++ b/config/mFriend.go @@ -0,0 +1,13 @@ +package config + +type mFriend struct { + Title string `json:"title"` + List []mFriendItem `json:"list"` +} + +type mFriendItem struct { + Name string `yaml:"name"` + Link string `yaml:"link"` + Avatar string `yaml:"avatar"` + Description string `yaml:"description"` +} diff --git a/config/mSite.go b/config/mSite.go index 73a19a7..c7a3833 100644 --- a/config/mSite.go +++ b/config/mSite.go @@ -1,8 +1,9 @@ package config type mSite struct { - Info mInfo `yaml:"info"` - Menu mMenu `yaml:"menu"` - Post mPost `yaml:"post"` - About mAbout `yaml:"about"` + Info mInfo `yaml:"info"` + Menu mMenu `yaml:"menu"` + Post mPost `yaml:"post"` + About mAbout `yaml:"about"` + Friend mFriend `yaml:"friend"` } diff --git a/internal/mApp/mHandler.go b/internal/mApp/mHandler.go index 40b1227..3cd0bad 100644 --- a/internal/mApp/mHandler.go +++ b/internal/mApp/mHandler.go @@ -496,3 +496,21 @@ func (ma *MApp) RSSHandler(ctx *gin.Context) { ctx.String(http.StatusNotFound, "RSS Not Found") } } + +func (ma *MApp) FriendHandler(ctx *gin.Context) { + resData := gin.H{ + "site_info": gin.H{ + "logo": ma.Config.MSite.Info.Logo, + "title": ma.Config.MSite.Info.Title, + "author": ma.Config.MSite.Info.Author, + "language": ma.Config.MSite.Info.Language, + "copyright": template.HTML(ma.Config.MSite.Info.Copyright), + }, + "menu": ma.Config.MSite.Menu, + "friend": gin.H{ + "title": ma.Config.MSite.Friend.Title, + "list": ma.Config.MSite.Friend.List, + }, + } + ctx.HTML(http.StatusOK, "friend.html", resData) +} diff --git a/internal/mApp/mRouter.go b/internal/mApp/mRouter.go index 06e2204..518a7ef 100644 --- a/internal/mApp/mRouter.go +++ b/internal/mApp/mRouter.go @@ -7,6 +7,7 @@ func (ma *MApp) loadRoutes() { ma.engine.GET("/rss", ma.RSSHandler) ma.engine.GET("/about", ma.AboutHandler) ma.engine.GET("/search", ma.SearchHandler) + ma.engine.GET("/friend", ma.FriendHandler) ma.engine.GET("/archive", ma.ArchiveHandler) ma.engine.GET("/post/:hash", ma.PostHandler) ma.engine.GET("/tag/:hash", ma.TagHandler) diff --git a/templates/default/assets/css/about.css b/templates/default/assets/css/about.css index ef5ed68..a3db12a 100644 --- a/templates/default/assets/css/about.css +++ b/templates/default/assets/css/about.css @@ -16,9 +16,10 @@ tr, th, td { color: var(--primary-text-color); } - -.about-title-wrap { - text-align: center; +.root-container { + max-width: 1000px; + margin-left: auto; + margin-right: auto; } .about-title { @@ -27,7 +28,6 @@ tr, th, td { .about-content { line-height: 1.6; - max-width: 1000px; color: var(--primary-text-color); } diff --git a/templates/default/assets/css/friend.css b/templates/default/assets/css/friend.css new file mode 100644 index 0000000..b7a5af7 --- /dev/null +++ b/templates/default/assets/css/friend.css @@ -0,0 +1,43 @@ +.friend-title { + color: var(--primary-color); +} + +.friend-item { + margin-top: 20px; + padding: 10px; + display: flex; + align-items: center; + color: var(--primary-text-color); + border: var(--secondary-text-color) 1px dashed; + border-radius: 4px; +} + +.friend-item:hover { + cursor: pointer; + border: var(--primary-color) 1px solid; +} + +.friend-avatar { + width: 64px; + height: 64px; + object-fit: cover; + border-radius: 50%; +} + +.friend-info-wrap { + padding-left: 10px; +} + +.friend-name { + font-size: 18px; + font-weight: bolder; +} + +.friend-description { + width: 200px; + font-size: 14px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + color: var(--secondary-text-color); +} \ No newline at end of file diff --git a/templates/default/assets/css/tag.css b/templates/default/assets/css/tag.css index e527597..5843956 100644 --- a/templates/default/assets/css/tag.css +++ b/templates/default/assets/css/tag.css @@ -40,8 +40,8 @@ width: 100%; height: 100%; opacity: 0.4; - mask-image: radial-gradient(at 100% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%); - -webkit-mask-image: radial-gradient(at 100% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%); + mask-image: radial-gradient(at 100% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%); + -webkit-mask-image: radial-gradient(at 100% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%); } .tag-word-cloud-canvas * { diff --git a/templates/default/assets/js/index.js b/templates/default/assets/js/index.js index 2592c2b..7748f26 100644 --- a/templates/default/assets/js/index.js +++ b/templates/default/assets/js/index.js @@ -1,25 +1,4 @@ function search() { const keyword = document.getElementById("index-search-input").value; window.location.href = "/search?keyword=" + keyword; -} - -function typeWriter(element_id, text) { - const element = document.getElementById(element_id); - let i = 0; - - element.innerHTML = ''; - function type() { - if (i < text.length) { - const minSpeed = 50; - const maxSpeed = 200; - const randomSpeed = Math.floor(Math.random() * (maxSpeed - minSpeed + 1)) + minSpeed; - - element.innerHTML += text.charAt(i); - - i++; - setTimeout(type, randomSpeed); - } - } - - type(); } \ No newline at end of file diff --git a/templates/default/html/about.html b/templates/default/html/about.html index 5636b28..dd0ae74 100644 --- a/templates/default/html/about.html +++ b/templates/default/html/about.html @@ -4,7 +4,7 @@ - {{ .site_info.title }} + {{ .site_info.title }} | {{ .about.title }} @@ -19,25 +19,27 @@
+ +
+
+
+ {{ range $i, $v := .menu.Items }} + + + {{ $v.Name }} + + {{ end }} +
+
+
+
-
-
-

# {{ .about.title }}

-
-
- {{ range $i, $v := .menu.Items }} - - {{ $v.Name }} - {{ end }} -
-
-
-
-
- {{ .about.content }} -
+
+

# {{ .about.title }}

+
+ {{ .about.content }}
diff --git a/templates/default/html/archive.html b/templates/default/html/archive.html index 2e440f4..e0e9a6a 100644 --- a/templates/default/html/archive.html +++ b/templates/default/html/archive.html @@ -4,30 +4,19 @@ - {{ .site_info.title }} + {{ .site_info.title }} | {{ .history_post.title }} -
- -
-
- -
-
+
@@ -41,24 +30,24 @@ {{ end }}
-
-
- -   - -
-
-

# {{ .history_post.title }}

-
-
+

# {{ .history_post.title }}

+
+
+ +   + +
+
+
+
{{ range $i, $v := .history_post.posts }}
@@ -83,23 +72,6 @@ {{ end }}
- - - - - {{ .site_info.motto_html }} - -
diff --git a/templates/default/html/category.html b/templates/default/html/category.html index 35afdc4..56b09e4 100644 --- a/templates/default/html/category.html +++ b/templates/default/html/category.html @@ -16,17 +16,7 @@
- -
-
- -
-
+
@@ -44,9 +34,9 @@
-

# {{ .categorized_post.title }}

-
-
+

# {{ .categorized_post.title }}

+
+
{{ range $i, $v := .categorized_post.posts }}
diff --git a/templates/default/html/friend.html b/templates/default/html/friend.html new file mode 100644 index 0000000..0e557a8 --- /dev/null +++ b/templates/default/html/friend.html @@ -0,0 +1,80 @@ +{{ define "friend.html" }} + + + + + + {{ .site_info.title }} | {{ .friend.title }} + + + + + + + + + + + + +
+
+ + +
+
+
+ {{ range $i, $v := .menu.Items }} + + + {{ $v.Name }} + + {{ end }} +
+
+
+ + +
+
+
+

# {{ .friend.title }}

+
+
+ {{ range $i, $v := .friend.list }} +
+
+ +
+
+ {{ $v.Name }} +
+
+ {{ $v.Description }} +
+
+
+
+ {{ end }} +
+
+
+
+
+ +
+ + + + + + + + +{{ end }} \ No newline at end of file diff --git a/templates/default/html/post.html b/templates/default/html/post.html index 6c85727..758157b 100644 --- a/templates/default/html/post.html +++ b/templates/default/html/post.html @@ -17,10 +17,11 @@
+
-
+
{{ range $i, $v := .menu.Items }} diff --git a/templates/default/html/search.html b/templates/default/html/search.html index b623fb7..6d506b1 100644 --- a/templates/default/html/search.html +++ b/templates/default/html/search.html @@ -16,17 +16,7 @@
- -
-
- -
-
+
@@ -38,24 +28,24 @@ {{ end }}
-
-
- -   - -
-
-

# {{ .search_post.title }}

-
-
+

# {{ .search_post.title }}

+
+
+ +   + +
+
+
+
{{ range $i, $v := .search_post.posts }}
diff --git a/templates/default/html/tag.html b/templates/default/html/tag.html index 7257829..315a03a 100644 --- a/templates/default/html/tag.html +++ b/templates/default/html/tag.html @@ -17,17 +17,7 @@
- -
-
- -
-
+
@@ -44,9 +34,9 @@
-

# {{ .tagged_post.title }}

-
-
+

# {{ .tagged_post.title }}

+
+
{{ range $i, $v := .tagged_post.posts }}