Spaces:
Running
Running
Update post_blog.py
Browse files- post_blog.py +30 -38
post_blog.py
CHANGED
@@ -48,42 +48,35 @@ def generate_post_html(title, summary, mindmap, category, citation):
|
|
48 |
image = generate_image(title, summary, category)
|
49 |
html_summary = mistune.html(summary)
|
50 |
post = f"""
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
<br>
|
81 |
-
<br>
|
82 |
-
<h2>Citation</h2>
|
83 |
-
<p id="paper_citation" data="{citation.replace("&", "&")}">
|
84 |
-
{mistune.html(citation.replace("&", "&"))}
|
85 |
-
</p>
|
86 |
-
</div>
|
87 |
"""
|
88 |
return post, image
|
89 |
|
@@ -125,13 +118,12 @@ def post_post(title, category, body, image):
|
|
125 |
"labels": [category, "recent"]
|
126 |
}
|
127 |
data = requests.post(url, headers=headers, json=post_data).json()
|
|
|
128 |
if data['status'] == 'LIVE':
|
129 |
return True
|
130 |
else:
|
131 |
-
print(data)
|
132 |
return False
|
133 |
except Exception as e:
|
134 |
-
print(data)
|
135 |
print('An error occurred:', str(e))
|
136 |
return False
|
137 |
|
|
|
48 |
image = generate_image(title, summary, category)
|
49 |
html_summary = mistune.html(summary)
|
50 |
post = f"""
|
51 |
+
<div>
|
52 |
+
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest"></script>
|
53 |
+
<style>
|
54 |
+
.markmap {{
|
55 |
+
position: relative;
|
56 |
+
}}
|
57 |
+
.markmap > svg {{
|
58 |
+
width: 100%;
|
59 |
+
border: 2px solid #000;
|
60 |
+
height: 80dvh;
|
61 |
+
}}
|
62 |
+
</style>
|
63 |
+
<img style='display:block; width:100%;height:100%;' id='paper_image' src='{image}' />
|
64 |
+
<br>
|
65 |
+
<p id="paper_summary" data="{summary.replace("&", "&")}">{html_summary.replace("&", "&")}</p>
|
66 |
+
<br>
|
67 |
+
<br>
|
68 |
+
<h2>Mindmap</h2>
|
69 |
+
<div class="markmap" id="paper_mindmap" data="# {title} \n {mindmap.replace("&", "&")}">
|
70 |
+
<script type="text/template">
|
71 |
+
{mindmap.replace("&", "&")}
|
72 |
+
</script>
|
73 |
+
</div>
|
74 |
+
<br>
|
75 |
+
<h2>Citation</h2>
|
76 |
+
<p id="paper_citation" data="{citation.replace("&", "&")}">
|
77 |
+
{mistune.html(citation.replace("&", "&"))}
|
78 |
+
</p>
|
79 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
"""
|
81 |
return post, image
|
82 |
|
|
|
118 |
"labels": [category, "recent"]
|
119 |
}
|
120 |
data = requests.post(url, headers=headers, json=post_data).json()
|
121 |
+
print(data)
|
122 |
if data['status'] == 'LIVE':
|
123 |
return True
|
124 |
else:
|
|
|
125 |
return False
|
126 |
except Exception as e:
|
|
|
127 |
print('An error occurred:', str(e))
|
128 |
return False
|
129 |
|