needComment用于配置是否需要评论功能

This commit is contained in:
Meekdai 2024-07-01 16:49:30 +08:00
parent e93fd1b946
commit 4d9fe5ac8f
2 changed files with 7 additions and 3 deletions

View File

@ -74,14 +74,13 @@ class GMEEK():
os.mkdir(self.post_dir) os.mkdir(self.post_dir)
if os.path.exists(self.static_dir): if os.path.exists(self.static_dir):
target_static_dir = os.path.join(self.root_dir, 'static') shutil.copytree(self.static_dir, os.path.join(self.root_dir, 'static'))
shutil.copytree(self.static_dir, target_static_dir)
print("Copy static to docs") print("Copy static to docs")
else: else:
print("static not exist") print("static not exist")
def defaultConfig(self): def defaultConfig(self):
dconfig={"singlePage":[],"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","themeMode":"manual","dayTheme":"light","nightTheme":"dark","urlMode":"pinyin","script":"","style":"","indexScript":"","indexStyle":"","bottomText":"","showPostSource":1,"iconList":{},"UTC":+8,"rssSplit":"sentence","exlink":{}} dconfig={"singlePage":[],"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","themeMode":"manual","dayTheme":"light","nightTheme":"dark","urlMode":"pinyin","script":"","style":"","indexScript":"","indexStyle":"","bottomText":"","showPostSource":1,"iconList":{},"UTC":+8,"rssSplit":"sentence","exlink":{},"needComment":1}
config=json.loads(open('config.json', 'r', encoding='utf-8').read()) config=json.loads(open('config.json', 'r', encoding='utf-8').read())
self.blogBase={**dconfig,**config}.copy() self.blogBase={**dconfig,**config}.copy()
self.blogBase["postListJson"]=json.loads('{}') self.blogBase["postListJson"]=json.loads('{}')

View File

@ -57,8 +57,10 @@
{% block content %} {% block content %}
<div class="markdown-body" id="postBody">{{ blogBase['postBody'] }}</div> <div class="markdown-body" id="postBody">{{ blogBase['postBody'] }}</div>
<div style="font-size:small;margin-top:8px;float:right;">{{ blogBase['bottomText'] }}</div> <div style="font-size:small;margin-top:8px;float:right;">{{ blogBase['bottomText'] }}</div>
{% if blogBase['needComment']==1 %}
<button class="btn btn-block" type="button" onclick="openComments()" id="cmButton">{{ i18n['comments'] }}</button> <button class="btn btn-block" type="button" onclick="openComments()" id="cmButton">{{ i18n['comments'] }}</button>
<div class="comments" id="comments"></div> <div class="comments" id="comments"></div>
{% endif %}
{% endblock %} {% endblock %}
{% block script %} {% block script %}
@ -72,6 +74,8 @@ document.getElementById("pathIssue").setAttribute("d",IconList["github"]);
span.innerHTML="{{ blogBase['commentNum'] }}"; span.innerHTML="{{ blogBase['commentNum'] }}";
cmButton.appendChild(span); cmButton.appendChild(span);
{%- endif %} {%- endif %}
{% if blogBase['needComment']==1 %}
function openComments(){ function openComments(){
cm=document.getElementById("comments"); cm=document.getElementById("comments");
cmButton=document.getElementById("cmButton"); cmButton=document.getElementById("cmButton");
@ -109,6 +113,7 @@ function iFrameLoading(){
} }
} }
} }
{%- endif %}
</script> </script>
{{ blogBase['script'] }} {{ blogBase['script'] }}
{% endblock %} {% endblock %}