Blame Manual/repository-init.pl

708042
#!/usr/bin/perl 
d7b2cd
#
d7b2cd
# repository.init -- This file initializes Texi2HTML program to
d7b2cd
# produce the repository documentation manual using the CentOS Web
d7b2cd
# Environment XHTML and CSS standard definition.
d7b2cd
#
d7b2cd
# Copyright (C) 2009-2011 Alain Reguera Delgado
d7b2cd
# 
d7b2cd
# This program is free software; you can redistribute it and/or modify
d7b2cd
# it under the terms of the GNU General Public License as published by
d7b2cd
# the Free Software Foundation; either version 2 of the License, or
d7b2cd
# (at your option) any later version.
d7b2cd
#  
d7b2cd
# This program is distributed in the hope that it will be useful, but
d7b2cd
# WITHOUT ANY WARRANTY; without even the implied warranty of
d7b2cd
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d7b2cd
# General Public License for more details.
d7b2cd
# 
d7b2cd
# You should have received a copy of the GNU General Public License
d7b2cd
# along with this program; if not, write to the Free Software
d7b2cd
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
d7b2cd
# USA.
d7b2cd
# ----------------------------------------------------------------------
d7b2cd
# $Id$
d7b2cd
# ----------------------------------------------------------------------
d7b2cd
d7b2cd
# -iso
d7b2cd
# if set, ISO8859 characters are used for special symbols (like copyright, etc)
d7b2cd
$USE_ISO = 1;
d7b2cd
d7b2cd
# -I
d7b2cd
# add a directory to the list of directories where @include files are
d7b2cd
# searched for (besides the directory of the file). additional '-I'
d7b2cd
# args are appended to this list.  (APA: Don't implicitely search .,
d7b2cd
# to conform with the docs!) my @INCLUDE_DIRS = (".");
d7b2cd
@INCLUDE_DIRS = ("/home/centos/artwork");
d7b2cd
d7b2cd
# Extension used on output files.
d7b2cd
$EXTENSION = "xhtml";
d7b2cd
d7b2cd
# Horizontal rules.
d7b2cd
$DEFAULT_RULE = '

';
d7b2cd
$SMALL_RULE = $DEFAULT_RULE;
d7b2cd
$MIDDLE_RULE = $DEFAULT_RULE;
d7b2cd
$BIG_RULE = $DEFAULT_RULE;
d7b2cd
d7b2cd
# -split section|chapter|node|none
d7b2cd
# if $SPLIT is set to 'section' (resp. 'chapter') one html file per
d7b2cd
# section (resp. chapter) is generated. If $SPLIT is set to 'node' one
d7b2cd
# html file per node or sectionning element is generated. In all these
d7b2cd
# cases separate pages for Top, Table of content (Toc), Overview and
d7b2cd
# About are generated.  Otherwise a monolithic html file that contains
d7b2cd
# the whole document is created.
d7b2cd
$SPLIT = 'section';
d7b2cd
d7b2cd
# -sec-nav|-nosec-nav
d7b2cd
# if this is set then navigation panels are printed at the beginning
d7b2cd
# of each section.  If the document is split at nodes then navigation
d7b2cd
# panels are printed at the end if there were more than $WORDS_IN_PAGE
d7b2cd
# words on page.
d7b2cd
#
d7b2cd
# If the document is split at sections this is ignored.
d7b2cd
#
d7b2cd
# This is most useful if you do not want to have section navigation
d7b2cd
# with -split chapter. There will be chapter navigation panel at the
d7b2cd
# beginning and at the end of chapters anyway.
d7b2cd
$SECTION_NAVIGATION = 0;
d7b2cd
708042
# Layout control
708042
$print_page_head	= \&T2H_XHTML_print_page_head;
708042
$print_page_foot	= \&T2H_XHTML_print_page_foot;
708042
$print_frame        = \&T2H_XHTML_print_frame;
708042
$button_icon_img    = \&T2H_XHTML_button_icon_img;
708042
$print_navigation   = \&T2H_XHTML_print_navigation;
d7b2cd
d7b2cd
#FIXME update once it is more stabilized in texi2html.init
d7b2cd
sub T2H_XHTML_print_page_head
d7b2cd
{
d7b2cd
    my $fh = shift;
d7b2cd
    my $longtitle = "$Texi2HTML::THISDOC{'title_unformatted'}";
d7b2cd
    $longtitle .= ": $Texi2HTML::UNFORMATTED{'This'}" if exists $Texi2HTML::UNFORMATTED{'This'};
d7b2cd
    $T2H_LANG='en';
d7b2cd
    @date=localtime(time);
d7b2cd
    $year=$date[5] += 1900;
d7b2cd
    print $fh <
d7b2cd
d7b2cd
d7b2cd
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
d7b2cd
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
d7b2cd
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$T2H_LANG" lang="$T2H_LANG">
d7b2cd
<head>
d7b2cd
d7b2cd
    <title>$longtitle</title>
d7b2cd
d7b2cd
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
d7b2cd
    <meta name="description" content="$longtitle" />
d7b2cd
    <meta name="keywords" content="$longtitle" />
d7b2cd
    <meta name="resource-type" content="document" />
d7b2cd
    <meta name="distribution" content="global" />
d7b2cd
    <meta name="generator" content="$Texi2HTML::THISDOC{program}" />
d7b2cd
    <meta name="copyright" content="2009-$year Alain Reguera Delgado" />
d7b2cd
ff0a0c
    <link href="/home/centos/artwork/trunk/Manual/repository.css" rel="stylesheet" type="text/css" media="screen projection" />
d7b2cd
d7b2cd
</head>
d7b2cd
d7b2cd
<body>
d7b2cd
d7b2cd
d7b2cd
d7b2cd
d7b2cd
d7b2cd
    
d7b2cd
d7b2cd
        
d7b2cd
d7b2cd
d7b2cd
EOT
d7b2cd
}
d7b2cd
d7b2cd
sub T2H_XHTML_print_page_foot
d7b2cd
{
d7b2cd
    my $fh = shift;
d7b2cd
    print $fh <
d7b2cd
d7b2cd
            

d7b2cd
d7b2cd
        
d7b2cd
d7b2cd
    
d7b2cd
d7b2cd
    

d7b2cd
d7b2cd
d7b2cd
d7b2cd
</body>
d7b2cd
d7b2cd
</html>
d7b2cd
EOT
d7b2cd
}
d7b2cd
d7b2cd
# / in 
d7b2cd
sub T2H_XHTML_button_icon_img
d7b2cd
{
d7b2cd
    my $button = shift;
d7b2cd
    my $icon = shift;
d7b2cd
    my $name = shift;
d7b2cd
    return '' if (!defined($icon));
d7b2cd
    if (defined($name) && $name)
d7b2cd
    {
d7b2cd
        $name = ": $name";
d7b2cd
    }
d7b2cd
    else
d7b2cd
    {
d7b2cd
        $name = '';
d7b2cd
    }
d7b2cd
    $button = "" if (!defined ($button));
d7b2cd
    return qq{$button$name};
d7b2cd
}
d7b2cd
d7b2cd
$simple_map{'*'} = '
';
d7b2cd
d7b2cd
# formatting functions
d7b2cd
d7b2cd
$def_line	       = \&t2h_xhtml_def_line;
d7b2cd
$index_summary     = \&t2h_xhtml_index_summary;
d7b2cd
$image             = \&t2h_xhtml_image;
d7b2cd
d7b2cd
# need / in 
d7b2cd
sub t2h_xhtml_image($$$)
d7b2cd
{
d7b2cd
   my $file = shift;
d7b2cd
   my $base = shift;
d7b2cd
   my $preformatted = shift;
d7b2cd
   return "[ $base ]" if ($preformatted);
d7b2cd
   return "\"$base\"";
d7b2cd
}
d7b2cd
d7b2cd
# process definition commands line @deffn for example
d7b2cd
# <u> replaced by 
d7b2cd
sub t2h_xhtml_def_line($$$$$)
d7b2cd
{
d7b2cd
   my $category = shift;
d7b2cd
   my $name = shift;
d7b2cd
   my $type = shift;
d7b2cd
   my $arguments = shift;
d7b2cd
   my $index_label = shift;
d7b2cd
   $index_label = '' if (!defined($index_label));
d7b2cd
   $name = '' if (!defined($name) or ($name =~ /^\s*$/));
d7b2cd
   $type = '' if (!defined($type) or $type =~ /^\s*$/);
d7b2cd
   if (!defined($arguments) or $arguments =~ /^\s*$/)
d7b2cd
   {
d7b2cd
       $arguments = '';
d7b2cd
   }
d7b2cd
   else
d7b2cd
   {
d7b2cd
       $arguments = '' . $arguments . '';
d7b2cd
   }
d7b2cd
   my $type_name = '';
d7b2cd
   $type_name = " $type" if ($type ne '');
d7b2cd
   $type_name .= ' ' . $name . '' if ($name ne '');
d7b2cd
   $type_name .= $arguments . "\n";
d7b2cd
   if (! $DEF_TABLE)
d7b2cd
   {
d7b2cd
       return '
'. '' . $category . ':' . $type_name . $index_label . "
\n";
d7b2cd
   }
d7b2cd
   else
d7b2cd
   {
d7b2cd
       
d7b2cd
       return "\n" . $type_name . 
d7b2cd
       "\n" . $category . $index_label . "\n" . "\n";
d7b2cd
   }
d7b2cd
}
d7b2cd
d7b2cd
# There is a br which needs / 
d7b2cd
sub t2h_xhtml_index_summary($$)
d7b2cd
{
d7b2cd
    my $alpha = shift;
d7b2cd
    my $nonalpha = shift;
d7b2cd
    my $join = '';
d7b2cd
    my $nonalpha_text = '';
d7b2cd
    my $alpha_text = '';
d7b2cd
    $join = "   \n
\n" if (@$nonalpha and @$alpha);
d7b2cd
    if (@$nonalpha)
d7b2cd
    {
d7b2cd
       $nonalpha_text = join("\n   \n", @$nonalpha) . "\n";
d7b2cd
    }
d7b2cd
    if (@$alpha)
d7b2cd
    {
d7b2cd
       $alpha_text = join("\n   \n", @$alpha) . "\n   \n";
d7b2cd
    }
d7b2cd
    #I18n
d7b2cd
    return "
Jump to:   " .
d7b2cd
    $nonalpha_text . $join . $alpha_text . '';
d7b2cd
}
708042
708042
# Layout of navigation panel
708042
sub T2H_XHTML_print_navigation
708042
{
708042
    my $fh = shift;
708042
    my $buttons = shift;
708042
    my $vertical = shift;
708042
    print $fh '
708042
708042
    print $fh "" unless $vertical;
708042
    for my $button (@$buttons)
708042
    {
708042
        print $fh qq{\n} if $vertical;
708042
        print $fh qq{};
708042
708042
        if (ref($button) eq 'CODE')
708042
        {
708042
            &$button($fh, $vertical);
708042
        }
708042
        elsif (ref($button) eq 'SCALAR')
708042
        {
708042
            print $fh "$$button" if defined($$button);
708042
        }
708042
        elsif (ref($button) eq 'ARRAY')
708042
        {
708042
            my $text = $button->[1];
708042
            my $button_href = $button->[0];
708042
            if (defined($button_href) and !ref($button_href) 
708042
               and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
708042
            {             # use given text
708042
                if ($Texi2HTML::HREF{$button_href})
708042
                {
708042
                  print $fh "" .
708042
                        &$anchor('',
708042
                                    $Texi2HTML::HREF{$button_href},
708042
                                    $$text
708042
                                   ) 
708042
                                    ;
708042
                }
708042
                else
708042
                {
708042
                  print $fh $$text;
708042
                }
708042
            }
708042
        }
708042
        elsif ($button eq ' ')
708042
        {                       # handle space button
708042
            print $fh
708042
                $ICONS && $ACTIVE_ICONS{' '} ?
708042
                    &$button_icon_img($button, $ACTIVE_ICONS{' '}) :
708042
                        $NAVIGATION_TEXT{' '};
708042
            #next;
708042
        }
708042
        elsif ($Texi2HTML::HREF{$button})
708042
        {                       # button is active
708042
            my $btitle = $BUTTONS_GOTO{$button} ?
708042
                'title="' . ucfirst($BUTTONS_GOTO{$button}) . '"' : '';
708042
            if ($ICONS && $ACTIVE_ICONS{$button})
708042
            {                   # use icon
708042
                print $fh '' .
708042
                    &$anchor('',
708042
                        $Texi2HTML::HREF{$button},
708042
                        &$button_icon_img($button,
708042
                                   $ACTIVE_ICONS{$button},
708042
                                   #$Texi2HTML::NAME{$button}),
708042
                                   $Texi2HTML::NO_TEXI{$button}),
708042
                        $btitle
708042
                      );
708042
            }
708042
            else
708042
            {                   # use text
708042
                print $fh
708042
                    '[' .
708042
                        &$anchor('',
708042
                                    $Texi2HTML::HREF{$button},
708042
                                    $NAVIGATION_TEXT{$button},
708042
                                    $btitle
708042
                                   ) .
708042
                                       ']';
708042
            }
708042
        }
708042
        else
708042
        {                       # button is passive
708042
            print $fh
708042
                $ICONS && $PASSIVE_ICONS{$button} ?
708042
                    &$button_icon_img($button,
708042
                                          $PASSIVE_ICONS{$button},
708042
                                          #$Texi2HTML::NAME{$button}) :
708042
                                          $Texi2HTML::NO_TEXI{$button}) :
708042
708042
                                              "[" . $NAVIGATION_TEXT{$button} . "]";
708042
        }
708042
        print $fh "\n";
708042
        print $fh "\n" if $vertical;
708042
    }
708042
    print $fh "" unless $vertical;
708042
    print $fh "\n";
708042
}
708042
708042
# Use icons for navigation.
708042
$ICONS = 1;
708042
708042
# specify in this array which "buttons" should appear in which order
708042
# in the navigation panel for sections; use ' ' for empty buttons (space)
708042
@SECTION_BUTTONS =
708042
    (
708042
     'Back', 'Top', 'Forward'
708042
    );
708042
708042
# insert here name of icon images for buttons
708042
# Icons are used, if $ICONS and resp. value are set
708042
%ACTIVE_ICONS =
708042
    (
708042
     'Top',         'file:///usr/share/gimp/2.0/help/images/home.png',
708042
     'Contents',    '',
708042
     'Overview',    '',
708042
     'Index',       '',
708042
     'This',        '',
708042
     'Back',        'file:///usr/share/gimp/2.0/help/images/prev.png',
708042
     'FastBack',    '',
708042
     'Prev',        'file:///usr/share/gimp/2.0/help/images/prev.png',
708042
     'Up',          'file:///usr/share/gimp/2.0/help/images/up.png',
708042
     'Next',        'file:///usr/share/gimp/2.0/help/images/next.png',
708042
     'NodeUp',      'file:///usr/share/gimp/2.0/help/images/up.png',
708042
     'NodeNext',    'file:///usr/share/gimp/2.0/help/images/next.png',
708042
     'NodePrev',    'file:///usr/share/gimp/2.0/help/images/next.png',
708042
     'Following',   'file:///usr/share/gimp/2.0/help/images/next.png',
708042
     'Forward',     'file:///usr/share/gimp/2.0/help/images/next.png',
708042
     'FastForward', '',
708042
     'About' ,      '',
708042
     'First',       '',
708042
     'Last',        '',
708042
     ' ',           ''
708042
    );
708042
708042
# insert here name of icon images for these, if button is inactive
708042
%PASSIVE_ICONS =
708042
    (
708042
     'Top',         '',
708042
     'Contents',    '',
708042
     'Overview',    '',
708042
     'Index',       '',
708042
     'This',        '',
708042
     'Back',        '',
708042
     'FastBack',    '',
708042
     'Prev',        '',
708042
     'Up',          '',
708042
     'Next',        '',
708042
     'NodeUp',      '',
708042
     'NodeNext',    '',
708042
     'NodePrev',    '',
708042
     'Following',   '',
708042
     'Forward',     '',
708042
     'FastForward', '',
708042
     'About',       '',
708042
     'First',       '',
708042
     'Last',        '',
708042
    );