Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed buildsite to generate CD pages too.

  • Loading branch information...
commit 643e57c9190bc5dc807da47f96ec0d25c59fa4bb 1 parent ee0f509
@davorg authored
Showing with 28 additions and 13 deletions.
  1. +21 −5 buildsite
  2. +5 −5 grillcd.tt
  3. +2 −3 index.tt
View
26 buildsite
@@ -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;
View
10 grillcd.tt
@@ -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>
@@ -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>
View
5 index.tt
@@ -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 -%]
Please sign in to comment.
Something went wrong with that request. Please try again.