Rebranding the code, still not made any frontend branding.

This commit is contained in:
sergiotarxz 2023-05-09 03:20:23 +02:00
parent b3e96df1f1
commit b69f3babb7
22 changed files with 194 additions and 166 deletions

View File

@ -1,12 +1,12 @@
package BurguillosInfo;
package OwlcodeTech;
use BurguillosInfo::Controller::Metrics;
use OwlcodeTech::Controller::Metrics;
use Mojo::Base 'Mojolicious', -signatures;
# This method will run once at server start
sub startup ($self) {
my $metrics = BurguillosInfo::Controller::Metrics->new;
my $metrics = OwlcodeTech::Controller::Metrics->new;
$self->hook(
around_dispatch => sub {
my $next = shift;

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Categories;
package OwlcodeTech::Categories;
use v5.34.1;
@ -11,7 +11,7 @@ use Const::Fast;
use Mojo::DOM;
use Path::Tiny;
use BurguillosInfo::Preview;
use OwlcodeTech::Preview;
const my $CURRENT_FILE => __FILE__;
const my $CATEGORIES_DIR =>
@ -23,7 +23,7 @@ sub new {
return bless {}, shift;
}
sub Retrieve($self) {
sub Retrieve ($self) {
if ( defined $cached_categories ) {
return $cached_categories;
}
@ -31,21 +31,22 @@ sub Retrieve($self) {
for my $category_file ( $CATEGORIES_DIR->children ) {
warn "Bad file $category_file, omiting...", next
if !-f $category_file || $category_file !~ /\.xml$/;
my $dom = Mojo::DOM->new( $category_file->slurp_utf8 );
defined(my $title = $dom->at(':root > title')->text)
my $dom = Mojo::DOM->new( $category_file->slurp_utf8 );
defined( my $title = $dom->at(':root > title')->text )
or die "Missing title at $category_file.";
defined(my $description = $dom->at(':root > description')->content)
defined( my $description = $dom->at(':root > description')->content )
or die "Missing description at $category_file";
defined(my $slug = $dom->at(':root > slug')->text)
defined( my $slug = $dom->at(':root > slug')->text )
or die "Missing slug at $category_file";
defined (my $menu_text = $dom->at(':root > menu_text')->content)
defined( my $menu_text = $dom->at(':root > menu_text')->content )
or die "Missing menu_text at $category_file";
defined (my $priority = $dom->at(':root > priority')->text)
defined( my $priority = $dom->at(':root > priority')->text )
or die "Missing priority at $category_file";
my $attributes = $self->_GetAttributes($dom, $category_file);
my $attributes = $self->_GetAttributes( $dom, $category_file );
my $parent_tag = $dom->at(':root > parent');
my $parent;
if (defined $parent_tag) {
if ( defined $parent_tag ) {
$parent = $parent_tag->content;
}
my $category = {
@ -55,9 +56,9 @@ sub Retrieve($self) {
description => $description,
priority => $priority,
(
(defined $parent) ?
(parent => $parent) :
()
( defined $parent )
? ( parent => $parent )
: ()
),
attributes => $attributes,
};
@ -68,64 +69,73 @@ sub Retrieve($self) {
return $cached_categories;
}
sub _GetAttributes($self, $dom, $category_file) {
sub _GetAttributes ( $self, $dom, $category_file ) {
my $attributes_tag = $dom->at(':root > attributes');
my %attributes;
if (defined $attributes_tag) {
my @attribute_tag_list = $attributes_tag->find('attributes > attribute')->each;
if ( defined $attributes_tag ) {
my @attribute_tag_list =
$attributes_tag->find('attributes > attribute')->each;
for my $attribute_tag (@attribute_tag_list) {
defined (my $menu_text = $attribute_tag->at('attribute > menu_text')->content)
defined( my $menu_text =
$attribute_tag->at('attribute > menu_text')->content )
or die "Missing attribute menu_text at $category_file";
defined (my $description = $attribute_tag->at('attribute > description')->content)
defined( my $description =
$attribute_tag->at('attribute > description')->content )
or die "Missing attribute description at $category_file";
defined (my $title = $attribute_tag->at('attribute > title')->text)
defined( my $title = $attribute_tag->at('attribute > title')->text )
or die "Missing attribute title at $category_file";
defined (my $identifier = $attribute_tag->at('attribute > identifier')->text)
defined( my $identifier =
$attribute_tag->at('attribute > identifier')->text )
or die "Missing attribute identifier at $category_file";
defined (my $priority = $attribute_tag->at('attribute > priority')->text)
defined( my $priority =
$attribute_tag->at('attribute > priority')->text )
or die "Missing attribute priority at $category_file";
$attributes{$identifier} = {
title => $title,
identifier => $identifier,
priority => $priority,
menu_text => $menu_text,
description => $description,
title => $title,
identifier => $identifier,
priority => $priority,
menu_text => $menu_text,
description => $description,
};
}
}
return \%attributes;
}
sub _PopulateChildrenField($self, $categories) {
for my $category_name (keys %$categories) {
sub _PopulateChildrenField ( $self, $categories ) {
for my $category_name ( keys %$categories ) {
my $category = $categories->{$category_name};
$category->{children} //= [];
my $parent_name = $category->{parent};
if (!defined $parent_name) {
if ( !defined $parent_name ) {
next;
}
my $parent = $categories->{$parent_name};
if (!defined $parent) {
die "Category $parent not exists and is the parent of $category_name.";
if ( !defined $parent ) {
die
"Category $parent not exists and is the parent of $category_name.";
}
$parent->{children} //= [];
push $parent->{children}->@*, $category;
}
}
sub _AvoidGrandChildCategories($self, $categories) {
for my $category_slug (keys %$categories) {
sub _AvoidGrandChildCategories ( $self, $categories ) {
for my $category_slug ( keys %$categories ) {
my $category = $categories->{$category_slug};
my $parent = $category->{parent};
if (defined $parent && defined $categories->{$parent}{parent}) {
die "$category_slug category is grandchild of $categories->{$parent}{parent}) category and this is not allowed.";
my $parent = $category->{parent};
if ( defined $parent && defined $categories->{$parent}{parent} ) {
die
"$category_slug category is grandchild of $categories->{$parent}{parent}) category and this is not allowed.";
}
}
}
sub PreviewOg($self, $category) {
my $title = $category->{title};
sub PreviewOg ( $self, $category ) {
my $title = $category->{title};
my $description = $category->{description};
return BurguillosInfo::Preview->Generate($title, $description, undef);
my $site_name = $self->config('site_name');
return OwlcodeTech::Preview->Generate( $title, $description, undef,
$site_name );
}
1;

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Controller::Attribute;
package OwlcodeTech::Controller::Attribute;
use v5.34.1;
use strict;
@ -6,17 +6,18 @@ use warnings;
use Data::Dumper;
use BurguillosInfo::Categories;
use OwlcodeTech::Categories;
use Mojo::Base 'Mojolicious::Controller', -signatures;
use BurguillosInfo::Preview;
use OwlcodeTech::Preview;
sub get_attribute_preview ($self) {
my $category_slug = $self->param('category_slug');
my $attribute_slug = $self->param('attribute_slug');
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category = $categories->{$category_slug};
my $site_name = $self->config('site_name');
if ( !defined $category ) {
return $self->reply->not_found;
}
@ -27,8 +28,9 @@ sub get_attribute_preview ($self) {
$self->render(
format => 'png',
data => BurguillosInfo::Preview->Generate(
$attribute->{title}, $attribute->{description}, undef
data => OwlcodeTech::Preview->Generate(
$attribute->{title}, $attribute->{description},
undef, $site_name
),
);
}
@ -37,7 +39,7 @@ sub get ($self) {
my $category_slug = $self->param('category_slug');
my $attribute_slug = $self->param('attribute_slug');
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category = $categories->{$category_slug};
if ( !defined $category ) {
return $self->reply->not_found;
@ -46,8 +48,8 @@ sub get ($self) {
if ( !defined $attribute ) {
return $self->reply->not_found;
}
my $posts = BurguillosInfo::Posts->RetrieveDirectPostsForCategory(
$category->{slug} );
my $posts =
OwlcodeTech::Posts->RetrieveDirectPostsForCategory( $category->{slug} );
$posts = [ grep { defined $_->{attributes}{$attribute_slug} } @$posts ];
my $base_url = $self->config('base_url');
$self->render(

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Controller::Example;
package OwlcodeTech::Controller::Example;
use Mojo::Base 'Mojolicious::Controller', -signatures;
# This action will render a template

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Controller::Metrics;
package OwlcodeTech::Controller::Metrics;
use v5.34.1;
@ -7,7 +7,7 @@ use warnings;
use Data::Dumper;
use BurguillosInfo::Tracking;
use OwlcodeTech::Tracking;
use Mojo::Base 'Mojolicious::Controller', '-signatures';
@ -22,10 +22,15 @@ sub request {
shift;
my $c = shift;
my $app = $c->app;
if (!defined $tracking) {
$tracking = BurguillosInfo::Tracking->new($app);
}
$tracking->register_request($c);
eval {
if (!defined $tracking) {
$tracking = OwlcodeTech::Tracking->new($app);
}
$tracking->register_request($c);
};
if ($@) {
warn $@;
}
}
sub stats {

View File

@ -1,23 +1,23 @@
package BurguillosInfo::Controller::Page;
package OwlcodeTech::Controller::Page;
use v5.34.1;
use strict;
use warnings;
use BurguillosInfo::Categories;
use BurguillosInfo::Posts;
use OwlcodeTech::Categories;
use OwlcodeTech::Posts;
use Data::Dumper;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Base 'Mojolicious::Controller', '-signatures';
use DateTime::Format::ISO8601;
use DateTime::Format::Mail;
sub index {
my $self = shift;
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $current_category = $categories->{'index'};
# Render template "example/welcome.html.ep" with message
@ -29,22 +29,24 @@ sub index {
sub category_rss {
my $self = shift;
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category_name = $self->param('category');
my $current_category = $categories->{$category_name};
my ( $posts_categories, $posts_slug ) =
BurguillosInfo::Posts->new->Retrieve;
OwlcodeTech::Posts->new->Retrieve;
if ( !defined $current_category && $category_name ne 'all' ) {
$self->render( template => '404', status => 404 );
return;
}
my $dom = Mojo::DOM->new_tag( 'rss', version => '2.0', undef );
my $channel_tag = Mojo::DOM->new_tag('channel');
my $base_url = $self->config('base_url');
my $site_name = $self->config('site_name');
if ( $category_name eq 'all' ) {
my $title_tag = Mojo::DOM->new_tag( 'title', 'Burguillos.info' );
my $title_tag = Mojo::DOM->new_tag( 'title', $site_name );
my $description_tag = Mojo::DOM->new_tag( 'description',
'Todas las noticias de Burguillos.info.' );
my $link_tag = Mojo::DOM->new_tag( 'link', 'https://burguillos.info/' );
"Todas las noticias de $site_name." );
my $link_tag = Mojo::DOM->new_tag( 'link', $base_url );
$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($link_tag);
@ -52,19 +54,19 @@ sub category_rss {
my $posts = $posts_categories->{$category};
for my $post (@$posts) {
$channel_tag->child_nodes->first->append_content(
_post_to_rss($post) );
$self->_post_to_rss($post) );
}
}
}
else {
my $category = $current_category;
my $title_tag = Mojo::DOM->new_tag( 'title',
"Burguillos.info - " . $category->{title} );
"$site_name - " . $category->{title} );
my $description_tag = Mojo::DOM->new_tag( 'description',
'Todas las noticias de la categoria de Burguillos.info '
"Todas las noticias de la categoria de $site_name "
. $category->{title} );
my $link_tag = Mojo::DOM->new_tag( 'link',
'https://burguillos.info/' . $category->{slug} );
$base_url . '/' . $category->{slug} );
$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($link_tag);
@ -72,7 +74,7 @@ sub category_rss {
for my $post (@$posts) {
$channel_tag->child_nodes->first->append_content(
_post_to_rss($post) );
$self->_post_to_rss($post) );
}
}
@ -83,12 +85,12 @@ sub category_rss {
);
}
sub _post_to_rss {
my $post = shift;
sub _post_to_rss($self, $post) {
my $item_tag = Mojo::DOM->new_tag('item');
my $title_tag = Mojo::DOM->new_tag( 'title', $post->{title} );
my $base_url = $self->config('base_url');
my $link = Mojo::DOM->new_tag( 'link',
'https://burguillos.info/posts/' . $post->{slug} );
"$base_url/posts/" . $post->{slug} );
my $description = Mojo::DOM->new_tag( 'description',
Mojo::DOM->new( $post->{content} )->all_text );
my $guid = Mojo::DOM->new_tag( 'guid', $post->{slug} );
@ -112,8 +114,8 @@ sub post {
my $self = shift;
my $slug = $self->param('slug');
my ( $posts_categories, $posts_slug ) =
BurguillosInfo::Posts->new->Retrieve;
my $categories = BurguillosInfo::Categories->new->Retrieve;
OwlcodeTech::Posts->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $post = $posts_slug->{$slug};
if ( !defined $post ) {
$self->render( template => '404', status => 404 );
@ -129,7 +131,7 @@ sub post {
sub category {
my $self = shift;
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category_name = $self->param('category');
my $current_category = $categories->{$category_name};
my $base_url = $self->config('base_url');
@ -148,7 +150,7 @@ sub category {
sub get_category_preview {
my $self = shift;
my $category_slug = $self->param('category');
my $category_model = BurguillosInfo::Categories->new;
my $category_model = OwlcodeTech::Categories->new;
my $categories = $category_model->Retrieve;
if ( !defined $categories->{$category_slug} ) {
$self->render( template => '404', status => 404 );
@ -164,7 +166,7 @@ sub get_category_preview {
sub get_post_preview {
my $self = shift;
my $slug = $self->param('slug');
my $post_model = BurguillosInfo::Posts->new;
my $post_model = OwlcodeTech::Posts->new;
my ( $posts_categories, $posts_slug ) = $post_model->Retrieve;
if ( !defined $posts_slug->{$slug} ) {
$self->render( template => '404', status => 404 );

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Controller::Robots;
package OwlcodeTech::Controller::Robots;
use Mojo::Base 'Mojolicious::Controller', '-signatures';
sub robots($self) {

View File

@ -1,12 +1,12 @@
package BurguillosInfo::Controller::Sitemap;
package OwlcodeTech::Controller::Sitemap;
use v5.34.1;
use strict;
use warnings;
use BurguillosInfo::Categories;
use BurguillosInfo::Posts;
use OwlcodeTech::Categories;
use OwlcodeTech::Posts;
use DateTime::Format::ISO8601;
@ -15,7 +15,7 @@ use XML::Twig;
use Mojo::Base 'Mojolicious::Controller', '-signatures';
sub sitemap ($self) {
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $dom = Mojo::DOM->new_tag(
'urlset',
xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9',
@ -38,7 +38,7 @@ sub _append_category_dom ( $self, $dom, $category_key, $categories ) {
my $date_last_modification_category;
my ( $posts_categories, $posts_slug ) =
BurguillosInfo::Posts->new->Retrieve;
OwlcodeTech::Posts->new->Retrieve;
for my $post ( $posts_categories->{$category_key}->@* ) {
( $date_publish_category, $date_last_modification_category ) =
_get_dates_for_category( $date_publish_category,

View File

@ -1,4 +1,4 @@
package BurguillosInfo::DB;
package OwlcodeTech::DB;
use v5.34.1;
@ -8,7 +8,7 @@ use warnings;
use DBI;
use DBD::Pg;
use BurguillosInfo::DB::Migrations;
use OwlcodeTech::DB::Migrations;
use Data::Dumper;
my $dbh;
@ -38,7 +38,7 @@ sub _migrate {
my $dbh = shift;
local $dbh->{RaiseError} = 0;
local $dbh->{PrintError} = 0;
my @migrations = BurguillosInfo::DB::Migrations::MIGRATIONS();
my @migrations = OwlcodeTech::DB::Migrations::MIGRATIONS();
if ( $class->get_current_migration($dbh) > @migrations ) {
warn "Something happened there, wrong migration number.";
}

View File

@ -1,4 +1,4 @@
package BurguillosInfo::DB::Migrations;
package OwlcodeTech::DB::Migrations;
use v5.34.1;

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Posts;
package OwlcodeTech::Posts;
use v5.34.1;
@ -10,7 +10,7 @@ use feature 'signatures';
use Data::Dumper;
use MIME::Base64;
use BurguillosInfo::Categories;
use OwlcodeTech::Categories;
use Const::Fast;
use Mojo::DOM;
@ -18,12 +18,12 @@ use Path::Tiny;
use DateTime::Format::ISO8601;
use DateTime;
use BurguillosInfo::Preview;
use OwlcodeTech::Preview;
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 $POSTS_DIR => $ROOT_PROJECT->child('content/posts');
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 $POSTS_DIR => $ROOT_PROJECT->child('content/posts');
my $cached_posts_by_category;
my $cached_posts_by_slug;
@ -41,9 +41,7 @@ sub _ReturnCacheFilter {
for my $category ( keys %$cached_posts_by_category ) {
for my $post ( @{ $cached_posts_by_category->{$category} } ) {
my $date_post;
eval {
$date_post = $iso8601->parse_datetime( $post->{date} );
};
eval { $date_post = $iso8601->parse_datetime( $post->{date} ); };
if ($@) {
print Data::Dumper::Dumper $post;
}
@ -59,7 +57,7 @@ sub _ReturnCacheFilter {
}
sub _GeneratePostFromFile ( $self, $post_file ) {
warn "Bad file $post_file, omiting...", return
warn "Bad file $post_file, omiting...", return
if !-f $post_file || $post_file !~ /\.xml$/;
my $dom = Mojo::DOM->new( $post_file->slurp_utf8 );
my $title = $dom->at(':root > title')->text
@ -78,7 +76,7 @@ sub _GeneratePostFromFile ( $self, $post_file ) {
or die "Missing content at $post_file.";
my $image_element = $dom->at(':root > img');
my $image;
my $attributes = $self->_GetAttributes($post_file, $dom);
my $attributes = $self->_GetAttributes( $post_file, $dom );
if ( defined $image_element ) {
$image = $image_element->attr->{src};
@ -109,14 +107,15 @@ sub _GeneratePostFromFile ( $self, $post_file ) {
};
}
sub _GetAttributes($self, $post_file, $dom) {
sub _GetAttributes ( $self, $post_file, $dom ) {
my $attributes_tag = $dom->at(':root > attributes');
my %attributes;
if (defined $attributes_tag) {
my @attribute_list = $attributes_tag->find('attributes > attribute')->map('text')->each;
%attributes = map {
if ( defined $attributes_tag ) {
my @attribute_list =
$attributes_tag->find('attributes > attribute')->map('text')->each;
%attributes = map {
my $identifier = $_;
($identifier => 1);
( $identifier => 1 );
} @attribute_list;
}
return \%attributes;
@ -128,10 +127,10 @@ sub _GeneratePostCache ($self) {
$cached_posts_by_slug = {};
for my $post_file ( sort { $b cmp $a } $POSTS_DIR->children ) {
my $post = $self->_GeneratePostFromFile($post_file);
if (!defined $post) {
if ( !defined $post ) {
next;
}
my $category = $post->{category};
my $category = $post->{category};
$cached_posts_by_category->{$category} //= [];
my $slug = $post->{slug};
my $category_posts = $cached_posts_by_category->{$category};
@ -150,21 +149,22 @@ sub Retrieve {
}
my $cache_all_post_categories = {};
sub RetrieveAllPostsForCategory ( $self, $category_name ) {
if (defined $cache_all_post_categories->{$category_name}) {
if ( defined $cache_all_post_categories->{$category_name} ) {
return $cache_all_post_categories->{$category_name};
}
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category = $categories->{$category_name};
my $posts = $self->RetrieveDirectPostsForCategory($category_name);
for my $child_category ( $category->{children}->@* ) {
my $child_category_name = $child_category->{slug};
push @$posts,
@{$self->RetrieveDirectPostsForCategory($child_category_name)};
@{ $self->RetrieveDirectPostsForCategory($child_category_name) };
}
@$posts = sort {
DateTime::Format::ISO8601->parse_datetime($b->{date}) <=>
DateTime::Format::ISO8601->parse_datetime($a->{date})
@$posts = sort {
DateTime::Format::ISO8601->parse_datetime( $b->{date} )
<=> DateTime::Format::ISO8601->parse_datetime( $a->{date} )
} @$posts;
$cache_all_post_categories->{$category_name} = $posts;
return $posts;
@ -172,7 +172,7 @@ sub RetrieveAllPostsForCategory ( $self, $category_name ) {
sub RetrieveDirectPostsForCategory ( $self, $category_name ) {
my ($post_by_category) = $self->Retrieve;
my $categories = BurguillosInfo::Categories->new->Retrieve;
my $categories = OwlcodeTech::Categories->new->Retrieve;
my $category = $categories->{$category_name};
if ( !defined $category ) {
die "$category_name category does not exists";
@ -183,14 +183,14 @@ sub RetrieveDirectPostsForCategory ( $self, $category_name ) {
}
sub PreviewOg {
my $self = shift;
my $post = shift;
my $title = $post->{title};
my $content = $post->{content};
my $self = shift;
my $post = shift;
my $site_name = $self->config('site_name');
my $title = $post->{title};
my $content = $post->{content};
my $image_file = $post->{image};
return BurguillosInfo::Preview->Generate($title, $content, $image_file);
return OwlcodeTech::Preview->Generate( $title, $content, $image_file,
$site_name );
}
1;

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Preview;
package OwlcodeTech::Preview;
use v5.36.0;
@ -23,21 +23,22 @@ const my $SVG_HEIGHT => 627;
const my $SVG_EMBEDDED_IMAGE_MAX_WIDTH => 1000;
const my $SVG_EMBEDDED_IMAGE_MAX_HEIGHT => 200;
sub Generate($self, $title, $content, $image_file) {
my $dom = Mojo::DOM->new($content);
sub Generate ( $self, $title, $content, $image_file, $site_name ) {
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, $site_name );
return $self->_SVGToPNG($svg);
}
sub _ToPng($self, $image) {
if ($image =~ /\.\w+$/) {
sub _ToPng ( $self, $image ) {
if ( $image =~ /\.\w+$/ ) {
my $new_image = $image =~ s/\.\w+$/.generated.png/r;
say $new_image;
if (!-e $new_image) {
if ( !-e $new_image ) {
system 'convert', "$image", "$new_image";
}
$image = $new_image;
@ -45,7 +46,7 @@ sub _ToPng($self, $image) {
return path($image);
}
sub _GenerateSVGPreviewHeaderBar($self, $svg, $group) {
sub _GenerateSVGPreviewHeaderBar ( $self, $svg, $group, $site_name ) {
$group->rect(
x => 0,
y => 0,
@ -61,10 +62,9 @@ sub _GenerateSVGPreviewHeaderBar($self, $svg, $group) {
style => { fill => '#F8F8FF' }
);
my $burguillos_logo_png = path($self->_ToPng($BURGUILLOS_LOGO));
my $burguillos_logo_png = path( $self->_ToPng($BURGUILLOS_LOGO) );
say $burguillos_logo_png;
say ''.$burguillos_logo_png;
say '' . $burguillos_logo_png;
$group->image(
x => 10,
y => 5,
@ -77,10 +77,10 @@ sub _GenerateSVGPreviewHeaderBar($self, $svg, $group) {
x => 60,
y => 40,
style => { 'font-size' => 50, fill => '#f2eb8c' }
)->cdata('Burguillos.info');
)->cdata($site_name);
}
sub _GenerateSVGPreview($self, $title, $content, $image_file) {
sub _GenerateSVGPreview ( $self, $title, $content, $image_file, $site_name ) {
my @content = @$content;
my $svg = SVG->new( width => $SVG_WIDTH, height => $SVG_HEIGHT );
@ -92,7 +92,7 @@ sub _GenerateSVGPreview($self, $title, $content, $image_file) {
}
);
$self->_GenerateSVGPreviewHeaderBar($svg, $group);
$self->_GenerateSVGPreviewHeaderBar( $svg, $group, $site_name );
my $new_y;
@ -119,7 +119,7 @@ sub _GenerateSVGPreview($self, $title, $content, $image_file) {
return $svg->xmlify;
}
sub _SVGToPNG($self, $svg) {
sub _SVGToPNG ( $self, $svg ) {
my ( $stdout, $stderr ) = capture {
open my $fh, '|-', qw{convert /dev/stdin png:fd:1};
binmode $fh, 'utf8';
@ -130,7 +130,7 @@ sub _SVGToPNG($self, $svg) {
return $stdout;
}
sub _DivideTextContentInLines($self, $content) {
sub _DivideTextContentInLines ( $self, $content ) {
my @content_divided_in_lines = split /\n/, $content;
my @new_content;
my $n_chars_per_line = 70;
@ -153,9 +153,10 @@ sub _DivideTextContentInLines($self, $content) {
}
return \@new_content;
}
sub _AttachImageSVG($self, $svg, $image_file) {
sub _AttachImageSVG ( $self, $svg, $image_file ) {
$image_file = $PUBLIC_DIR->child( './' . $image_file );
$image_file = path($self->_ToPng($image_file));
$image_file = path( $self->_ToPng($image_file) );
my ( $stdout, $stderr, $error ) = capture {
system qw/identify -format "%wx%h"/, $image_file;
};

View File

@ -1,4 +1,4 @@
package BurguillosInfo::Tracking;
package OwlcodeTech::Tracking;
use v5.34.1;
@ -10,7 +10,7 @@ use feature 'signatures';
use JSON;
use Const::Fast;
use BurguillosInfo::DB;
use OwlcodeTech::DB;
my $app;
@ -22,12 +22,12 @@ EOF
sub new {
my $class = shift;
$app = shift;
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
return bless {}, $class;
}
sub _add_path ( $self, $url ) {
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
$dbh->do( <<'EOF', undef, $url );
INSERT INTO paths (path) VALUES($1)
ON CONFLICT (path) DO
@ -36,7 +36,7 @@ EOF
}
sub _update_null_last_seen_paths_if_any ($self) {
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
$dbh->do( <<'EOF', undef );
UPDATE paths
@ -53,7 +53,7 @@ EOF
sub _register_request_query ( $self, $remote_address, $user_agent,
$params_json, $path, $referer )
{
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
$dbh->do(
<<'EOF', undef, $remote_address, $user_agent, $params_json, $path, $referer );
INSERT INTO requests(remote_address, user_agent, params, path, referer)
@ -65,7 +65,7 @@ sub register_request {
my $self = shift;
my $c = shift;
my $path = $c->req->url->path;
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
$self->_add_path($path);
$self->_update_null_last_seen_paths_if_any();
my $remote_address = $c->tx->remote_address;
@ -82,7 +82,7 @@ sub get_global_data {
my $self = shift;
my $c = shift;
my $app = $c->app;
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
my $data = $dbh->selectrow_hashref( <<"EOF", undef );
SELECT
(
@ -112,7 +112,7 @@ sub get_google_data {
my $self = shift;
my $c = shift;
my $app = $c->app;
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
my $data = $dbh->selectall_arrayref(<<"EOF", { Slice => {} } );
SELECT paths.path,
(
@ -150,7 +150,7 @@ sub get_data_for_urls {
my $self = shift;
my $c = shift;
my $app = $c->app;
my $dbh = BurguillosInfo::DB->connect($app);
my $dbh = OwlcodeTech::DB->connect($app);
my $data = $dbh->selectall_arrayref( <<"EOF", { Slice => {} } );
SELECT paths.path,
(

View File

@ -4,6 +4,6 @@
"db": {
"database": "example"
},
"base_url": "https://burguillos.info",
"listen": "https:localhost:3555"
"base_url": "https://owlcode.tech",
"listen": "https://localhost:3000"
}

View File

@ -219,6 +219,7 @@ body {
body div.page-contents nav.mobile-foldable, body div.page-contents nav.mobile-foldable.show {
display: none; }
body div.page-contents div.description {
margin-top: auto;
margin-left: 10%;
margin-right: 10%; }
body div.page-contents nav.desktop {

View File

@ -357,6 +357,7 @@ body {
}
div.description {
margin-top: auto;
margin-left: 10%;
margin-right: 10%;
}

View File

@ -8,4 +8,4 @@ use lib curfile->dirname->sibling('lib')->to_string;
use Mojolicious::Commands;
# Start command line interface for application
Mojolicious::Commands->start_app('BurguillosInfo');
Mojolicious::Commands->start_app('OwlcodeTech');

View File

@ -1,6 +1,6 @@
% use Mojo::Util;
% use BurguillosInfo::Categories;
% layout 'default', current_category_slug => undef, categories => BurguillosInfo::Categories->new->Retrieve;
% use OwlcodeTech::Categories;
% layout 'default', current_category_slug => undef, categories => OwlcodeTech::Categories->new->Retrieve;
<div class="description">
<h2>Esta página no existe.</h2>
<p>Si un enlace te ha llevado aquí, reporta el error a <a href="mailto:contact@owlcode.tech">los administradores</a>.</p>

View File

@ -1 +0,0 @@
404.html.ep

View File

@ -0,0 +1,7 @@
% use Mojo::Util;
% use OwlcodeTech::Categories;
% layout 'default', current_category_slug => undef, categories => OwlcodeTech::Categories->new->Retrieve;
<div class="description">
<h2>Esta página no existe.</h2>
<p>Si un enlace te ha llevado aquí, reporta el error a <a href="mailto:contact@owlcode.tech">los administradores</a>.</p>
</div>

View File

@ -4,7 +4,7 @@
% use Mojo::DOM;
% use Mojo::Util;
%
% use BurguillosInfo::Posts;
% use OwlcodeTech::Posts;
%
% my $category = stash 'category';
% my $attribute = stash 'attribute';

View File

@ -5,7 +5,7 @@
% use Mojo::DOM;
% use Mojo::Util;
%
% use BurguillosInfo::Posts;
% use OwlcodeTech::Posts;
%
% my $description_og = '<div>'.$current_category->{description}.'</div>';
% $description_og = Mojo::DOM->new($description_og)->all_text;
@ -26,7 +26,7 @@
<p><a href="<%="/$current_category->{slug}/atributo/$attribute->{identifier}"%>"><%==$attribute->{menu_text}%></a></p>
% }
% }
% my ($category_posts) = BurguillosInfo::Posts->new->RetrieveAllPostsForCategory($current_category->{slug});
% my ($category_posts) = OwlcodeTech::Posts->new->RetrieveAllPostsForCategory($current_category->{slug});
%= include 'page/_list_posts', posts => $category_posts;
<h2>Suscribete a esta categoría.</h2>

View File

@ -3,9 +3,9 @@
% use Mojo::DOM;
% use Mojo::Util;
%
% use BurguillosInfo::Posts;
% use BurguillosInfo::Categories;
% my $categories = BurguillosInfo::Categories->new->Retrieve;
% use OwlcodeTech::Posts;
% use OwlcodeTech::Categories;
% my $categories = OwlcodeTech::Categories->new->Retrieve;
% my $description_og = '<div>'.$post->{content}.'</div>';
% $description_og = Mojo::DOM->new($description_og)->all_text;
% my $base_url = config 'base_url';