Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed buildsite to generate CD pages too.
  • Loading branch information
davorg committed Mar 7, 2014
1 parent ee0f509 commit 643e57c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
26 changes: 21 additions & 5 deletions buildsite
Expand Up @@ -6,17 +6,33 @@ use 5.010;

use Template;

open my $cd_fh, '<', 'cds.txt' or die $!;
open my $cds_fh, '<', 'cds.txt' or die $!;
my $cds;

my @cols = qw[code year title];
while (<$cd_fh>) {
my $tt = Template->new;

my @cd_cols = qw[code year title];
my @track_cols = qw[num title artist];
while (<$cds_fh>) {
chomp;
my %cd;
@cd{@cols} = split /\t/;
@cd{@cd_cols} = split /\t/;
$cd{num} = (split ' ', $cd{code})[-1];
push @$cds, \%cd;

next unless -f "grillcd$cd{num}.txt";

open my $track_fh, '<', "grillcd$cd{num}.txt" or die "$!: grillcd$cd{num}.txt";
while (my $track = <$track_fh>) {
chomp $track;
my %track;
@track{@track_cols} = split /\t/, $track;
push @{$cd{tracks}}, \%track;
}

$tt->process('grillcd.tt', { cd => \%cd}, "grillcd$cd{num}.html")
or die $tt->error;
}

my $tt = Template->new;
$tt->process('index.tt', { cds => $cds }, 'index.html')
or die $tt->error;
10 changes: 5 additions & 5 deletions grillcd.tt
Expand Up @@ -4,7 +4,7 @@
<link rel="stylesheet" href="style.css" type="text/css" />
<head>
<body>
<h1>[% cd.title %]</h1>
<h1>[% cd.title | html %]</h1>

<p><a href="index.html">Return to list</p>

Expand All @@ -15,15 +15,15 @@
</tr>
<tr>
<th>Released</th>
<td>[% cd.release %]</td>
<td>[% cd.year %]</td>
</tr>
</table>
<table>
[% FOR track IN cd.tracks -%]
<tr>
<td>[% loop.count %]</td>
<td>[% track.artist %]</td>
<td>[% track.title %]</td>
<td>[% track.num %]</td>
<td>[% track.artist | html %]</td>
<td>[% track.title | html %]</td>
</tr>
[% END -%]
</table>
Expand Down
5 changes: 2 additions & 3 deletions index.tt
Expand Up @@ -10,9 +10,8 @@
<table>
[% FOREACH cd IN cds -%]
<tr>
[% IF cd.title;
code = cd.code.split(' ') -%]
<td><a href="grillcd[% code.2 %].html">[% cd.code IF cd.code %]</a></td>
[% IF cd.title -%]
<td><a href="grillcd[% cd.num %].html">[% cd.code IF cd.code %]</a></td>
[% ELSE -%]
<td>[% cd.code IF cd.code -%]</td>
[% END -%]
Expand Down

0 comments on commit 643e57c

Please sign in to comment.