diff --git a/content/posts/0000024-bar-restaurante-duran.xml b/content/posts/0000024-bar-restaurante-duran.xml
index cc55856..b12972b 100644
--- a/content/posts/0000024-bar-restaurante-duran.xml
+++ b/content/posts/0000024-bar-restaurante-duran.xml
@@ -3,7 +3,7 @@
2023-05-05T22:21+00:00
Carta y Menú del Bar - Restaurante Durán - Centro de día en Burguillos.
Carta y Menú del Bar - Restaurante Durán - Centro de día en Burguillos.
-
+
donde-comer
hamburguesas
diff --git a/content/posts/0000025-bar-cafe-beluche.xml b/content/posts/0000025-bar-cafe-beluche.xml
index 5cde79c..5bb3ae8 100644
--- a/content/posts/0000025-bar-cafe-beluche.xml
+++ b/content/posts/0000025-bar-cafe-beluche.xml
@@ -4,7 +4,7 @@
Carta y Menú del Café - Bar Beluche en Burguillos.
2023-09-13T16:03+00:00
Carta y Menú del Café - Bar Beluche en Burguillos.
-
+
2
donde-comer
diff --git a/lib/BurguillosInfo/Posts.pm b/lib/BurguillosInfo/Posts.pm
index a0b7b83..8537961 100644
--- a/lib/BurguillosInfo/Posts.pm
+++ b/lib/BurguillosInfo/Posts.pm
@@ -77,6 +77,7 @@ sub _GeneratePostFromFile ( $self, $post_file ) {
my $pinned_node = $dom->at(':root > pinned');
my $image_element = $dom->at(':root > img');
my $image;
+ my $image_bottom_preview;
my $attributes = $self->_GetAttributes( $post_file, $dom );
my $pinned;
@@ -84,7 +85,8 @@ sub _GeneratePostFromFile ( $self, $post_file ) {
$pinned = int( $pinned_node->text );
}
if ( defined $image_element ) {
- $image = $image_element->attr->{src};
+ $image = $image_element->attr->{src};
+ $image_bottom_preview = $image_element->attr->{'bottom-preview'};
}
my $last_modification_date_element =
@@ -95,14 +97,15 @@ sub _GeneratePostFromFile ( $self, $post_file ) {
}
return {
- title => $title,
- author => $author,
- date => $date,
- ogdesc => $ogdesc,
- category => $category,
- slug => $slug,
- content => $content,
- attributes => $attributes,
+ title => $title,
+ author => $author,
+ date => $date,
+ ogdesc => $ogdesc,
+ category => $category,
+ slug => $slug,
+ content => $content,
+ attributes => $attributes,
+ image_bottom_preview => $image_bottom_preview,
(
( defined $last_modification_date )
? ( last_modification_date => $last_modification_date )
@@ -181,8 +184,10 @@ sub RetrieveAllPostsForCategory ( $self, $category_name ) {
}
sub shufflePostsIfRequired ( $self, $category, $posts ) {
- my $pinned_posts = [ sort { $b->{pinned} <=> $b->{pinned} }
- grep { exists $_->{pinned} } @$posts ];
+ my $pinned_posts = [
+ sort { $b->{pinned} <=> $b->{pinned} }
+ grep { exists $_->{pinned} } @$posts
+ ];
$posts = [ grep { !exists $_->{pinned} } @$posts ];
$pinned_posts = [ sort { $b <=> $a } @$pinned_posts ];
if ( exists $category->{random} && $category->{random} ) {
@@ -205,11 +210,13 @@ sub RetrieveDirectPostsForCategory ( $self, $category_name ) {
}
sub PreviewOg {
- my $self = shift;
- my $post = shift;
- my $title = $post->{title};
- my $content = $post->{content};
- my $image_file = $post->{image};
- return BurguillosInfo::Preview->Generate( $title, $content, $image_file );
+ my $self = shift;
+ my $post = shift;
+ my $title = $post->{title};
+ my $content = $post->{content};
+ my $image_file = $post->{image};
+ my $image_bottom_preview = $post->{image_bottom_preview};
+ return BurguillosInfo::Preview->Generate( $title, $content, $image_file,
+ $image_bottom_preview );
}
1;
diff --git a/lib/BurguillosInfo/Preview.pm b/lib/BurguillosInfo/Preview.pm
index 338507e..69d7a55 100644
--- a/lib/BurguillosInfo/Preview.pm
+++ b/lib/BurguillosInfo/Preview.pm
@@ -23,13 +23,13 @@ const my $SVG_HEIGHT => 627;
const my $SVG_EMBEDDED_IMAGE_MAX_WIDTH => 1200;
const my $SVG_EMBEDDED_IMAGE_MAX_HEIGHT => 400;
-sub Generate($self, $title, $content, $image_file) {
+sub Generate($self, $title, $content, $image_file, $image_bottom_preview) {
my $dom = Mojo::DOM->new($content);
$content = $dom->all_text;
my $svg =
- $self->_GenerateSVGPreview( $title, $self->_DivideTextContentInLines($content), $image_file );
+ $self->_GenerateSVGPreview( $title, $self->_DivideTextContentInLines($content), $image_file, $image_bottom_preview );
return $self->_SVGToPNG($svg);
}
@@ -80,7 +80,7 @@ sub _GenerateSVGPreviewHeaderBar($self, $svg, $group) {
)->cdata('Burguillos.info');
}
-sub _GenerateSVGPreview($self, $title, $content, $image_file) {
+sub _GenerateSVGPreview($self, $title, $content, $image_file, $image_bottom_preview) {
my @content = @$content;
my $svg = SVG->new( width => $SVG_WIDTH, height => $SVG_HEIGHT );
@@ -97,7 +97,7 @@ sub _GenerateSVGPreview($self, $title, $content, $image_file) {
my $new_y;
if ( defined $image_file ) {
- $new_y = $self->_AttachImageSVG( $svg, $group, $image_file );
+ $new_y = $self->_AttachImageSVG( $svg, $group, $image_file, $image_bottom_preview );
}
$new_y //= 100;
@@ -155,7 +155,7 @@ sub _DivideTextContentInLines($self, $content) {
return \@new_content;
}
-sub _AttachImageSVG($self, $svg, $group, $image_file) {
+sub _AttachImageSVG($self, $svg, $group, $image_file, $image_bottom_preview) {
$image_file = $PUBLIC_DIR->child( './' . $image_file );
$image_file = path($self->_ToPng($image_file));
my ( $stdout, $stderr, $error ) = capture {
@@ -187,7 +187,10 @@ sub _AttachImageSVG($self, $svg, $group, $image_file) {
$clip_path->rect(x => 0, y => 50, width => 1200, height => $height);
my $x = 0;
- my $y_image = 50 - $height_complete_image + $height;
+ my $y_image = 50 - $height_complete_image + $height;
+ if (defined $image_bottom_preview && $height_complete_image > $SVG_EMBEDDED_IMAGE_MAX_HEIGHT) {
+ $y_image += $height_complete_image - $image_bottom_preview;
+ }
my $y = 50;
my ($output) = capture {
system qw/file --mime-type/, $image_file;