#!/usr/bin/env perl
use strict;
use warnings;
use autodie qw( :all );
use Cwd qw( abs_path );
use FindBin qw( $Bin );
use File::Slurp qw( read_file );
use Markdent::Simple::Fragment 0.22;
my $repo = abs_path("$Bin/..");
my $markdown = read_file("$repo/MaxMind-DB-spec.md");
my $mds = Markdent::Simple::Fragment->new();
my $spec_html = $mds->markdown_to_html(
dialects => 'GitHub',
markdown => $markdown,
);
my ($title) = $markdown =~ /^\#\s+(.+)\n/;
my $index_html = <<"EOF";
<!DOCTYPE html>
<html>
<head>
<title>$title</title>
<link rel="stylesheet" id="maxmind-bootstrap-css" href="//www.maxmind.com/css/maxmind.css" type="text/css" media="all" />
</head>
<body>
<div class="row-fluid">
<div class="span2"></div>
<div class="span8">
$spec_html
</div>
<div class="span2"></div>
</body>
</html>
EOF
system qw( git co gh-pages );
open my $fh, '>', "$repo/index.html";
print {$fh} $index_html;
close $fh;