diff --git a/app/post/routes.py b/app/post/routes.py index b364580e..cc9f8957 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -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, diff --git a/app/post/util.py b/app/post/util.py index 19a2b6b5..7aa3d9c5 100644 --- a/app/post/util.py +++ b/app/post/util.py @@ -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 diff --git a/app/templates/post/_post_full.html b/app/templates/post/_post_full.html index c6ebc741..01c5b79c 100644 --- a/app/templates/post/_post_full.html +++ b/app/templates/post/_post_full.html @@ -144,8 +144,8 @@ {% endif -%}