Blob Blame History Raw
#!/bin/bash
#
# texinfo_updateOutputFileXhtml.sh -- This function exports
# documentation manual to HTML format.
#
# Copyright (C) 2009, 2010, 2011 The CentOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ----------------------------------------------------------------------
# $Id$
# ----------------------------------------------------------------------

function texinfo_updateOutputFileXhtml {

    # Output action message.
    cli_printMessage "${MANUAL_BASEFILE}.xhtml.tar.bz2" --as-response-line

    # Verify initialization files used by texi2html.
    cli_checkFiles ${MANUAL_TEMPLATE}/manual-init.pl
    cli_checkFiles ${MANUAL_TEMPLATE_L10N}/manual-init.pl

    # Verify transformation files used to modify texi2html output.
    cli_checkFiles ${MANUAL_TEMPLATE}/manual.sed
    cli_checkFiles ${MANUAL_TEMPLATE_L10N}/manual.sed

    # Redefine manual base file to use just the file base name.
    local MANUAL_BASEFILE=$(basename "$MANUAL_BASEFILE")

    # Add manual base directory path into directory stack to make it
    # the current working directory. This is done to reduce the path
    # information packaged inside `repository.xhtml.tar.bz2' file.
    pushd ${MANUAL_BASEDIR_L10N} > /dev/null

    # Clean up directory structure where xhtml files will be stored.
    # We don't want to have unused files inside it.
    if [[ -d ${MANUAL_NAME}-xhtml ]];then
        rm -r ${MANUAL_NAME}-xhtml
    fi

    # Prepare directory structure where xhtml files will be stored in.
    mkdir ${MANUAL_NAME}-xhtml

    # Add directory where xhtml files will be sotred in into directory
    # stack to make it the current working directory. This is required
    # in order for include paths to be constructed correctly.
    pushd ${MANUAL_NAME}-xhtml > /dev/null

    # Update xhtml files.  Use texi2html to export from texinfo file
    # format to xhtml using The CentOS Web default visual style.
    texi2html --lang=$(cli_getCurrentLocale --langcode-only) \
        --init-file=${MANUAL_TEMPLATE}/manual-init.pl \
        --init-file=${MANUAL_TEMPLATE_L10N}/manual-init.pl \
        --output=${MANUAL_BASEDIR_L10N}/${MANUAL_NAME}-xhtml \
        ${MANUAL_BASEDIR_L10N}/${MANUAL_NAME}.${MANUAL_EXTENSION}

    # Remove directory where xhtml files are stored from directory
    # stack. The xhtml files have been already created.
    popd > /dev/null

    # Apply xhtml transformations. This transformation cannot be built
    # inside the initialization script (repository-init.pl). For example,
    # Would it be a possible way to produce different quotation HTML
    # outputs from the same texinfo quotation definition?  Instead,
    # once the HTML code is produced we can take que quotation HTML
    # definition plus the first letters inside it and transform the
    # structure to a completly different thing that can be handle
    # through classed inside CSS definitions.
    sed -r -i \
        -f ${MANUAL_TEMPLATE}/manual.sed \
        -f ${MANUAL_TEMPLATE_L10N}/manual.sed \
        ${MANUAL_BASEFILE}-xhtml/*.xhtml

    # Compress directory structure where xhtml files are stored in.
    # This compressed version is the one we put under version control.
    # The directory used to build the compressed version is left
    # unversion for the matter of human revision.
    tar -cjf ${MANUAL_BASEFILE}.xhtml.tar.bz2 ${MANUAL_BASEFILE}-xhtml

    # Remove manual base directory from directory stack.
    popd > /dev/null

}