DragonFly docs List (threaded) for 2007-04
DragonFly BSD
DragonFly docs List (threaded) for 2007-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

handbook now on wiki


From: "Justin C. Sherrill" <justin@xxxxxxxxxxxxxxxxxx>
Date: Sun, 22 Apr 2007 22:02:21 -0400 (EDT)

I converted the whole handbook over to the wiki:

http://wiki.dragonflybsd.org/index.cgi/DragonFlyBSD_Handbook

There's some typos and conversion errors, of course, but it's been tweaked
enough that it's remarkably similar to the original document.  Most of the
odd things come from the MoinMoin wiki software not allowing markup within
section headers or code, and the like.

Anyway: hooray, no more SGML!  Please mangle as you see fit.

For posterity, here's the Perl script I put together for it:

#!/usr/pkg/bin/perl

use WWW::CheckSite::Spider;
use Wiki::Gateway;
use HTML::WikiConverter;
use LWP;
use File::Basename;

# use checksite to grab all pages in handbook
# use converter to change
# apply to pages in wiki

$wikitype = "moinmoin1";

my $wc = new HTML::WikiConverter(
    dialect => 'MoinMoin',
    wiki_uri => 'http://leaf.dragonflybsd.org/~justin/handbook/'
);

my $sp = WWW::CheckSite::Spider->new(
         #uri      => 'http://leaf.dragonflybsd.org/~justin/handbook/',
         uri      =>
'http://leaf.dragonflybsd.org/~justin/handbook/basics.html',
         #uri      =>
'http://leaf.dragonflybsd.org/~justin/new-bsdusers/article.html',
);

while ( my $page = $sp->get_page )
{
    # go through pages on site
    print "$page->{title} $page->{ret_uri}\n";
    # get actual page url
    my $path = $page->{ret_uri};

    # go get the page and convert
    my $page_text = $wc->html2wiki( uri => $path );

    # find name of end file
    my($filename, $directories, $suffix) = fileparse($path);

    if ($filename eq "article.html")
    {
        $filename = $page->{title};
    }

    print "result: $result\n";

    # takes care of table links on each handbook page
    $page_text =~ s/\[([\w\.\-]+)\ Prev]/\[:$1:Prev\]/sg;
    $page_text =~ s/ \[([\w\.\-]+)\ Next]/\<\)\> \[:$1:Next\]/sg;
    $page_text =~ s/\[([\w\.]+)\ Home]/\[:$1:Home\]/sg;
    $page_text =~ s/\[([\w\.\-]+)\ Up]/\[:$1:Up\]/sg;

    # fix the mini-table of contents found at the start of chapters,
    # as the wikiconverter tries to treat these as terms and definitions.
    $page_text =~ s/(\d+\.\d+) \[([\w\.\-\#]*?) +(.*?)\]::/$1
[:$2:$3]\n\n/sg;
    $page_text =~ s/'''Table of Contents'''::/'''Table of Contents'''\n\n/sg;

    # footnotes/anchors
    $page_text =~ s/\[([\w\.]+#[\w\.\-]+)/\[:$1:/sg;
    $page_text =~ s/\[(\d)\]\]/\($1\)]/sg;
    $page_text =~ s/Up\] \|\| (.*?) \|\|/Up] ||<)> $1 ||/sg;

    # center the header text
    $page_text =~ s/(\> DragonFly Handbook \|\|)/ : $1/sg;
    $page_text =~ s/\|\|( Chapter)/\|\|<:>$1/sg;

    # mark it english
    $page_text = "#language en\n$page_text";

    # stupid CamelCase, which I hate with the intensity of
    # a thousand burning suns
    $page_text =~ s/DragonFly/Dragon``Fly/sg;
    $page_text =~ s/McKusick/Mc``Kusick/sg;

    #print "$page_text";

    # post page to wiki
    $result =
Wiki::Gateway::putPage('http://wiki.dragonflybsd.org/index.cgi/',
$wikitype, "$filename", $page_text);

}




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]