添加文章置顶功能
This commit is contained in:
parent
e2ea95ec61
commit
f184fedb91
11
Gmeek.js
11
Gmeek.js
@ -86,8 +86,15 @@ if(htmlType=="plist"){
|
|||||||
span=document.createElement("span");
|
span=document.createElement("span");
|
||||||
div.setAttribute("class","d-flex flex-items-center");
|
div.setAttribute("class","d-flex flex-items-center");
|
||||||
svg.setAttributeNS(null,"class","SideNav-icon octicon");
|
svg.setAttributeNS(null,"class","SideNav-icon octicon");
|
||||||
svg.setAttributeNS(null,"style","witdh:16px;height:16px");
|
if(postListJson[num]["top"]==0){
|
||||||
path.setAttributeNS(null, "d", IconList["post"]);
|
svg.setAttributeNS(null,"style","witdh:16px;height:16px");
|
||||||
|
path.setAttributeNS(null, "d", IconList["post"]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg.setAttributeNS(null,"style","witdh:16px;height:16px;color:red");
|
||||||
|
path.setAttributeNS(null, "d", IconList["star"]);
|
||||||
|
}
|
||||||
|
|
||||||
span.innerHTML=postListJson[num]["postTitle"];
|
span.innerHTML=postListJson[num]["postTitle"];
|
||||||
svg.appendChild(path);
|
svg.appendChild(path);
|
||||||
div.appendChild(svg);
|
div.appendChild(svg);
|
||||||
|
|||||||
16
Gmeek.py
16
Gmeek.py
@ -50,7 +50,7 @@ class GMEEK():
|
|||||||
os.mkdir(self.post_dir)
|
os.mkdir(self.post_dir)
|
||||||
|
|
||||||
|
|
||||||
def get_repo(self,user: Github, repo: str):
|
def get_repo(self,user:Github, repo:str):
|
||||||
return user.get_repo(repo)
|
return user.get_repo(repo)
|
||||||
|
|
||||||
def markdown2html(self,mdstr):
|
def markdown2html(self,mdstr):
|
||||||
@ -83,6 +83,7 @@ class GMEEK():
|
|||||||
postBase["i18n"]=self.blogBase["i18n"]
|
postBase["i18n"]=self.blogBase["i18n"]
|
||||||
postBase["commentNum"]=issue["commentNum"]
|
postBase["commentNum"]=issue["commentNum"]
|
||||||
postBase["fontSize"]=issue["fontSize"]
|
postBase["fontSize"]=issue["fontSize"]
|
||||||
|
postBase["top"]=issue["top"]
|
||||||
postBase["repoName"]=options.repo_name
|
postBase["repoName"]=options.repo_name
|
||||||
postBase["GMEEK_VERSION"]=options.Gmeek_version
|
postBase["GMEEK_VERSION"]=options.Gmeek_version
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ class GMEEK():
|
|||||||
print("create postPage title=%s file=%s " % (issue["postTitle"],gen_Html))
|
print("create postPage title=%s file=%s " % (issue["postTitle"],gen_Html))
|
||||||
|
|
||||||
def createPlistHtml(self):
|
def createPlistHtml(self):
|
||||||
self.blogBase["postListJson"]=dict(sorted(self.blogBase["postListJson"].items(),key=lambda x:x[1]["createdAt"],reverse=True))#使列表由时间排序
|
self.blogBase["postListJson"]=dict(sorted(self.blogBase["postListJson"].items(),key=lambda x:(x[1]["top"],x[1]["createdAt"]),reverse=True))#使列表由时间排序
|
||||||
|
|
||||||
f = open(self.root_dir+"index.html", 'w', encoding='UTF-8')
|
f = open(self.root_dir+"index.html", 'w', encoding='UTF-8')
|
||||||
f.write(self.plist_example % json.dumps(self.blogBase))
|
f.write(self.plist_example % json.dumps(self.blogBase))
|
||||||
@ -138,14 +139,21 @@ class GMEEK():
|
|||||||
else:
|
else:
|
||||||
period="."
|
period="."
|
||||||
self.blogBase["postListJson"][postNum]["description"]=issue.body.split(period)[0]+period
|
self.blogBase["postListJson"][postNum]["description"]=issue.body.split(period)[0]+period
|
||||||
|
|
||||||
|
self.blogBase["postListJson"][postNum]["top"]=0
|
||||||
|
for event in issue.get_events():
|
||||||
|
if event.event=="pinned":
|
||||||
|
self.blogBase["postListJson"][postNum]["top"]=1
|
||||||
|
break
|
||||||
|
elif event.event=="unpinned":
|
||||||
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
postConfig=json.loads(issue.body.split("\r\n")[-1:][0].split("##")[1])
|
postConfig=json.loads(issue.body.split("\r\n")[-1:][0].split("##")[1])
|
||||||
print("Has Custom JSON parameters")
|
print("Has Custom JSON parameters")
|
||||||
print(postConfig)
|
print(postConfig)
|
||||||
except:
|
except:
|
||||||
postConfig={}
|
postConfig={}
|
||||||
print("No Custom JSON parameters")
|
|
||||||
|
|
||||||
if "timestamp" in postConfig:
|
if "timestamp" in postConfig:
|
||||||
self.blogBase["postListJson"][postNum]["createdAt"]=postConfig["timestamp"]
|
self.blogBase["postListJson"][postNum]["createdAt"]=postConfig["timestamp"]
|
||||||
|
|||||||
5
icon.js
5
icon.js
@ -9,5 +9,6 @@ var IconList={
|
|||||||
"search":"M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z",
|
"search":"M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z",
|
||||||
"home":"M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z",
|
"home":"M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z",
|
||||||
"email":"M1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25v-8.5C0 2.784.784 2 1.75 2ZM1.5 12.251c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V5.809L8.38 9.397a.75.75 0 0 1-.76 0L1.5 5.809v6.442Zm13-8.181v-.32a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25v.32L8 7.88Z",
|
"email":"M1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25v-8.5C0 2.784.784 2 1.75 2ZM1.5 12.251c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V5.809L8.38 9.397a.75.75 0 0 1-.76 0L1.5 5.809v6.442Zm13-8.181v-.32a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25v.32L8 7.88Z",
|
||||||
"rss":"M2.002 2.725a.75.75 0 0 1 .797-.699C8.79 2.42 13.58 7.21 13.974 13.201a.75.75 0 0 1-1.497.098 10.502 10.502 0 0 0-9.776-9.776.747.747 0 0 1-.7-.798ZM2.84 7.05h-.002a7.002 7.002 0 0 1 6.113 6.111.75.75 0 0 1-1.49.178 5.503 5.503 0 0 0-4.8-4.8.75.75 0 0 1 .179-1.489ZM2 13a1 1 0 1 1 2 0 1 1 0 0 1-2 0Z"
|
"rss":"M2.002 2.725a.75.75 0 0 1 .797-.699C8.79 2.42 13.58 7.21 13.974 13.201a.75.75 0 0 1-1.497.098 10.502 10.502 0 0 0-9.776-9.776.747.747 0 0 1-.7-.798ZM2.84 7.05h-.002a7.002 7.002 0 0 1 6.113 6.111.75.75 0 0 1-1.49.178 5.503 5.503 0 0 0-4.8-4.8.75.75 0 0 1 .179-1.489ZM2 13a1 1 0 1 1 2 0 1 1 0 0 1-2 0Z",
|
||||||
}
|
"star":"M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user