i don't know if this will do what you want, i hacked together a quick and dirty script...
Generate static pages "at will" (e.g., via cron job, or just when I run the command).
set $offline to 1 in the script, then it will generate the runmode html file with every click on your local webserver.
the only requirement is that you don't have the links in the templates but give them to the template module as objects $foo = "rm=foo";bless(\$foo, "Static::Link");
you might add a spider script that automatically calls every runmode like that.
the script probably runs also with HTML::Template if you adjust the tmpl_vars.
package Static::Link; use strict; use warnings; use vars '$type'; $type = 'cgi'; # default use overload '""' => sub { $_[0]->$type }; # '/cgi-bin/static.pl' => # http://server.example/cgi-bin/static.pl?rm=foo my $script = "/cgi-bin/static.cgi"; # 'html/' => # http://server.example/html/rm_foo.html my $htdocs = ""; sub cgi { "$script?".${$_[0]} } sub offline { my $link = ${$_[0]}; $link =~ tr/=/_/; # fit to your needs "$htdocs$link.html"; }
the script:
use strict; use warnings; use CGI; use HTML::Template::Compiled 0.43; my $offline = 1; # set to 1 if on development server my $q = CGI->new; print $q->header; my $dir = '/www/cgi-bin/static'; my $rm = $q->param("rm")||"foo"; my $htc = HTML::Template::Compiled->new( path => $dir, scalarref => \<<EOM, <h2>we are at runmode <tmpl_var .runmode></h2> <a href="<tmpl_var .rm.foo>">foo</a> <a href="<tmpl_var .rm.bar>">bar</a> EOM # optional # cache_dir => "$dir/cache", ); my $foo = "rm=foo"; my $bar = "rm=bar"; my %p = ( runmode => $rm, rm => { foo => bless(\$foo, "Static::Link"), bar => bless(\$bar, "Static::Link"), }, ); $htc->param(%p); print $htc->output; if ($offline) { # generate static page $Static::Link::type = 'offline'; my $link = $p{rm}->{$rm}; my $file = "$link"; open my $fh, ">./static/htdocs/$file" or die $!; print $fh $htc->output; # update: set to cgi again $Static::Link::type = 'cgi'; }

In reply to Re: Generation of dynamically-static documents by tinita
in thread Generation of dynamically-static documents by Tanktalus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.