Improving ogimages.
This commit is contained in:
parent
6de7c91676
commit
13f38ac67e
@ -21,9 +21,12 @@ sub index {
|
|||||||
my $current_category = $categories->{'index'};
|
my $current_category = $categories->{'index'};
|
||||||
|
|
||||||
# Render template "example/welcome.html.ep" with message
|
# Render template "example/welcome.html.ep" with message
|
||||||
|
my $base_url = $self->config('base_url');
|
||||||
|
$self->stash( ogimage =>
|
||||||
|
( $base_url . '/' . $current_category->{slug} . '-preview.png' ) );
|
||||||
$self->render(
|
$self->render(
|
||||||
categories => $categories,
|
categories => $categories,
|
||||||
current_category => $current_category
|
current_category => $current_category,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +76,8 @@ sub category_rss {
|
|||||||
my $description_tag = Mojo::DOM->new_tag( 'description',
|
my $description_tag = Mojo::DOM->new_tag( 'description',
|
||||||
'Todas las noticias de la categoria de Burguillos.info '
|
'Todas las noticias de la categoria de Burguillos.info '
|
||||||
. $category->{title} );
|
. $category->{title} );
|
||||||
my $link_tag = Mojo::DOM->new_tag( 'link',
|
my $link_tag =
|
||||||
$base_url . '/' . $category->{slug} );
|
Mojo::DOM->new_tag( 'link', $base_url . '/' . $category->{slug} );
|
||||||
$channel_tag->child_nodes->first->append_content($title_tag);
|
$channel_tag->child_nodes->first->append_content($title_tag);
|
||||||
$channel_tag->child_nodes->first->append_content($description_tag);
|
$channel_tag->child_nodes->first->append_content($description_tag);
|
||||||
$channel_tag->child_nodes->first->append_content($link_tag);
|
$channel_tag->child_nodes->first->append_content($link_tag);
|
||||||
@ -99,8 +102,8 @@ sub _post_to_rss {
|
|||||||
my $item_tag = Mojo::DOM->new_tag('item');
|
my $item_tag = Mojo::DOM->new_tag('item');
|
||||||
my $title_tag = Mojo::DOM->new_tag( 'title', $post->{title} );
|
my $title_tag = Mojo::DOM->new_tag( 'title', $post->{title} );
|
||||||
my $base_url = BurguillosInfo->new->config->{base_url};
|
my $base_url = BurguillosInfo->new->config->{base_url};
|
||||||
my $link = Mojo::DOM->new_tag( 'link',
|
my $link =
|
||||||
$base_url = '/posts/' . $post->{slug} );
|
Mojo::DOM->new_tag( 'link', $base_url = '/posts/' . $post->{slug} );
|
||||||
my $description = Mojo::DOM->new_tag( 'description',
|
my $description = Mojo::DOM->new_tag( 'description',
|
||||||
Mojo::DOM->new( $post->{content} )->all_text );
|
Mojo::DOM->new( $post->{content} )->all_text );
|
||||||
my $guid = Mojo::DOM->new_tag( 'guid', $post->{slug} );
|
my $guid = Mojo::DOM->new_tag( 'guid', $post->{slug} );
|
||||||
@ -149,10 +152,11 @@ sub category {
|
|||||||
$self->render( template => '404', status => 404 );
|
$self->render( template => '404', status => 404 );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$self->stash( ogimage =>
|
||||||
|
( $base_url . '/' . $current_category->{slug} . '-preview.png' ) );
|
||||||
$self->render(
|
$self->render(
|
||||||
template => 'page/index',
|
template => 'page/index',
|
||||||
categories => $categories,
|
categories => $categories,
|
||||||
ogimage => $base_url . '/' . $current_category->{slug} . '-preview.png',
|
|
||||||
current_category => $current_category
|
current_category => $current_category
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,17 @@
|
|||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="description" content="<%=defined $description_og ? $description_og : 'Lee más sobre: ' . title %>" />
|
<meta name="description" content="<%=defined $description_og ? $description_og : 'Lee más sobre: ' . title %>" />
|
||||||
<meta property="og:title" content="<%= title %>"/>
|
<meta property="og:title" content="<%= title %>"/>
|
||||||
<meta property="og:site_name" content="burguillos.info" />
|
<meta property="og:site_name" content="Burguillos Info" />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
% my $ogimage = stash 'ogimage';
|
% my $ogimage = stash 'ogimage';
|
||||||
|
% say STDERR $ogimage;
|
||||||
% my $user_agent = stash 'useragent';
|
% my $user_agent = stash 'useragent';
|
||||||
|
|
||||||
% if (defined $ogimage) {
|
% if (defined $ogimage) {
|
||||||
|
% my $url_for = url_for || '';
|
||||||
<meta itemprop="image" property="og:image" content="<%= $ogimage %>"/>
|
<meta itemprop="image" property="og:image" content="<%= $ogimage %>"/>
|
||||||
|
<meta name="image" property="og:image" content="<%= $ogimage %>"/>
|
||||||
|
<meta property="og:url" content="<%=$base_url%><%= url_for %>"/>
|
||||||
<meta property="og:image:width" content="1200"/>
|
<meta property="og:image:width" content="1200"/>
|
||||||
<meta property="og:image:height" content="630"/>
|
<meta property="og:image:height" content="630"/>
|
||||||
<meta name="twitter:image" content="<%=$ogimage%>" />
|
<meta name="twitter:image" content="<%=$ogimage%>" />
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%
|
%
|
||||||
% my $description_og = '<div>'.$current_category->{description}.'</div>';
|
% my $description_og = '<div>'.$current_category->{description}.'</div>';
|
||||||
% $description_og = Mojo::DOM->new($description_og)->all_text;
|
% $description_og = Mojo::DOM->new($description_og)->all_text;
|
||||||
% layout 'default', current_category_slug => $current_category->{slug}, description_og => $description_og, , ogimage => "/$current_category->{slug}-preview.png?v=4";
|
% layout 'default', current_category_slug => $current_category->{slug}, description_og => $description_og;
|
||||||
% title $current_category->{title};
|
% title $current_category->{title};
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<h1><%= $current_category->{title} %></h1>
|
<h1><%= $current_category->{title} %></h1>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
% my $description_og = '<div>'.$post->{content}.'</div>';
|
% my $description_og = '<div>'.$post->{content}.'</div>';
|
||||||
% $description_og = Mojo::DOM->new($description_og)->all_text;
|
% $description_og = Mojo::DOM->new($description_og)->all_text;
|
||||||
% my $base_url = config 'base_url';
|
% my $base_url = config 'base_url';
|
||||||
% layout 'default', current_category_slug => $current_category->{slug}, categories => $categories, description_og => $description_og, ogimage => "$base_url/posts/$post->{slug}-preview.png?v=4";
|
% layout 'default', current_category_slug => $current_category->{slug}, categories => $categories, description_og => $description_og;
|
||||||
% title $post->{title};
|
% title $post->{title};
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<h1><%= $post->{title} %></h1>
|
<h1><%= $post->{title} %></h1>
|
||||||
|
Loading…
Reference in New Issue
Block a user