#!/usr/bin/env perl

# Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch
# This is free software. See the file COPYING.md that came bundled
# with this file.

use strict; use warnings; use warnings FATAL => 'uninitialized';

use Cwd 'abs_path';
our ($mydir, $myname); BEGIN {
    my $location= (-l $0) ? abs_path ($0) : $0;
    $location=~ /(.*?)([^\/]+?)_?\z/s or die "?";
    ($mydir, $myname)=($1,$2);
}
use lib "$mydir/../lib";


use PXML::XHTML ':all';
use PXML::Serialize;

use utf8;


sub page {
    my ($title,$mtime,$main)= @_;
    HTML(
	HEAD(
	    TITLE($title)),
	BODY(
	    $main,
	    HR(),
	    P(
		"By ", A({href=> "http://christianjaeger.ch"},
			 "Christian Jaeger"),
		", last modified at ", gmtime($mtime)."", " (or something).")))
}

our $numbers= {
	       1=> "one",
	       2=> "two",
	       3=> "three"};

sub examplepage {
    my ($title)= @_;
    page("example page - $title",
	 @ARGV ? $ARGV[0] : time,
	 [
	  H1($title),
	  P("Garçon méchanique, \"1 < 2\" is true. ",
	    A({href=> "\"1 < 2\""},
	      "this will be 404")),
	  TABLE({border=>1},
		map {
		    TR(TD($_), TD($$numbers{$_}))
		} (1..3))])
}

open my $o, ">:utf8", "out.xhtml" or die $!;
pxml_xhtml_print examplepage ("Hello World"), $o, "en";
close $o or die $!;

