Skip to content

Commit

Permalink
trurl: render download link and info for trurl
Browse files Browse the repository at this point in the history
We generate tarballs for trurl releases starting in 0.15

Closes #390
  • Loading branch information
bagder committed Aug 28, 2024
1 parent ee2fd74 commit b46d559
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 1 deletion.
5 changes: 4 additions & 1 deletion trurl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ trurl.gen: trurl-www/trurl.md
manual.html: _manual.html $(MAINPARTS) trurl.gen
$(ACTION)

index.html: _index.html $(MAINPARTS)
index.html: _index.html files.gen mkfiles.pl $(MAINPARTS)
$(ACTION)

files.gen: mkfiles.pl dl/*
./mkfiles.pl >$@

clean:
rm -f $(PAGES)
22 changes: 22 additions & 0 deletions trurl/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<html>
<head> <title>trurl</title>
#include "css.t"
<style type="text/css">
a.trurldl {
font-size: 200%;
}
</style>
</head>

#define DEVEL_INDEX
Expand All @@ -10,6 +15,8 @@
#include "_menu.html"
#include "setup.t"

#include "files.gen"

WHERE1(trurl)

TITLE(trurl)
Expand Down Expand Up @@ -38,6 +45,21 @@
parser</a> and will thus parse and understand URLs exactly the same as curl
the command line tool does – making it the perfect companion tool.

SUBTITLE(Download)
<p>
<div style="border: 1px solid black; padding: 8px 8px 8px 8px;">
<a href="TRURL_FILENAME"><img src="/pix/GS-Download-icon.svg" alt="download trurl TRURL_VER" width="90" height="120" style="float:left;"></a>
<a href="TRURL_FILENAME" class="trurldl">trurl TRURL_VER</a> <br>
<a href="TRURL_SIG"><b>GPG signature</b></a> | <a href="https://github.com/curl/trurl/releases/tag/TRURL_VER_LINK"><b>Release notes</b></a>
#ifdef TRURL_VIDEO
| <a href="TRURL_VIDEO"><b>Release video</b></a>
#endif
<br>
<b>Size</b>: TRURL_SIZE <br>
<b>sha256</b>: TRURL_SHA256 <br>
</div>

<p>
SUBTITLE(Pronunciation)
<p>
We say "trurel". As if there was an 'e' between the 'r' and 'l' at the end.
Expand Down
3 changes: 3 additions & 0 deletions trurl/dl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# trurl download directory

Store tarballs and signatures here.
105 changes: 105 additions & 0 deletions trurl/mkfiles.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/perl

#use Time::localtime;
use POSIX qw(strftime);

my $url="/trurl/";

sub getdl {
my ($dir)=@_; # where the download files are
opendir(DIR, $dir) || return "";
my @files = readdir(DIR);
closedir DIR;
return @files;
}

sub filetime {
my ($filename)=@_;

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);

return $mtime;
}

sub filesize {
my ($filename)=@_;

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);

return $size;
}

sub checksum {
my ($f) = @_;
my @o = `sha256sum $f 2>/dev/null`;
my $sh = $o[0];
$sh =~ s/([^ ]*).*/$1/;
chomp $sh;
return $sh;
}


my $dl = "dl";
my @files = getdl($dl);

for(@files) {
my $file = $_;
if($file =~ /^trurl-([0-9.-]+)\.(tar\.gz)$/) {
my ($version, $ext)=($1, $2);
$file{$version}=$file;
my $fsize = filesize("$dl/$file");
$size{$version}=sprintf("%.1f KB", $fsize/1024);

my $when = filetime("$dl/$file");
my $d = strftime "%Y-%m-%d", gmtime($when);
$date{$version}=$d;
$versions{$version}++;
if(-e "$dl/$file.asc") {
# a GPG signature
$gpg{$version}="$dl/$file.asc";
}
}
}

sub num {
my ($t)=@_;
return $t;
}

my %video = (
'0.15' => 'https://youtu.be/ETxhkW2SsfU',
);

my $gen=0;
for my $version (reverse sort { num($a) <=> num($b) } keys %versions) {
my $build = 1;
my $officialver = $version;
if($officialver =~ s/-(\d)\z//g) {
$build = $1;
}
my $link = $officialver;
print "#define TRURL_VER $officialver\n";
print "#define TRURL_VER_LINK trurl-$officialver\n\n";

printf("#define TRURL_FILENAME dl/%s\n", $file{$version});
printf("#define TRURL_SIZE %s\n", $size{$version});
printf("#define TRURL_DATE %s\n", $date{$version});

if($gpg{$version}) {
printf("#define TRURL_SIG %s\n", $gpg{$version});
}

my $sha = checksum("$dl/$file{$version}");
printf("#define TRURL_SHA256 %s\n", $sha);

if($video{$officialver}) {
printf("#define TRURL_VIDEO %s\n", $video{$officialver});
}

last;
}

0 comments on commit b46d559

Please sign in to comment.