mirror of https://github.com/Meekdai/Gmeek.git
config配置文件精简,添加配置Theme参数
This commit is contained in:
parent
369543e155
commit
c4561b6a74
|
|
@ -12,14 +12,7 @@
|
||||||
"homeUrl":"http://blog.meekdai.com",
|
"homeUrl":"http://blog.meekdai.com",
|
||||||
"avatarUrl":"http://meekdai.com/avatar.jpg",
|
"avatarUrl":"http://meekdai.com/avatar.jpg",
|
||||||
"faviconUrl":"http://meekdai.com/favicon.ico",
|
"faviconUrl":"http://meekdai.com/favicon.ico",
|
||||||
"email":"meekdai@163.com",
|
|
||||||
"startSite":"02/16/2015",
|
|
||||||
"filingNum":"浙ICP备20023628号",
|
|
||||||
"onePageListNum":15,
|
|
||||||
"singlePage":["link","about"],
|
"singlePage":["link","about"],
|
||||||
"commentLabelColor":"#006b75",
|
|
||||||
"yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],
|
|
||||||
"i18n":"CN",
|
|
||||||
"GMEEK_VERSION":"v2.3"
|
"GMEEK_VERSION":"v2.3"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
22
Gmeek.py
22
Gmeek.py
|
|
@ -43,18 +43,9 @@ class GMEEK():
|
||||||
self.labelColorDict=json.loads('{}')
|
self.labelColorDict=json.loads('{}')
|
||||||
for label in self.repo.get_labels():
|
for label in self.repo.get_labels():
|
||||||
self.labelColorDict[label.name]='#'+label.color
|
self.labelColorDict[label.name]='#'+label.color
|
||||||
|
|
||||||
print(self.labelColorDict)
|
print(self.labelColorDict)
|
||||||
|
|
||||||
config=json.loads(open('config.json', 'r', encoding='utf-8').read())
|
self.defaultConfig()
|
||||||
self.blogBase=config.copy()
|
|
||||||
self.blogBase["postListJson"]=json.loads('{}')
|
|
||||||
self.blogBase["singeListJson"]=json.loads('{}')
|
|
||||||
|
|
||||||
if self.blogBase["i18n"]=="CN":
|
|
||||||
self.i18n=i18nCN
|
|
||||||
else:
|
|
||||||
self.i18n=i18n
|
|
||||||
|
|
||||||
def cleanFile(self):
|
def cleanFile(self):
|
||||||
if os.path.exists(self.backup_dir):
|
if os.path.exists(self.backup_dir):
|
||||||
|
|
@ -67,6 +58,17 @@ class GMEEK():
|
||||||
os.mkdir(self.root_dir)
|
os.mkdir(self.root_dir)
|
||||||
os.mkdir(self.post_dir)
|
os.mkdir(self.post_dir)
|
||||||
|
|
||||||
|
def defaultConfig(self):
|
||||||
|
dconfig={"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","dayTheme":"light","nightTheme":"dark"}
|
||||||
|
config=json.loads(open('config.json', 'r', encoding='utf-8').read())
|
||||||
|
self.blogBase={**dconfig,**config}.copy()
|
||||||
|
self.blogBase["postListJson"]=json.loads('{}')
|
||||||
|
self.blogBase["singeListJson"]=json.loads('{}')
|
||||||
|
if self.blogBase["i18n"]=="CN":
|
||||||
|
self.i18n=i18nCN
|
||||||
|
else:
|
||||||
|
self.i18n=i18n
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
<link rel="icon" href="{{ blogBase['faviconUrl'] }}">
|
<link rel="icon" href="{{ blogBase['faviconUrl'] }}">
|
||||||
<script>
|
<script>
|
||||||
if(localStorage.getItem("meek_theme")==null){}
|
if(localStorage.getItem("meek_theme")==null){}
|
||||||
else if(localStorage.getItem("meek_theme")=="dark"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="dark";}
|
else if(localStorage.getItem("meek_theme")=="dark"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['nightTheme'] }}";}
|
||||||
else if(localStorage.getItem("meek_theme")=="light"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="light";}
|
else if(localStorage.getItem("meek_theme")=="light"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['dayTheme'] }}";}
|
||||||
</script>
|
</script>
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -46,13 +46,13 @@ else if(localStorage.getItem("meek_theme")=="dark"){changeDark();}
|
||||||
else if(localStorage.getItem("meek_theme")=="light"){changeLight();}
|
else if(localStorage.getItem("meek_theme")=="light"){changeLight();}
|
||||||
|
|
||||||
function changeDark(){
|
function changeDark(){
|
||||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="dark";
|
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['nightTheme'] }}";
|
||||||
document.getElementById("themeSwitch").setAttribute("d",value=IconList["moon"]);
|
document.getElementById("themeSwitch").setAttribute("d",value=IconList["moon"]);
|
||||||
document.getElementById("themeSwitch").parentNode.style.color="#00f0ff";
|
document.getElementById("themeSwitch").parentNode.style.color="#00f0ff";
|
||||||
if(utterancesLoad==1){utterancesTheme("dark-blue");}
|
if(utterancesLoad==1){utterancesTheme("dark-blue");}
|
||||||
}
|
}
|
||||||
function changeLight(){
|
function changeLight(){
|
||||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="light";
|
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['dayTheme'] }}";
|
||||||
document.getElementById("themeSwitch").setAttribute("d",value=IconList["sun"]);
|
document.getElementById("themeSwitch").setAttribute("d",value=IconList["sun"]);
|
||||||
document.getElementById("themeSwitch").parentNode.style.color="#ff5000";
|
document.getElementById("themeSwitch").parentNode.style.color="#ff5000";
|
||||||
if(utterancesLoad==1){utterancesTheme("github-light");}
|
if(utterancesLoad==1){utterancesTheme("github-light");}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue