1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-22 05:08:58 +02:00

Make analytics optional for HTML documentation.

Analytics should only be added to the current HTML documentation on the website, so exclude them by default.
This commit is contained in:
David Steele 2021-10-29 11:45:50 -04:00
parent 1336657326
commit 6abb06248c
4 changed files with 27 additions and 8 deletions

View File

@ -225,7 +225,16 @@ sub htmlGet
my $self = shift;
# Assign function parameters, defaults, and log debug info
my ($strOperation) = logDebugParam(__PACKAGE__ . '->htmlGet');
my
(
$strOperation,
$bAnalytics,
) =
logDebugParam
(
__PACKAGE__ . '->htmlGet', \@_,
{name => 'bAnalytics', optional => true, default => false, trace => true},
);
# Build the header
my $strHtml =
@ -286,10 +295,13 @@ sub htmlGet
$self->indent(1) . "<link rel=\"stylesheet\" href=\"default.css\" type=\"text/css\"></link>\n";
}
$strHtml .=
$self->indent(1) . "<script async src=\"https://www.googletagmanager.com/gtag/js?id=G-VKCRNV73H1\"></script>\n" .
$self->indent(1) . "<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}" .
"gtag('js',new Date());gtag('config','G-VKCRNV73H1');</script>\n";
if ($bAnalytics)
{
$strHtml .=
$self->indent(1) . "<script async src=\"https://www.googletagmanager.com/gtag/js?id=G-VKCRNV73H1\"></script>\n" .
$self->indent(1) . "<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}" .
"gtag('js',new Date());gtag('config','G-VKCRNV73H1');</script>\n";
}
$strHtml .=
$self->indent(0) . "</head>" . $self->lf() .

View File

@ -186,7 +186,11 @@ sub process
return logDebugReturn
(
$strOperation,
{name => 'strHtml', value => $oHtmlBuilder->htmlGet(), trace => true}
{name => 'strHtml',
value => $oHtmlBuilder->htmlGet(
{bAnalytics => defined($self->{oManifest}->variableGet('analytics')) &&
$self->{oManifest}->variableGet('analytics') eq 'y'}),
trace => true}
);
}

View File

@ -23,6 +23,9 @@
<variable key="dev">n</variable>
<variable key="debug">n</variable>
<!-- Add analytics to the HTML documentation? -->
<variable key="analytics">n</variable>
<!-- Release date - static allows for reproducible builds -->
<variable key="release-date-static">n</variable>
<variable key="release-date" eval="y">

View File

@ -297,9 +297,9 @@ eval
{
&log(INFO, "Generate website documentation");
executeTest("${strDocExe} --deploy --cache-only --key-var=os-type=rhel --out=html");
executeTest("${strDocExe} --var=analytics=y --deploy --cache-only --key-var=os-type=rhel --out=html");
$oStorageDoc->move("$strDocHtml/user-guide.html", "$strDocHtml/user-guide-rhel.html");
executeTest("${strDocExe} --deploy --out-preserve --cache-only --out=html");
executeTest("${strDocExe} --var=analytics=y --deploy --out-preserve --cache-only --out=html");
# Deploy to repository
&log(INFO, '...Deploy to repository');