Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

start to generate web pages

  • Loading branch information...
commit 07826f7328373b9b2ed862f54b19f42a8c624958 1 parent 41b3b5e
Moritz Lenz moritz authored
9 README
... ... @@ -1 +1,8 @@
1   -Collection of Perl 6 FAQs, and a few answers.
  1 +Collection of Perl 6 FAQs, and a few answers. Source of http://faq.perl6.org/.
  2 +
  3 +To generate the web page(s), run
  4 +
  5 + perl generate-web.pl path/to/output/directory
  6 +
  7 +Requires Perl 5, Text::Markdown and HTML::Template::Compiled.
  8 +
34 generate-web.pl
... ... @@ -0,0 +1,34 @@
  1 +use strict;
  2 +use warnings;
  3 +use Text::Markdown qw/markdown/;
  4 +use HTML::Template::Compiled;
  5 +use File::Copy qw/copy/;
  6 +
  7 +my $dest_dir = shift @ARGV
  8 + or die "Usage: $0 <destination-dir>";
  9 +
  10 +my $t = HTML::Template::Compiled->new(
  11 + filename => 'web/index.tmpl',
  12 + open_mode => ':encoding(UTF-8)',
  13 + default_escape => 'HTML',
  14 + global_vars => 1,
  15 +);
  16 +
  17 +open my $fh, '<', 'answers.md'
  18 + or die "Cannot open 'answers.md' for reading: $!";
  19 +my $contents = do { local $/; <$fh> };
  20 +close $fh;
  21 +
  22 +$t->param(body => scalar(markdown($contents)));
  23 +$t->param(last_updated => scalar(localtime +(stat 'answers.md')[9]));
  24 +
  25 +my $fn = "$dest_dir/index.html";
  26 +open my $out, '>:encoding(UTF-8)', $fn
  27 + or die "Cannot open '$fn' for writing: $!";
  28 +print { $out } $t->output;
  29 +close $out;
  30 +
  31 +for (glob 'web/*') {
  32 + next if /\.tmpl$/;
  33 + copy $_, $dest_dir;
  34 +}
17 web/index.tmpl
... ... @@ -0,0 +1,17 @@
  1 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3 +
  4 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5 +<head>
  6 + <title>Perl 6 Frequently Asked Questions (FAQ)</title>
  7 + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  8 + <link rel="stylesheet" type="text/css" href="/style.css" />
  9 + <link rel="shortcut icon" href="http://perl6.org/favicon.ico" />
  10 +</head>
  11 +<body>
  12 + <%var body escape=none%>
  13 +
  14 + <div id="footer">Last updated on <%var last_updated%></div>
  15 +</body>
  16 +</html>
  17 +
1  web/style.css
... ... @@ -0,0 +1 @@
  1 +/* your cool style here */

0 comments on commit 07826f7

Please sign in to comment.
Something went wrong with that request. Please try again.