Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 20. apríl 2024

Súbor: [Platon] / iotta / Iotta / Input / NavGen.pm (stiahnutie)

Revízia 1.2, Fri Mar 14 14:21:27 2003 UTC (21 years, 1 month ago) by yenar


Zmeny od 1.1: +37 -8 [lines]

make index generator recursive [NavGen.pm]

package Iotta::Input::NavGen;
use strict;
require Iotta::Elem;
our @ISA = ("Iotta::Elem");

sub trim {
    my $i = shift;
    $i =~ s/^[ \t\n]+//;
    $i =~ s/[ \t\n]+$//;
    return $i;
}

sub run {
    my $self = shift;
    my $m = shift;
    my $d = shift;
    $self->next->run ($m, $d) if ($self->next);
    push @{$self->files}, $m;
    return 0;
}

sub setup {
    my $s = shift;
    my $o = shift;
    #$s->chain->mod_creat ("test");
    $s->categ ($s->chain->mod_creat ($$o{categorizer}));
}

sub mkindex {
    my $s = shift;
    my $a = shift;
    my $d = "";
    print "creating index: $$a{input}\n";
    for my $sub (@{$$a{subs}}) {
        print "creating subindex: $$sub{input}\n";
        &mkindex ($s, $sub);
        print "end creating subindex: $$sub{input}\n";
        $d .= "L ".$$sub{input}.".html\n"; ## FIXME!!
        $d .= "T ".$$sub{title}."\n\n";
    }
    for (@{$$a{files}}) {
        $d .= "L ".$$_{relname}."\n";
        $d .= "T ".$$_{title}."\n\n";
    }
    $$a{format} = "index";
    $$a{top} = '.';
    $s->next->run ($a, $d) if ($s->next);
}

sub finish {
    my $s = shift;
    # build index list using categorizer
    my $indexes = $s->categ->sort ($s->files);
    # format the indexes into text files and process these
    for my $a (@$indexes) {
#        my $d;
        &mkindex ($s, $a);
#        for (@{$$a{subs}}) {
#            print "creating subindex: $$_{input}\n";
#            #$s->mkindex ($_);
#            print "end creating subindex: $$_{input}\n";
#            $d .= "L ".$$_{input}.".html\n"; ## FIXME!!
#            $d .= "T ".$$_{title}."\n\n";
#        }
#        for (@{$$a{files}}) {
#            $d .= "L ".$$_{relname}."\n";
#            $d .= "T ".$$_{title}."\n\n";
#        }
#        $$a{format} = "index";
#        $$a{top} = '.';
#        $s->next->run ($a, $d) if ($s->next);
    }
    my %sidx;
    my $d;
    for (@$indexes) {
        $d .= "L ".$$_{relname}."\n";
        $d .= "T ".$$_{title}."\n\n";
    }
    $sidx{format} = "index";
    $sidx{input} = "categories";
    $sidx{title} = "category index";
    $sidx{top} = '.';
    $s->next->run (\%sidx, $d) if ($s->next);
}

sub initialize {
    my $self = shift;
    my @files;
    $self->SUPER::initialize (@_);
    $self->{files} = \@files;
    $self->{categ} = 0;
}

1;

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok