Blame Manuals/Texinfo/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.
41622d
$SECTION_NAVIGATION = 1;
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
    print $fh <
d7b2cd
d7b2cd
d7b2cd
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
d7b2cd
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
06e2d5
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$LANG" lang="$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}" />
41622d
    <meta name="copyright" content="2009, 2010, 2011 The CentOS Project" />
d7b2cd
9a9c85
    <link href="/home/centos/artwork/trunk/Manuals/Texinfo/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;
41622d
    my @date=localtime(time);
41622d
    my $year=$date[5] += 1900;
41622d
    my $program_string = program_string();
d7b2cd
    print $fh <
d7b2cd
41622d
        

$program_string

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;
41622d
    print $fh '' . "\n";
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;
41622d
    print $fh "\n";
708042
}
708042
708042
# Use icons for navigation.
41622d
$ICONS = 0;
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
    (
41622d
     'Top',         'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-top.png',
41622d
     'Contents',    'file:///usr/share/icons/Bluecurve/24x24/stock/help-contents.png',
708042
     'Overview',    '',
41622d
     'Index',       'file:///usr/share/icons/Bluecurve/24x24/stock/stock-find.png',
708042
     'This',        '',
41622d
     'Back',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'FastBack',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-first.png',
41622d
     'Prev',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'Up',          'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-up.png',
41622d
     'Next',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'NodeUp',      'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-up.png',
41622d
     'NodeNext',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'NodePrev',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'Following',   'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'Forward',     'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'FastForward', 'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-last.png',
41622d
     'About' ,      'file:///usr/share/icons/Bluecurve/24x24/stock/gtk-about.png',
41622d
     'First',       'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-first.png',
41622d
     'Last',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-last.png',
708042
     ' ',           ''
708042
    );
708042
41622d
# Insert here name of icon images for these, if button is inactive
708042
%PASSIVE_ICONS =
708042
    (
41622d
     'Top',         'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-top.png',
41622d
     'Contents',    'file:///usr/share/icons/Bluecurve/24x24/stock/help-contents.png',
708042
     'Overview',    '',
41622d
     'Index',       'file:///usr/share/icons/Bluecurve/24x24/stock/stock-find.png',
708042
     'This',        '',
41622d
     'Back',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'FastBack',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-first.png',
41622d
     'Prev',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'Up',          'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-up.png',
41622d
     'Next',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'NodeUp',      'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-up.png',
41622d
     'NodeNext',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'NodePrev',    'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-back.png',
41622d
     'Following',   'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'Forward',     'file:///usr/share/icons/Bluecurve/24x24/stock/stock-go-forward.png',
41622d
     'FastForward', 'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-last.png',
41622d
     'About' ,      'file:///usr/share/icons/Bluecurve/24x24/stock/gtk-about.png',
41622d
     'First',       'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-first.png',
41622d
     'Last',        'file:///usr/share/icons/Bluecurve/24x24/stock/stock-goto-last.png',
41622d
     ' ',           ''
708042
    );