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 %>.