Skip to content

Commit

Permalink
Use demos from the source repository
Browse files Browse the repository at this point in the history
Part of whatwg/html#30. Depends on whatwg/html#445 landing first.
  • Loading branch information
domenic committed Dec 24, 2015
1 parent 464468d commit 2e99e02
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions .pre-process-main.pl
Expand Up @@ -47,27 +47,17 @@
my $indent = $1;
my $folder = $2;
my $example = $3;
# TODO: maybe move these to the HTML source repo, and upload them to whatwg.org from there?
# Or maybe better, redirect from these URLs to new html.spec.whatwg.org URLs
my $url = "https://whatwg.org/demos/$folder$example";

my $data;
my $fh;
mkpath(dirname("$ENV{'HTML_CACHE'}/demos/$folder$example"));
if (-e "$ENV{'HTML_CACHE'}/demos/$folder$example" && "false" eq "$ENV{'DO_UPDATE'}") {
report "\r\nReading $ENV{'HTML_CACHE'}/demos/$folder$example";
open($fh, "<:encoding(UTF-8)", "$ENV{'HTML_CACHE'}/demos/$folder$example");
while (<$fh>) {
$data .= $_;
}
close $fh;
} else {
report "\r\n\nReading $url\n";
$data = `curl \$(\$VERBOSE && echo "-v" || echo "-s") $url`;
report "\rWriting $ENV{'HTML_CACHE'}/demos/$folder$example";
open($fh, '>', "$ENV{'HTML_CACHE'}/demos/$folder$example");
print $fh $data;
close $fh;

report "\r\nReading $ENV{'HTML_SOURCE'}/demos/$folder$example";
open($fh, "<:encoding(UTF-8)", "$ENV{'HTML_SOURCE'}/demos/$folder$example");
while (<$fh>) {
$data .= $_;
}
close $fh;

$data =~ s/&/&amp;/gos;
$data =~ s/</&lt;/gos;
unshift @lines, split("\n", "$indent<pre>$data</pre>");
Expand Down

0 comments on commit 2e99e02

Please sign in to comment.