支持medium-zoom库提供的图像放缩显示功能
This commit is contained in:
parent
03ee911f40
commit
4e9f0e7343
6
Gmeek.py
6
Gmeek.py
@ -72,7 +72,7 @@ class GMEEK():
|
|||||||
os.mkdir(self.post_dir)
|
os.mkdir(self.post_dir)
|
||||||
|
|
||||||
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":"","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":"","bottomText":"","showPostSource":1,"iconList":{},"UTC":+8,"rssSplit":"sentence","exlink":{},"useMediumZoom":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('{}')
|
||||||
@ -138,6 +138,10 @@ class GMEEK():
|
|||||||
post_body=re.sub(r'</math-renderer>','',post_body)
|
post_body=re.sub(r'</math-renderer>','',post_body)
|
||||||
issue["script"]=issue["script"]+'<script>MathJax = {tex: {inlineMath: [["$", "$"]]}};</script><script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>'
|
issue["script"]=issue["script"]+'<script>MathJax = {tex: {inlineMath: [["$", "$"]]}};</script><script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>'
|
||||||
|
|
||||||
|
if postBase["useMediumZoom"] == 1:
|
||||||
|
# match <a> tags containing only <img> tags regardless of newlines and remove them
|
||||||
|
post_body = re.sub(r"<a [^>]*>\s*(<img [^>]*>)\s*</a>", r"\1", post_body, flags=re.DOTALL)
|
||||||
|
|
||||||
postBase["postTitle"]=issue["postTitle"]
|
postBase["postTitle"]=issue["postTitle"]
|
||||||
postBase["postUrl"]=self.blogBase["homeUrl"]+"/"+issue["postUrl"]
|
postBase["postUrl"]=self.blogBase["homeUrl"]+"/"+issue["postUrl"]
|
||||||
postBase["description"]=issue["description"]
|
postBase["description"]=issue["description"]
|
||||||
|
|||||||
@ -65,6 +65,14 @@
|
|||||||
<script>
|
<script>
|
||||||
document.getElementById("pathHome").setAttribute("d",IconList["home"]);
|
document.getElementById("pathHome").setAttribute("d",IconList["home"]);
|
||||||
document.getElementById("pathIssue").setAttribute("d",IconList["github"]);
|
document.getElementById("pathIssue").setAttribute("d",IconList["github"]);
|
||||||
|
{% if blogBase['useMediumZoom']==1 -%}
|
||||||
|
// importing the medium-zoom library for <img>
|
||||||
|
let medium_zoom_script = document.createElement('script');
|
||||||
|
medium_zoom_script.src = 'https://unpkg.com/medium-zoom/dist/medium-zoom.min.js';
|
||||||
|
// only impose medium-zoom to images in the postBody
|
||||||
|
medium_zoom_script.onload = function() {mediumZoom('#postBody img');};
|
||||||
|
document.head.appendChild(medium_zoom_script);
|
||||||
|
{%- endif %}
|
||||||
{% if blogBase['commentNum']>0 -%}
|
{% if blogBase['commentNum']>0 -%}
|
||||||
cmButton=document.getElementById("cmButton");
|
cmButton=document.getElementById("cmButton");
|
||||||
span=document.createElement("span");
|
span=document.createElement("span");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user