From 6e15cc84379a4e4a959e2ff3ae14b838e9d8d074 Mon Sep 17 00:00:00 2001 From: Meekdai Date: Wed, 22 Nov 2023 12:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80docs=E7=9A=84json=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E5=8D=87=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gmeek.py | 13 +++++++++++-- templates/tag.html | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Gmeek.py b/Gmeek.py index bf19fdc..a097975 100644 --- a/Gmeek.py +++ b/Gmeek.py @@ -315,8 +315,17 @@ listFile.write(json.dumps(blog.blogBase)) listFile.close() # shutil.copy("blogBase.json",blog.root_dir) -blog.blogBase["postListJson"]=dict(sorted(self.blogBase["postListJson"].items(),key=lambda x:x[1]["createdAt"],reverse=True))#使列表由时间排序 +blog.blogBase["postListJson"]=dict(sorted(blog.blogBase["postListJson"].items(),key=lambda x:x[1]["createdAt"],reverse=True))#使列表由时间排序 +for i in blog.blogBase["postListJson"]: + del blog.blogBase["postListJson"][i]["description"] + del blog.blogBase["postListJson"][i]["postSourceUrl"] + del blog.blogBase["postListJson"][i]["htmlDir"] + del blog.blogBase["postListJson"][i]["createdAt"] + del blog.blogBase["postListJson"][i]["script"] + del blog.blogBase["postListJson"][i]["style"] + del blog.blogBase["postListJson"][i]["top"] + docListFile=open(blog.root_dir+"postList.json","w") -docListFile.write(json.dumps(blog.blogBase)) +docListFile.write(json.dumps(blog.blogBase["postListJson"])) docListFile.close() ###################################################################################### diff --git a/templates/tag.html b/templates/tag.html index bf335dd..00d93b2 100644 --- a/templates/tag.html +++ b/templates/tag.html @@ -92,22 +92,22 @@ function showList(){ showLabels.setAttribute("onclick","javascript:updateShowTag('All');"); tagLable.appendChild(showLabels); } - for(i in jsonData["postListJson"]){ - if(!(tagList.includes(jsonData["postListJson"][i]['label']))){ - tagList.push(jsonData["postListJson"][i]['label']); + for(i in jsonData){ + if(!(tagList.includes(jsonData[i]['label']))){ + tagList.push(jsonData[i]['label']); let showLabels=document.createElement("button"); showLabels.setAttribute("class","Label"); - showLabels.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']); - showLabels.innerHTML=jsonData["postListJson"][i]['label']; - showLabels.setAttribute("onclick","javascript:updateShowTag('"+jsonData["postListJson"][i]['label']+"');"); + showLabels.setAttribute("style","background-color:"+jsonData[i]['labelColor']); + showLabels.innerHTML=jsonData[i]['label']; + showLabels.setAttribute("onclick","javascript:updateShowTag('"+jsonData[i]['label']+"');"); tagLable.appendChild(showLabels); } let div=document.createElement("div"); - div.setAttribute("class","lists "+jsonData["postListJson"][i]['label']); + div.setAttribute("class","lists "+jsonData[i]['label']); let item=document.createElement("a"); item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between"); - item.setAttribute("href",jsonData["postListJson"][i]['postUrl']); + item.setAttribute("href",jsonData[i]['postUrl']); let center=document.createElement("div"); center.setAttribute("class","d-flex flex-items-center"); @@ -122,7 +122,7 @@ function showList(){ let title=document.createElement("span"); title.setAttribute("class","listTitle"); - title.innerHTML=jsonData["postListJson"][i]['postTitle']; + title.innerHTML=jsonData[i]['postTitle']; center.appendChild(svg); center.appendChild(title); @@ -130,13 +130,13 @@ function showList(){ listLabels.setAttribute("class","listLabels"); let LabelName=document.createElement("span"); LabelName.setAttribute("class","Label LabelName"); - LabelName.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']); - LabelName.innerHTML=jsonData["postListJson"][i]['label']; + LabelName.setAttribute("style","background-color:"+jsonData[i]['labelColor']); + LabelName.innerHTML=jsonData[i]['label']; listLabels.appendChild(LabelName); let LabelTime=document.createElement("span"); LabelTime.setAttribute("class","Label LabelTime"); - LabelTime.setAttribute("style","background-color:"+jsonData["postListJson"][i]['dateLabelColor']); - LabelTime.innerHTML=jsonData["postListJson"][i]['createdDate']; + LabelTime.setAttribute("style","background-color:"+jsonData[i]['dateLabelColor']); + LabelTime.innerHTML=jsonData[i]['createdDate']; listLabels.appendChild(LabelTime); item.appendChild(center);