mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
fix: Adjust the tab layout and fix some bugs
This commit is contained in:
@@ -27,6 +27,7 @@ type MApp struct {
|
||||
IndexedPosts map[uint64]*model.MPost
|
||||
|
||||
Tags map[string]string
|
||||
TagsHash map[string]string
|
||||
TagsCount map[string]int
|
||||
Categories map[string]string
|
||||
CategoriesCount map[string]int
|
||||
@@ -76,6 +77,7 @@ func NewMApp(cfg *config.MConfig) *MApp {
|
||||
IndexedPosts: make(map[uint64]*model.MPost),
|
||||
|
||||
Tags: make(map[string]string),
|
||||
TagsHash: make(map[string]string),
|
||||
TagsCount: make(map[string]int),
|
||||
|
||||
Categories: make(map[string]string),
|
||||
@@ -93,6 +95,8 @@ func NewMApp(cfg *config.MConfig) *MApp {
|
||||
func (ma *MApp) resetStorage() error {
|
||||
ma.Posts = nil
|
||||
ma.Tags = nil
|
||||
ma.TagsHash = nil
|
||||
ma.TagsCount = nil
|
||||
ma.Categories = nil
|
||||
ma.CategoriesCount = nil
|
||||
ma.TaggedPosts = nil
|
||||
@@ -100,6 +104,7 @@ func (ma *MApp) resetStorage() error {
|
||||
ma.SrcFiles = nil
|
||||
|
||||
ma.Tags = make(map[string]string)
|
||||
ma.TagsHash = make(map[string]string)
|
||||
ma.TagsCount = make(map[string]int)
|
||||
ma.Categories = make(map[string]string)
|
||||
ma.CategoriesCount = make(map[string]int)
|
||||
|
||||
@@ -165,7 +165,7 @@ func (ma *MApp) TagHandler(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
for tag, num := range ma.TagsCount {
|
||||
tagList = append(tagList, []interface{}{tag, num})
|
||||
tagList = append(tagList, []interface{}{tag, num, ma.TagsHash[tag]})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (ma *MApp) TagHandler(ctx *gin.Context) {
|
||||
|
||||
func (ma *MApp) CategoryHandler(ctx *gin.Context) {
|
||||
categoryHash := ctx.Param("hash")
|
||||
categoryName := ma.Tags[categoryHash]
|
||||
categoryName := ma.Categories[categoryHash]
|
||||
|
||||
// paging logic processing
|
||||
page, _ := strconv.Atoi(ctx.DefaultQuery("page", "1"))
|
||||
@@ -235,7 +235,6 @@ func (ma *MApp) CategoryHandler(ctx *gin.Context) {
|
||||
offset := curPage * size
|
||||
|
||||
var categorizedPosts []model.MPost
|
||||
//var tagList [][]interface{}
|
||||
if start >= 0 {
|
||||
for i := start; i < utils.Min(len(ma.CategorizedPosts[categoryHash]), offset); i++ {
|
||||
tmpPost := *ma.CategorizedPosts[categoryHash][i]
|
||||
@@ -243,12 +242,8 @@ func (ma *MApp) CategoryHandler(ctx *gin.Context) {
|
||||
categorizedPosts = append(categorizedPosts, tmpPost)
|
||||
}
|
||||
|
||||
//for tag, num := range ma.TagsCount {
|
||||
// tagList = append(tagList, []interface{}{tag, num})
|
||||
//}
|
||||
}
|
||||
|
||||
//tagListJson, _ := json.Marshal(tagList)
|
||||
resData := gin.H{
|
||||
"site_info": gin.H{
|
||||
"logo": ma.Config.MSite.Info.Logo,
|
||||
@@ -268,7 +263,6 @@ func (ma *MApp) CategoryHandler(ctx *gin.Context) {
|
||||
"title": fmt.Sprintf("%s - %s", ma.Config.MSite.Post.Category.Title, categoryName),
|
||||
"posts": categorizedPosts,
|
||||
"category_hash": categoryHash,
|
||||
//"tag_list": string(tagListJson),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ func (ma *MApp) parseMarkdowns() error {
|
||||
})
|
||||
|
||||
ma.Tags[tagHash] = tag
|
||||
ma.TagsHash[tag] = tagHash
|
||||
ma.TagsCount[tag] += 1
|
||||
ma.TaggedPosts[tagHash] = append(ma.TaggedPosts[tagHash], &post)
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'meslo-lg-s-regular-for-powerline';
|
||||
src: url('../../assets/css/webfonts/meslo-lg-s-regular-for-powerline.ttf') format('opentype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
/*@font-face {*/
|
||||
/* font-family: 'meslo-lg-s-regular-for-powerline';*/
|
||||
/* src: url('../../assets/css/webfonts/meslo-lg-s-regular-for-powerline.ttf') format('opentype');*/
|
||||
/* font-weight: normal;*/
|
||||
/* font-style: normal;*/
|
||||
/*}*/
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
@@ -29,7 +29,7 @@ html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
font-family: meslo-lg-s-regular-for-powerline, serif;
|
||||
/*font-family: meslo-lg-s-regular-for-powerline, serif;*/
|
||||
background-color: var(--background-color);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
.tag-word-cloud-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.3;
|
||||
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%);
|
||||
}
|
||||
|
||||
.tag-word-cloud-canvas * {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const tagWordCloudCanvas = document.getElementById('tag-word-cloud-canvas');
|
||||
|
||||
let wordList = JSON.parse(tagList);
|
||||
|
||||
const options = {
|
||||
list: JSON.parse(tagList),
|
||||
list: wordList,
|
||||
weightFactor: 20,
|
||||
backgroundColor: 'transparent',
|
||||
click: (item) => {
|
||||
console.log(item[0], item[1]);
|
||||
window.location.href = "/tag/" + item[2];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="container p-3">
|
||||
<div class="row pt-lg-3">
|
||||
<h4 class="categorized-post-title"># {{ .categorized_post.title }}</h4>
|
||||
<div class="col-12 col-lg-9">
|
||||
<div class="col-12">
|
||||
<div>
|
||||
{{ range $i, $v := .categorized_post.posts }}
|
||||
<div class="row categorized-post-item">
|
||||
|
||||
Reference in New Issue
Block a user