Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] Use Template::Semantic to isolate logic #2436

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ my $build = Module::Build->new(
dist_author => 'Divinum Officium',
dist_abstract => 'Generates texts for the traditional Roman liturgy.',
requires => {
'perl' => '5.10.1',
'CGI' => 0,
'CGI::Carp' => 0,
'CGI::Cookie' => 0,
'Encode' => 0,
'File::Basename' => 0,
'FindBin' => 0,
'Time::Local' => 0,
'Test::Cmd' => 0,
'Test::Carp' => 0,
'DateTime' => 0,
'List::MoreUtils' => 0,
'perl' => '5.10.1',
'CGI' => 0,
'CGI::Carp' => 0,
'CGI::Cookie' => 0,
'Encode' => 0,
'File::Basename' => 0,
'FindBin' => 0,
'Time::Local' => 0,
'Test::Cmd' => 0,
'Test::Carp' => 0,
'DateTime' => 0,
'List::MoreUtils' => 0,
'Template::Semantic' => 0,
},
);

Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM perl:5.28-slim
FROM perl:5.28
MAINTAINER Ben Yanke <[email protected]>

# Set envs
Expand Down Expand Up @@ -32,6 +32,10 @@ RUN mkdir -p /var/run/apache2 /var/lock/apache2 /var/log/apache2 ; chown -R www-
WORKDIR /var/www
COPY --chown=www-data:www-data web /var/www/web

# Update dependencies
COPY --chown=www-data:www-data Build.PL /var/www/Build.PL
RUN cpanm .

# Write build info to be available at $url/buildinfo
RUN echo "Build date: `date`" > /var/www/web/buildinfo

Expand Down
4 changes: 2 additions & 2 deletions web/cgi-bin/horas/horascommon.pl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ sub getrank {
if (-e "$datafolder/Latin/$tn.txt" || $dayname[0] =~ /Epi0/i || ($transfer{$nday}) =~ /tempora/i) {
$dofw = $dayofweek;

if ($hora =~ /(vespera|completorium)/i && $testmode !~ /(Saint|Common)/i) {
if ($hora =~ /(Vespera|Completorium)/i && $testmode !~ /(Saint|Common)/i) {
my $a = getweek(1);
my @a = split('=', $a);
$dn[0] = $a[0];
Expand Down Expand Up @@ -427,7 +427,7 @@ sub getrank {
if (exists($transfer{$cday}) && $transfer{$cday} !~ /Tempora/i) { $cday = $transfer{$cday}; }
if ($tname =~ /Nat/ && $cday =~ /Nat/) { $cday = 'none'; }

if ($hora =~ /(vespera|completorium)/i) {
if ($hora =~ /(Vespera|Completorium)/i) {
if ($cday !~ /(tempora|DU)/i) { $cday = "$kalendar{$cday}"; }
my $cdayd = $cday;
if (!$cdayd || $cdayd !~ /([0-9]+\-[0-9]+)/) { $cdayd = nextday($month, $day, $year); }
Expand Down
2 changes: 1 addition & 1 deletion web/cgi-bin/horas/officium.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
use utf8;

# Name : Laszlo Kiss
Expand Down
27 changes: 4 additions & 23 deletions web/cgi-bin/horas/webdia.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#use warnings;
#use strict "refs";
#use strict "subs";

use Template::Semantic;

my $a = 4;

#*** htmlHead($title, $flag)
Expand All @@ -16,30 +19,8 @@ sub htmlHead {
my $flag = shift;
if (!$title) { $title = ' '; }

# print "Content-type: text/html; charset=ISO-8859-1\n\n";
print "Content-type: text/html; charset=utf-8\n\n";
print << "PrintTag";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD>
<META NAME="Resource-type" CONTENT="Document">
<META NAME="description" CONTENT="Divine Office">
<META NAME="keywords" CONTENT="Divine Office, Breviarium, Liturgy, Traditional, Zsolozsma">
<META NAME="Copyright" CONTENT="Like GNU">
<STYLE>
/* https://www.30secondsofcode.org/css/s/offscreen/ */
.offscreen {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
</STYLE>
<TITLE>$title</TITLE>
PrintTag
print Template::Semantic->process("../../template/home.html", { 'TITLE' => $title });
if ($flag == 2) { horasjs(); }
print "</HEAD>";
}
Expand Down
20 changes: 20 additions & 0 deletions web/template/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD>
<META NAME="Resource-type" CONTENT="Document">
<META NAME="description" CONTENT="Divine Office">
<META NAME="keywords" CONTENT="Divine Office, Breviarium, Liturgy, Traditional, Zsolozsma">
<META NAME="Copyright" CONTENT="Like GNU">
<STYLE>
/* https://www.30secondsofcode.org/css/s/offscreen/ */
.offscreen {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
</STYLE>
<TITLE>Divinum Officium</TITLE>