mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
no bypass, just provide an archive link #205
This commit is contained in:
parent
2b7ab8c415
commit
537ab9f4b8
3 changed files with 12 additions and 12 deletions
|
@ -15,8 +15,8 @@ from app.community.util import save_post, send_to_remote_instance
|
|||
from app.inoculation import inoculation
|
||||
from app.post.forms import NewReplyForm, ReportPostForm, MeaCulpaForm
|
||||
from app.community.forms import CreateLinkForm, CreateImageForm, CreateDiscussionForm, CreateVideoForm, CreatePollForm
|
||||
from app.post.util import post_replies, get_comment_branch, post_reply_count, tags_to_string, url_has_paywall, \
|
||||
generate_paywall_bypass_link, body_has_no_paywall_link
|
||||
from app.post.util import post_replies, get_comment_branch, post_reply_count, tags_to_string, url_needs_archive, \
|
||||
generate_archive_link, body_has_no_archive_link
|
||||
from app.constants import SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR, POST_TYPE_LINK, \
|
||||
POST_TYPE_IMAGE, \
|
||||
POST_TYPE_ARTICLE, POST_TYPE_VIDEO, NOTIF_REPLY, NOTIF_POST, POST_TYPE_POLL
|
||||
|
@ -300,10 +300,10 @@ def show_post(post_id: int):
|
|||
else:
|
||||
poll_form = True
|
||||
|
||||
# Bypass paywalls link
|
||||
bypass_paywall_link = None
|
||||
if post.type == POST_TYPE_LINK and body_has_no_paywall_link(post.body_html) and url_has_paywall(post.url):
|
||||
bypass_paywall_link = generate_paywall_bypass_link(post.url)
|
||||
# Archive.ph link
|
||||
archive_link = None
|
||||
if post.type == POST_TYPE_LINK and body_has_no_archive_link(post.body_html) and url_needs_archive(post.url):
|
||||
archive_link = generate_archive_link(post.url)
|
||||
|
||||
response = render_template('post/post.html', title=post.title, post=post, is_moderator=is_moderator, community=post.community,
|
||||
breadcrumbs=breadcrumbs, related_communities=related_communities, mods=mod_list,
|
||||
|
@ -312,7 +312,7 @@ def show_post(post_id: int):
|
|||
description=description, og_image=og_image, POST_TYPE_IMAGE=constants.POST_TYPE_IMAGE,
|
||||
POST_TYPE_LINK=constants.POST_TYPE_LINK, POST_TYPE_ARTICLE=constants.POST_TYPE_ARTICLE,
|
||||
POST_TYPE_VIDEO=constants.POST_TYPE_VIDEO, POST_TYPE_POLL=constants.POST_TYPE_POLL,
|
||||
autoplay=request.args.get('autoplay', False), bypass_paywall_link=bypass_paywall_link,
|
||||
autoplay=request.args.get('autoplay', False), archive_link=archive_link,
|
||||
noindex=not post.author.indexable, preconnect=post.url if post.url else None,
|
||||
recently_upvoted=recently_upvoted, recently_downvoted=recently_downvoted,
|
||||
recently_upvoted_replies=recently_upvoted_replies, recently_downvoted_replies=recently_downvoted_replies,
|
||||
|
|
|
@ -81,14 +81,14 @@ def tags_to_string(post: Post) -> str:
|
|||
return ', '.join([tag.name for tag in post.tags])
|
||||
|
||||
|
||||
def body_has_no_paywall_link(body):
|
||||
def body_has_no_archive_link(body):
|
||||
if body:
|
||||
return 'https://archive.' not in body and 'https://12ft.io' not in body
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def url_has_paywall(url) -> bool:
|
||||
def url_needs_archive(url) -> bool:
|
||||
paywalled_sites = ['washingtonpost.com', 'nytimes.com', 'wsj.com', 'economist.com', 'ft.com', 'telegraph.co.uk',
|
||||
'bild.de', 'theatlantic.com', 'lemonde.fr', 'nzherald.co.nz']
|
||||
if url:
|
||||
|
@ -102,5 +102,5 @@ def url_has_paywall(url) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def generate_paywall_bypass_link(url) -> bool:
|
||||
def generate_archive_link(url) -> bool:
|
||||
return 'https://archive.ph/' + url
|
||||
|
|
|
@ -144,8 +144,8 @@
|
|||
{% endif -%}
|
||||
<div class="post_body">
|
||||
{{ post.body_html|community_links|safe if post.body_html else '' }}
|
||||
{% if bypass_paywall_link -%}
|
||||
<p><a href="{{ bypass_paywall_link }}">{{ _('Bypass paywall') }}</a></p>
|
||||
{% if archive_link -%}
|
||||
<p><a href="{{ archive_link }}">{{ _('Archive.ph link') }}</a></p>
|
||||
{% endif -%}
|
||||
</div>
|
||||
{% if post.type == POST_TYPE_POLL -%}
|
||||
|
|
Loading…
Add table
Reference in a new issue