raannakasturi commited on
Commit
5b507dc
·
verified ·
1 Parent(s): 9452f95

Update post_blog.py

Browse files
Files changed (1) hide show
  1. 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
- <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
- <br>
66
- <p id="paper_summary" data="{summary.replace("&amp;", "&")}">{html_summary.replace("&amp;", "&")}</p>
67
- <br>
68
- <br>
69
- <h2>Mindmap</h2>
70
- <div class="markmap" id="paper_mindmap" data="# {title} \n {mindmap.replace("&amp;", "&")}">
71
- <script type="text/template">
72
- ---
73
- title: {title}
74
- markmap:
75
- maxWidth: 300
76
- ---
77
- {mindmap.replace("&amp;", "&")}
78
- </script>
79
- </div>
80
- <br>
81
- <br>
82
- <h2>Citation</h2>
83
- <p id="paper_citation" data="{citation.replace("&amp;", "&")}">
84
- {mistune.html(citation.replace("&amp;", "&"))}
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("&amp;", "&")}">{html_summary.replace("&amp;", "&")}</p>
66
+ <br>
67
+ <br>
68
+ <h2>Mindmap</h2>
69
+ <div class="markmap" id="paper_mindmap" data="# {title} \n {mindmap.replace("&amp;", "&")}">
70
+ <script type="text/template">
71
+ {mindmap.replace("&amp;", "&")}
72
+ </script>
73
+ </div>
74
+ <br>
75
+ <h2>Citation</h2>
76
+ <p id="paper_citation" data="{citation.replace("&amp;", "&")}">
77
+ {mistune.html(citation.replace("&amp;", "&"))}
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