From 46c59e1c698ebdd4b9113ecfecae82dd8c10197e Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sun, 13 Nov 2022 02:22:31 +0100 Subject: [PATCH] We have to lie Linkedin telling them there are not images there. --- lib/BurguillosInfo/Controller/Page.pm | 1 + templates/page/post.html.ep | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/BurguillosInfo/Controller/Page.pm b/lib/BurguillosInfo/Controller/Page.pm index 7784273..c0e2c5e 100644 --- a/lib/BurguillosInfo/Controller/Page.pm +++ b/lib/BurguillosInfo/Controller/Page.pm @@ -120,6 +120,7 @@ sub post { } my $current_category = $categories->{ $post->{category} }; $self->stash(ogimage => 'https://burguillos.info/posts/'.$post->{slug}.'-preview.png'); + $self->stash(useragent => $self->req->headers->user_agent); $self->render( post => $post, current_category => $current_category ); } diff --git a/templates/page/post.html.ep b/templates/page/post.html.ep index c7814f1..8a1dcbd 100644 --- a/templates/page/post.html.ep +++ b/templates/page/post.html.ep @@ -10,7 +10,18 @@ % title $post->{title};

<%= $post->{title} %>

+% my $user_agent = stash 'useragent'; +% if ($user_agent !~ /LinkedInBot/) { <%== $post->{content} %> +% } else { +% my $content = $post->{content}; +% my $dom = Mojo::DOM->new($content); +% my @images = $dom->find('img')->each; +% for my $image (@images) { +% $image->remove; +% } + <%== $dom->to_string() %> +% } % my $date_article = DateTime::Format::ISO8601->parse_datetime($post->{date}); % $date_article->set_time_zone('Europe/Madrid');

Escrito por <%= $post->{author} %> con fecha <%= $date_article %>.