image: fix 403 access problem from Medium

This commit is contained in:
ZhymabekRoman 2025-01-25 11:33:03 +05:00
parent a085e2e55e
commit 13ab8edce2
2 changed files with 19 additions and 16 deletions

View file

@ -361,7 +361,7 @@ class MediumParser:
out_paragraphs.append(header_template_rendered)
elif paragraph["type"] == "IMG":
image_template = jinja_env.from_string(
'<div class="mt-7"><img alt="{{ paragraph.metadata.alt }}" class="pt-5 m-auto lazy" role="presentation" data-src="https://miro.medium.com/v2/resize:fit:700/{{ paragraph.metadata.id }}"></div>'
'<div class="mt-7"><img alt="{{ paragraph.metadata.alt }}" class="pt-5 m-auto lazy" role="presentation" referrerpolicy="no-referrer" data-src="https://miro.medium.com/v2/resize:fit:700/{{ paragraph.metadata.id }}"></div>'
)
image_caption_template = jinja_env.from_string(
"<figcaption class='mt-3 text-sm text-center text-gray-500 dark:text-gray-200'>{{ text }}</figcaption>"
@ -530,7 +530,7 @@ class MediumParser:
elif paragraph["type"] == "MIXTAPE_EMBED":
# TODO: redirect all Medium embeding articles to Fredium
embed_template = jinja_env.from_string(
'<div class="items-center p-2 overflow-hidden border border-gray-300 mt-7"><a rel="noopener follow" href="{{ url }}" target="_blank"> <div class="flex flex-row justify-between p-2 overflow-hidden"><div class="flex flex-col justify-center p-2"><h2 class="text-base font-bold text-black dark:text-gray-100">{{ embed_title }}</h2><div class="block mt-2"><h3 class="text-sm text-grey-darker">{{ embed_description }}</h3></div><div class="mt-5"><p class="text-xs text-grey-darker">{{ embed_site }}</p></div></div><div class="relative flex h-40 flew-row w-60"><div class="absolute inset-0 bg-center bg-cover lazy" data-bg="https://miro.medium.com/v2/resize:fit:320/{{ paragraph.mixtapeMetadata.thumbnailImageId }}"></div></div></div> </a></div>'
'<div class="items-center p-2 overflow-hidden border border-gray-300 mt-7"><a rel="noopener follow" href="{{ url }}" target="_blank"> <div class="flex flex-row justify-between p-2 overflow-hidden"><div class="flex flex-col justify-center p-2"><h2 class="text-base font-bold text-black dark:text-gray-100">{{ embed_title }}</h2><div class="block mt-2"><h3 class="text-sm text-grey-darker">{{ embed_description }}</h3></div><div class="mt-5"><p class="text-xs text-grey-darker">{{ embed_site }}</p></div></div><div class="relative flex h-40 flew-row w-60"><div class="absolute inset-0 bg-center bg-cover lazy" referrerpolicy="no-referrer" data-bg="https://miro.medium.com/v2/resize:fit:320/{{ paragraph.mixtapeMetadata.thumbnailImageId }}"></div></div></div> </a></div>'
)
if paragraph.get("mixtapeMetadata") is not None:
url = paragraph["mixtapeMetadata"]["href"]

View file

@ -1,8 +1,8 @@
<div class="container w-full md:max-w-3xl mx-auto pt-20 break-words">
<div class="w-full px-4 md:px-6 text-xl text-gray-800 leading-normal" style="font-family:Georgia,serif">
<div class="container w-full pt-20 mx-auto break-words md:max-w-3xl">
<div class="w-full px-4 text-xl leading-normal text-gray-800 md:px-6" style="font-family:Georgia,serif">
<div class="font-sans">
<p class="text-base md:text-sm text-green-500 font-bold pb-3">
<a href="{{ url }}" class="text-sm md:text-sm text-green-500 font-bold no-underline hover:underline ">&lt; Go to the original</a>
<p class="pb-3 text-base font-bold text-green-500 md:text-sm">
<a href="{{ url }}" class="text-sm font-bold text-green-500 no-underline md:text-sm hover:underline ">&lt; Go to the original</a>
</p>
{% if previewImageId %}
<img alt="Preview image"
@ -11,19 +11,21 @@
margin: auto"
loading="eager"
role="presentation"
referrerpolicy="no-referrer"
src="https://miro.medium.com/v2/resize:fit:700/{{ previewImageId }}">
{% endif %}
<h1 class="font-bold font-sans break-normal text-gray-900 pt-6 pb-2 text-3xl md:text-4xl">{{ title }}</h1>
{% if subtitle %}<h2 class="font-medium font-sans break-normal text-gray-600 pt-1 pb-3 text-1xl md:text-1xl">{{ subtitle }}</h2>{% endif %}
<h1 class="pt-6 pb-2 font-sans text-3xl font-bold text-gray-900 break-normal md:text-4xl">{{ title }}</h1>
{% if subtitle %}<h2 class="pt-1 pb-3 font-sans font-medium text-gray-600 break-normal text-1xl md:text-1xl">{{ subtitle }}</h2>{% endif %}
</div>
<div class="bg-gray-100 border border-gray-300 m-2">
<div class="flex items-center space-x-4 p-4">
<div class="m-2 bg-gray-100 border border-gray-300">
<div class="flex items-center p-4 space-x-4">
<div class="flex-shrink-0">
<a href="https://medium.com/@{{ creator.username }}" target="_blank" title="{{ creator.bio }}" class="block relative">
<a href="https://medium.com/@{{ creator.username }}" target="_blank" title="{{ creator.bio }}" class="relative block">
<img src="https://miro.medium.com/v2/resize:fill:88:88/{{ creator.imageId }}"
alt="{{ creator.name }}"
referrerpolicy="no-referrer"
class="rounded-full h-11 w-11 no-lightense">
<div class="absolute bottom-0 right-0 h-3 w-3 border-2 border-white bg-green-500 rounded-full"></div>
<div class="absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-white rounded-full"></div>
</a>
</div>
<div class="flex-grow">
@ -31,7 +33,7 @@
target="_blank"
title="{{ creator.bio }}"
class="block font-semibold text-gray-900">{{ creator.name }}</a>
<button class="text-sm text-white bg-green-500 px-3 py-1 rounded-lg mt-1">
<button class="px-3 py-1 mt-1 text-sm text-white bg-green-500 rounded-lg">
<a href="https://medium.com/@{{ creator.username }}"
target="_blank"
title="{{ creator.bio }}"
@ -48,7 +50,8 @@
class="flex items-center space-x-1">
<img src="https://miro.medium.com/v2/resize:fill:48:48/{{ collection.avatar.id }}"
alt="{{ collection.name }}"
class="h-4 w-4 rounded-full no-lightense">
referrerpolicy="no-referrer"
class="w-4 h-4 rounded-full no-lightense">
<p>{{ collection.name }}</p>
</a>
<span>·</span>
@ -63,9 +66,9 @@
</div>
{% for paragraph in content %}{{ paragraph }}{% endfor %}
<div class="flex flex-wrap gap-2 mt-5">
{% for tag in tags %}<a title="{{ tag.displayTitle }}" target="_blank" href="https://medium.com/tag/{{ tag.normalizedTagSlug }}"><span class="text-green-500 bg-green-100 px-2 py-1 rounded-full text-xs">#{{ tag.normalizedTagSlug }}</span></a>{% endfor %}
{% for tag in tags %}<a title="{{ tag.displayTitle }}" target="_blank" href="https://medium.com/tag/{{ tag.normalizedTagSlug }}"><span class="px-2 py-1 text-xs text-green-500 bg-green-100 rounded-full">#{{ tag.normalizedTagSlug }}</span></a>{% endfor %}
</div>
<div class="container w-full md:max-w-3xl mx-auto pt-12"></div>
<div class="container w-full pt-12 mx-auto md:max-w-3xl"></div>
</div>
<style>
code {