Fixing previews.

This commit is contained in:
sergiotarxz 2023-05-17 04:44:41 +02:00
parent a76b17de27
commit 19bfe3b9b4
2 changed files with 8 additions and 7 deletions

View File

@ -11,6 +11,7 @@ use Const::Fast;
use Mojo::DOM;
use Path::Tiny;
use OwlcodeTech;
use OwlcodeTech::Preview;
const my $CURRENT_FILE => __FILE__;
@ -158,8 +159,9 @@ sub _AvoidGrandChildCategories ( $self, $categories ) {
sub PreviewOg ( $self, $category ) {
my $title = $category->{title};
my $description = $category->{description};
my $site_name = $self->config('site_name');
return OwlcodeTech::Preview->Generate( $title, $description, undef,
my $image = $category->{image};
my $site_name = OwlcodeTech->new->config('site_name');
return OwlcodeTech::Preview->Generate( $title, $description, $image,
$site_name );
}
1;

View File

@ -17,7 +17,7 @@ use MIME::Base64;
const my $CURRENT_FILE => __FILE__;
const my $ROOT_PROJECT => path($CURRENT_FILE)->parent->parent->parent;
const my $PUBLIC_DIR => $ROOT_PROJECT->child('public');
const my $BURGUILLOS_LOGO => $PUBLIC_DIR->child('img/burguillos.webp');
const my $OWLCODE_LOGO => $PUBLIC_DIR->child('img/owlcode_tech.webp');
const my $SVG_WIDTH => 1200;
const my $SVG_HEIGHT => 627;
const my $SVG_EMBEDDED_IMAGE_MAX_WIDTH => 1000;
@ -26,6 +26,7 @@ const my $SVG_EMBEDDED_IMAGE_MAX_HEIGHT => 200;
sub Generate ( $self, $title, $content, $image_file, $site_name ) {
my $dom = Mojo::DOM->new($content);
$content = $dom->all_text;
$title = Mojo::DOM->new('<div>'.$title.'</div>')->all_text;
my $svg =
$self->_GenerateSVGPreview( $title,
@ -62,16 +63,14 @@ sub _GenerateSVGPreviewHeaderBar ( $self, $svg, $group, $site_name ) {
style => { fill => '#F8F8FF' }
);
my $burguillos_logo_png = path( $self->_ToPng($BURGUILLOS_LOGO) );
say $burguillos_logo_png;
say '' . $burguillos_logo_png;
my $owlcode_logo_png = path( $self->_ToPng($OWLCODE_LOGO) );
$group->image(
x => 10,
y => 5,
width => 40,
height => 40,
-href => 'data:image/png;base64,'
. encode_base64( $burguillos_logo_png->slurp )
. encode_base64( $owlcode_logo_png->slurp )
);
$group->text(
x => 60,