mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-05-15 22:06:48 +02:00
* The repo-path option now always refers to the repository where backups and archive are stored, whether local or remote, so the repo-remote-path option has been removed. The new spool-path option can be used to define a location for queueing WAL segments when archiving asynchronously. Otherwise, a local repository is no longer required. * Implemented a new config format which should be far simpler to use. See the User Guide and Configuration Reference for details but for a simple configuration all options can now be placed in the stanza section. Options that are shared between stanzas can be placed in the [global] section. More complex configurations can still make use of command sections though this should be a rare use case. * The default configuration filename is now pgbackrest.conf instead of pg_backrest.conf. This was done for consistency with other naming changes but also to prevent old config files from being loaded accidentally. * The default repository name was changed from /var/lib/backup to /var/lib/pgbackrest. * Lock files are now stored in /tmp/pgbackrest by default. These days /run/pgbackrest would be the preferred location but that would require init scripts which are not part of this release. The lock-path option can be used to configure the lock directory. * Log files are now stored in /var/log/pgbackrest by default and no longer have the date appended so they can be managed with logrotate. The log-path option can be used to configure the lock directory. * Executable filename changed from pg_backrest to pgbackrest.
220 lines
7.6 KiB
Perl
220 lines
7.6 KiB
Perl
####################################################################################################################################
|
|
# DOC HTML BUILDER MODULE
|
|
####################################################################################################################################
|
|
package BackRestDoc::Html::DocHtmlBuilder;
|
|
|
|
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use Carp qw(confess);
|
|
|
|
use Exporter qw(import);
|
|
our @EXPORT = qw();
|
|
use File::Basename qw(dirname);
|
|
use File::Copy;
|
|
|
|
use lib dirname($0) . '/../lib';
|
|
use pgBackRest::Common::Log;
|
|
use pgBackRest::Common::String;
|
|
|
|
use BackRestDoc::Html::DocHtmlElement;
|
|
|
|
####################################################################################################################################
|
|
# Operation constants
|
|
####################################################################################################################################
|
|
use constant OP_DOC_HTML_BUILDER => 'DocHtmlBuilder';
|
|
|
|
use constant OP_DOC_HTML_BUILDER_NEW => OP_DOC_HTML_BUILDER . '->new';
|
|
use constant OP_DOC_HTML_BUILDER_HTML_GET => OP_DOC_HTML_BUILDER . '->htmlGet';
|
|
use constant OP_DOC_HTML_BUILDER_HTML_RENDER => OP_DOC_HTML_BUILDER . '->htmlRender';
|
|
|
|
####################################################################################################################################
|
|
# CONSTRUCTOR
|
|
####################################################################################################################################
|
|
sub new
|
|
{
|
|
my $class = shift; # Class name
|
|
|
|
# Create the class hash
|
|
my $self = {};
|
|
bless $self, $class;
|
|
|
|
$self->{strClass} = $class;
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
(
|
|
my $strOperation,
|
|
$self->{strName},
|
|
$self->{strTitle},
|
|
$self->{bPretty}
|
|
) =
|
|
logDebugParam
|
|
(
|
|
OP_DOC_HTML_BUILDER_NEW, \@_,
|
|
{name => 'strName'},
|
|
{name => 'strTitle'},
|
|
{name => 'bPretty', default => false}
|
|
);
|
|
|
|
$self->{oBody} = new BackRestDoc::Html::DocHtmlElement(HTML_BODY);
|
|
|
|
# Return from function and log return values if any
|
|
return logDebugReturn
|
|
(
|
|
$strOperation,
|
|
{name => 'self', value => $self}
|
|
);
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# indent
|
|
#
|
|
# Indent html
|
|
####################################################################################################################################
|
|
sub indent
|
|
{
|
|
my $self = shift;
|
|
my $iDepth = shift;
|
|
|
|
return $self->{bPretty} ? (' ' x $iDepth) : '';
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# lf
|
|
#
|
|
# Add a linefeed.
|
|
####################################################################################################################################
|
|
sub lf
|
|
{
|
|
my $self = shift;
|
|
|
|
return $self->{bPretty} ? "\n" : '';
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# bodyGet
|
|
#
|
|
# Get the body element.
|
|
####################################################################################################################################
|
|
sub bodyGet
|
|
{
|
|
my $self = shift;
|
|
|
|
return $self->{oBody};
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# htmlRender
|
|
#
|
|
# Render each html element.
|
|
####################################################################################################################################
|
|
sub htmlRender
|
|
{
|
|
my $self = shift;
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
my (
|
|
$strOperation,
|
|
$oElement,
|
|
$iDepth
|
|
) =
|
|
logDebugParam
|
|
(
|
|
OP_DOC_HTML_BUILDER_HTML_RENDER, \@_,
|
|
{name => 'oElement', trace => true},
|
|
{name => 'iDepth', trace => true}
|
|
);
|
|
|
|
# Build the header
|
|
my $strHtml =
|
|
$self->indent($iDepth) . "<$oElement->{strType}" .
|
|
(defined($oElement->{strClass}) ? " class=\"$oElement->{strClass}\"": '') .
|
|
(defined($oElement->{strRef}) ? " href=\"$oElement->{strRef}\"": '') .
|
|
(defined($oElement->{strId}) ? " id=\"$oElement->{strId}\"": '') . '>';
|
|
|
|
if (defined($oElement->{strContent}))
|
|
{
|
|
if (!defined($oElement->{bPre}) || !$oElement->{bPre})
|
|
{
|
|
$oElement->{strContent} =~ s/\n/\<br\/>\n/g;
|
|
$oElement->{strContent} = trim($oElement->{strContent});
|
|
$strHtml .= $self->lf();
|
|
}
|
|
|
|
$strHtml .= $oElement->{strContent};
|
|
|
|
if (!defined($oElement->{bPre}) || !$oElement->{bPre})
|
|
{
|
|
$strHtml .= $self->lf() . $self->indent($iDepth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!($oElement->{strType} eq HTML_A && @{$oElement->{oyElement}} == 0))
|
|
{
|
|
$strHtml .= $self->lf();
|
|
}
|
|
|
|
foreach my $oChildElement (@{$oElement->{oyElement}})
|
|
{
|
|
$strHtml .= $self->htmlRender($oChildElement, $iDepth + 1);
|
|
}
|
|
|
|
if (!($oElement->{strType} eq HTML_A && @{$oElement->{oyElement}} == 0))
|
|
{
|
|
$strHtml .= $self->indent($iDepth);
|
|
}
|
|
}
|
|
|
|
$strHtml .= "</$oElement->{strType}>" . $self->lf();
|
|
|
|
# Return from function and log return values if any
|
|
return logDebugReturn
|
|
(
|
|
$strOperation,
|
|
{name => 'strHtml', value => $strHtml, trace => true}
|
|
);
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# htmlGet
|
|
#
|
|
# Generate the HTML.
|
|
####################################################################################################################################
|
|
sub htmlGet
|
|
{
|
|
my $self = shift;
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
my ($strOperation) = logDebugParam(OP_DOC_HTML_BUILDER_HTML_GET);
|
|
|
|
# Build the header
|
|
my $strHtml =
|
|
$self->indent(0) . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" .
|
|
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" . $self->lf() .
|
|
$self->indent(0) . "<html xmlns=\"http://www.w3.org/1999/xhtml\">" . $self->lf() .
|
|
$self->indent(0) . "<head>" . $self->lf() .
|
|
$self->indent(1) . "<title>$self->{strTitle}</title>" . $self->lf() .
|
|
$self->indent(1) . "<link rel=\"stylesheet\" href=\"default.css\" type=\"text/css\"></link>" . $self->lf() .
|
|
# $self->indent(1) . "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></meta>" . $self->lf() .
|
|
$self->indent(1) . "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"></meta>" . $self->lf() .
|
|
$self->indent(1) . "<meta name=\"og:site_name\" content=\"$self->{strName}\"></meta>" . $self->lf() .
|
|
$self->indent(1) . "<meta name=\"og:title\" content=\"$self->{strTitle}\"></meta>" . $self->lf() .
|
|
$self->indent(1) . "<meta name=\"og:image\" content=\"favicon.png\"></meta>" . $self->lf() .
|
|
$self->indent(0) . "</head>" . $self->lf();
|
|
|
|
$strHtml .= $self->htmlRender($self->bodyGet(), 0);
|
|
|
|
# Complete the html
|
|
$strHtml .=
|
|
$self->indent(0) . "</html>" . $self->lf();
|
|
|
|
# Return from function and log return values if any
|
|
return logDebugReturn
|
|
(
|
|
$strOperation,
|
|
{name => 'strHtml', value => $strHtml, trace => true}
|
|
);
|
|
}
|
|
|
|
1;
|