添加多label支持
This commit is contained in:
parent
38c90b9ab6
commit
11ce33e617
15
Gmeek.py
15
Gmeek.py
@ -77,6 +77,7 @@ class GMEEK():
|
|||||||
self.blogBase={**dconfig,**config}.copy()
|
self.blogBase={**dconfig,**config}.copy()
|
||||||
self.blogBase["postListJson"]=json.loads('{}')
|
self.blogBase["postListJson"]=json.loads('{}')
|
||||||
self.blogBase["singeListJson"]=json.loads('{}')
|
self.blogBase["singeListJson"]=json.loads('{}')
|
||||||
|
self.blogBase["labelColorDict"]=self.labelColorDict
|
||||||
if "displayTitle" not in self.blogBase:
|
if "displayTitle" not in self.blogBase:
|
||||||
self.blogBase["displayTitle"]=self.blogBase["title"]
|
self.blogBase["displayTitle"]=self.blogBase["title"]
|
||||||
|
|
||||||
@ -148,7 +149,7 @@ class GMEEK():
|
|||||||
else:
|
else:
|
||||||
postBase["highlight"]=0
|
postBase["highlight"]=0
|
||||||
|
|
||||||
if issue["label"] in self.blogBase["singlePage"]:
|
if issue["labels"][0] in self.blogBase["singlePage"]:
|
||||||
postBase["bottomText"]=''
|
postBase["bottomText"]=''
|
||||||
|
|
||||||
keys=['sun','moon','sync','home','github']
|
keys=['sun','moon','sync','home','github']
|
||||||
@ -223,10 +224,10 @@ class GMEEK():
|
|||||||
|
|
||||||
for num in self.blogBase["singeListJson"]:
|
for num in self.blogBase["singeListJson"]:
|
||||||
item=feed.add_item()
|
item=feed.add_item()
|
||||||
item.guid(self.blogBase["homeUrl"]+"/"+self.blogBase["singeListJson"][num]["label"]+".html",permalink=True)
|
item.guid(self.blogBase["homeUrl"]+"/"+self.blogBase["singeListJson"][num]["postUrl"],permalink=True)
|
||||||
item.title(self.blogBase["singeListJson"][num]["postTitle"])
|
item.title(self.blogBase["singeListJson"][num]["postTitle"])
|
||||||
item.description(self.blogBase["singeListJson"][num]["description"])
|
item.description(self.blogBase["singeListJson"][num]["description"])
|
||||||
item.link(href=self.blogBase["homeUrl"]+"/"+self.blogBase["singeListJson"][num]["label"]+".html")
|
item.link(href=self.blogBase["homeUrl"]+"/"+self.blogBase["singeListJson"][num]["postUrl"])
|
||||||
item.pubDate(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(self.blogBase["singeListJson"][num]["createdAt"])))
|
item.pubDate(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(self.blogBase["singeListJson"][num]["createdAt"])))
|
||||||
|
|
||||||
for num in self.blogBase["postListJson"]:
|
for num in self.blogBase["postListJson"]:
|
||||||
@ -258,7 +259,7 @@ class GMEEK():
|
|||||||
feed.rss_file(self.root_dir+'rss.xml')
|
feed.rss_file(self.root_dir+'rss.xml')
|
||||||
|
|
||||||
def addOnePostJson(self,issue):
|
def addOnePostJson(self,issue):
|
||||||
if len(issue.labels)==1:
|
if len(issue.labels)>=1:
|
||||||
if issue.labels[0].name in self.blogBase["singlePage"]:
|
if issue.labels[0].name in self.blogBase["singlePage"]:
|
||||||
listJsonName='singeListJson'
|
listJsonName='singeListJson'
|
||||||
htmlFile='{}.html'.format(self.createFileName(issue,useLabel=True))
|
htmlFile='{}.html'.format(self.createFileName(issue,useLabel=True))
|
||||||
@ -271,8 +272,8 @@ class GMEEK():
|
|||||||
postNum="P"+str(issue.number)
|
postNum="P"+str(issue.number)
|
||||||
self.blogBase[listJsonName][postNum]=json.loads('{}')
|
self.blogBase[listJsonName][postNum]=json.loads('{}')
|
||||||
self.blogBase[listJsonName][postNum]["htmlDir"]=gen_Html
|
self.blogBase[listJsonName][postNum]["htmlDir"]=gen_Html
|
||||||
self.blogBase[listJsonName][postNum]["label"]=issue.labels[0].name
|
self.blogBase[listJsonName][postNum]["labels"]=[label.name for label in issue.labels]
|
||||||
self.blogBase[listJsonName][postNum]["labelColor"]=self.labelColorDict[issue.labels[0].name]
|
# self.blogBase[listJsonName][postNum]["labelColor"]=self.labelColorDict[issue.labels[0].name]
|
||||||
self.blogBase[listJsonName][postNum]["postTitle"]=issue.title
|
self.blogBase[listJsonName][postNum]["postTitle"]=issue.title
|
||||||
self.blogBase[listJsonName][postNum]["postUrl"]=urllib.parse.quote(gen_Html[len(self.root_dir):])
|
self.blogBase[listJsonName][postNum]["postUrl"]=urllib.parse.quote(gen_Html[len(self.root_dir):])
|
||||||
|
|
||||||
@ -431,6 +432,8 @@ for i in blog.blogBase["postListJson"]:
|
|||||||
wordCount=wordCount+blog.blogBase["postListJson"][i]["wordCount"]
|
wordCount=wordCount+blog.blogBase["postListJson"][i]["wordCount"]
|
||||||
del blog.blogBase["postListJson"][i]["wordCount"]
|
del blog.blogBase["postListJson"][i]["wordCount"]
|
||||||
|
|
||||||
|
blog.blogBase["postListJson"]["labelColorDict"]=blog.labelColorDict
|
||||||
|
|
||||||
docListFile=open(blog.root_dir+"postList.json","w")
|
docListFile=open(blog.root_dir+"postList.json","w")
|
||||||
docListFile.write(json.dumps(blog.blogBase["postListJson"]))
|
docListFile.write(json.dumps(blog.blogBase["postListJson"]))
|
||||||
docListFile.close()
|
docListFile.close()
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button></a>
|
</button></a>
|
||||||
{% for num in blogBase['singeListJson'] -%}
|
{% for num in blogBase['singeListJson'] -%}
|
||||||
<a href="{{ blogBase['homeUrl'] }}/{{ blogBase['singeListJson'][num]['label'] }}.html"><button class="btn btn-invisible circle" title="{{ blogBase['singeListJson'][num]['postTitle'] }}">
|
<a href="{{ blogBase['homeUrl'] }}/{{ blogBase['singeListJson'][num]['labels'][0] }}.html"><button class="btn btn-invisible circle" title="{{ blogBase['singeListJson'][num]['postTitle'] }}">
|
||||||
<svg class="octicon" width="16" height="16" >
|
<svg class="octicon" width="16" height="16" >
|
||||||
<path id="{{ blogBase['singeListJson'][num]['postTitle'] }}" fill-rule="evenodd"></path>
|
<path id="{{ blogBase['singeListJson'][num]['postTitle'] }}" fill-rule="evenodd"></path>
|
||||||
</svg>
|
</svg>
|
||||||
@ -78,7 +78,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="listLabels">
|
<div class="listLabels">
|
||||||
{% if postListJson[num]['commentNum']>0 %}<span class="Label" style="background-color:{{ blogBase['commentLabelColor'] }}">{{ postListJson[num]['commentNum'] }}</span>{% endif %}
|
{% if postListJson[num]['commentNum']>0 %}<span class="Label" style="background-color:{{ blogBase['commentLabelColor'] }}">{{ postListJson[num]['commentNum'] }}</span>{% endif %}
|
||||||
<span class="Label LabelName" style="background-color:{{ postListJson[num]['labelColor'] }}"><object><a style="color:#fff" href="{{ blogBase['homeUrl'] }}/tag.html#{{ postListJson[num]['label'] }}">{{ postListJson[num]['label'] }}</a></object></span>
|
{% for label in postListJson[num]['labels'] -%}
|
||||||
|
<span class="Label LabelName" style="background-color:{{ blogBase['labelColorDict'][label] }}"><object><a style="color:#fff" href="tag.html#{{ label }}">{{ label }}</a></object></span>
|
||||||
|
{%- endfor %}
|
||||||
<span class="Label LabelTime" style="background-color:{{ postListJson[num]['dateLabelColor'] }}">{{ postListJson[num]['createdDate'] }}</span>
|
<span class="Label LabelTime" style="background-color:{{ postListJson[num]['dateLabelColor'] }}">{{ postListJson[num]['createdDate'] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
@ -119,7 +121,7 @@ for(var i=0;i<iconPost.length;i++){
|
|||||||
}
|
}
|
||||||
|
|
||||||
{% for num in blogBase['singeListJson'] -%}
|
{% for num in blogBase['singeListJson'] -%}
|
||||||
document.getElementById("{{ blogBase['singeListJson'][num]['postTitle'] }}").setAttribute("d",value=IconList["{{ blogBase['singeListJson'][num]['label'] }}"]);
|
document.getElementById("{{ blogBase['singeListJson'][num]['postTitle'] }}").setAttribute("d",value=IconList["{{ blogBase['singeListJson'][num]['labels'][0] }}"]);
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -91,14 +91,16 @@ function showList(){
|
|||||||
tagLable.appendChild(showLabels);
|
tagLable.appendChild(showLabels);
|
||||||
}
|
}
|
||||||
for(i in jsonData){
|
for(i in jsonData){
|
||||||
if(!(tagList.includes(jsonData[i]['label']))){
|
for(label in jsonData[i]['labels']){
|
||||||
tagList.push(jsonData[i]['label']);
|
if(!(tagList.includes(label))){
|
||||||
let showLabels=document.createElement("button");
|
tagList.push(label);
|
||||||
showLabels.setAttribute("class","Label");
|
let showLabels=document.createElement("button");
|
||||||
showLabels.setAttribute("style","background-color:"+jsonData[i]['labelColor']);
|
showLabels.setAttribute("class","Label");
|
||||||
showLabels.innerHTML=jsonData[i]['label'];
|
showLabels.setAttribute("style","background-color:"+jsonData['labelColorDict'][label]);
|
||||||
showLabels.setAttribute("onclick","javascript:updateShowTag('"+jsonData[i]['label']+"');");
|
showLabels.innerHTML=label;
|
||||||
tagLable.appendChild(showLabels);
|
showLabels.setAttribute("onclick","javascript:updateShowTag('"+label+"');");
|
||||||
|
tagLable.appendChild(showLabels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let div=document.createElement("div");
|
let div=document.createElement("div");
|
||||||
@ -126,11 +128,14 @@ function showList(){
|
|||||||
|
|
||||||
let listLabels=document.createElement("div");
|
let listLabels=document.createElement("div");
|
||||||
listLabels.setAttribute("class","listLabels");
|
listLabels.setAttribute("class","listLabels");
|
||||||
let LabelName=document.createElement("span");
|
|
||||||
LabelName.setAttribute("class","Label LabelName");
|
for(label in jsonData[i]['labels']){
|
||||||
LabelName.setAttribute("style","background-color:"+jsonData[i]['labelColor']);
|
let LabelName=document.createElement("span");
|
||||||
LabelName.innerHTML=jsonData[i]['label'];
|
LabelName.setAttribute("class","Label LabelName");
|
||||||
listLabels.appendChild(LabelName);
|
LabelName.setAttribute("style","background-color:"+jsonData['labelColorDict'][label]);
|
||||||
|
LabelName.innerHTML=label;
|
||||||
|
listLabels.appendChild(LabelName);
|
||||||
|
}
|
||||||
let LabelTime=document.createElement("span");
|
let LabelTime=document.createElement("span");
|
||||||
LabelTime.setAttribute("class","Label LabelTime");
|
LabelTime.setAttribute("class","Label LabelTime");
|
||||||
LabelTime.setAttribute("style","background-color:"+jsonData[i]['dateLabelColor']);
|
LabelTime.setAttribute("style","background-color:"+jsonData[i]['dateLabelColor']);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user