mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Tweak OpenGraph
This commit is contained in:
parent
5dce025700
commit
34579bd151
2 changed files with 10 additions and 1 deletions
|
@ -77,6 +77,7 @@
|
|||
|
||||
{% if meta and meta.og_metadata and obj | has_type('Note') %}
|
||||
{% for og in meta.og_metadata %}
|
||||
{% if og.url %}
|
||||
<a href="{{ og.url }}" class="og-link" style="margin:30px 0;clear:both;display: flex;">
|
||||
<div>
|
||||
<img style="width:100px;border-radius:3px;" src="{{ og.image | get_og_image_url }}">
|
||||
|
@ -87,6 +88,7 @@
|
|||
<small>{{ og.site_name }}</small>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -42,4 +42,11 @@ def fetch_og_metadata(user_agent, links):
|
|||
r = requests.get(l, headers={"User-Agent": user_agent}, timeout=15)
|
||||
r.raise_for_status()
|
||||
htmls.append(r.text)
|
||||
return [dict(opengraph.OpenGraph(html=html)) for html in htmls]
|
||||
|
||||
res = []
|
||||
for html in htmls:
|
||||
data = dict(opengraph.OpenGraph(html=html))
|
||||
if data.get("url"):
|
||||
res.append(data)
|
||||
|
||||
return res
|
||||
|
|
Loading…
Reference in a new issue