Pretty printing sitemap.xml
This commit is contained in:
parent
d195e26842
commit
423e813490
1
Build.PL
1
Build.PL
@ -18,6 +18,7 @@ my $build = Module::Build->new(
|
||||
'DateTime::Format::ISO8601.pm' => 0,
|
||||
'DateTime::Format::Mail.pm' => 0,
|
||||
'SVG' => 0,
|
||||
'XML::LibXML::PrettyPrint' => 0,
|
||||
},
|
||||
);
|
||||
$build->create_build_script;
|
||||
|
@ -10,6 +10,9 @@ use BurguillosInfo::Posts;
|
||||
|
||||
use DateTime::Format::ISO8601;
|
||||
|
||||
use XML::LibXML;
|
||||
use XML::LibXML::PrettyPrint;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Controller', '-signatures';
|
||||
|
||||
sub sitemap ($self) {
|
||||
@ -23,7 +26,12 @@ sub sitemap ($self) {
|
||||
for my $category_key ( keys %$categories ) {
|
||||
$self->_append_category_dom( $dom, $category_key, $categories );
|
||||
}
|
||||
$self->render(text => $dom, format => 'xml');
|
||||
my $xml_string = "$dom";
|
||||
my $document = XML::LibXML->load_xml(string => $xml_string);
|
||||
my $pretty_print = XML::LibXML::PrettyPrint->new(indent_string => (" " x 4));
|
||||
$pretty_print->pretty_print($document);
|
||||
$xml_string = $document->toString();
|
||||
$self->render(text => $xml_string, format => 'xml');
|
||||
}
|
||||
|
||||
sub _append_category_dom ( $self, $dom, $category_key, $categories ) {
|
||||
|
Loading…
Reference in New Issue
Block a user