Blame Scripts/Functions/Help/help_updateOutputFileXhtml.sh

d3e9d7
#!/bin/bash
d3e9d7
#
1afa3c
# texinfo_updateOutputFileXhtml.sh -- This function exports
5285d6
# documentation manual to HTML format.
d3e9d7
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
d3e9d7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d3e9d7
# General Public License for more details.
d3e9d7
#
d3e9d7
# You should have received a copy of the GNU General Public License
d3e9d7
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
d3e9d7
# ----------------------------------------------------------------------
d3e9d7
# $Id$
d3e9d7
# ----------------------------------------------------------------------
d3e9d7
1afa3c
function texinfo_updateOutputFileXhtml {
d3e9d7
420e77
    # Verify initialization files used by texi2html.
420e77
    cli_checkFiles ${MANUAL_BACKEND}/${MANUAL_NAME}-init.pl
420e77
    cli_checkFiles ${MANUAL_TEMPLATE}/${MANUAL_NAME}-init.pl
420e77
420e77
    # Verify transformation files used to modify texi2html output.
420e77
    cli_checkFiles ${MANUAL_BACKEND}/${MANUAL_NAME}.sed
420e77
    cli_checkFiles ${MANUAL_TEMPLATE}/${MANUAL_NAME}.sed
420e77
5285d6
    # Output action message.
18be6e
    cli_printMessage "${MANUAL_BASEFILE}.xhtml.tar.bz2" --as-updating-line
d3e9d7
25b773
    # Redefine manual base file to use just the file base name.
25b773
    local MANUAL_BASEFILE=$(basename "$MANUAL_BASEFILE")
d3e9d7
25b773
    # Add manual base directory path into directory stack to make it
25b773
    # the current working directory. This is done to reduce the path
25b773
    # information packaged inside `repository.xhtml.tar.bz2' file.
25b773
    pushd ${MANUAL_BASEDIR} > /dev/null
d3e9d7
25b773
    # Prepare directory structure where xhtml files will be stored in.
25b773
    [[ ! -d ${MANUAL_BASEFILE}.xhtml ]] && mkdir -p ${MANUAL_BASEFILE}.xhtml
25b773
25b773
    # Clean up directory structure where xhtml files will be stored.
25b773
    # We don't want to have unused files inside it.
25b773
    [[ $(ls ${MANUAL_BASEFILE}.xhtml > /dev/null) ]] && rm ${MANUAL_BASEFILE}.xhtml/*.xhtml
25b773
bf016b
    # Add directory where xhtml files will be sotred in into directory
bf016b
    # stack to make it the current working directory. This is required
bf016b
    # in order for include paths to be constructed correctly.
bf016b
    pushd ${MANUAL_BASEFILE}.xhtml > /dev/null
bf016b
25b773
    # Update xhtml files.  Use texi2html to export from texinfo file
420e77
    # format to xhtml using CentOS Web default visual style.
420e77
    texi2html --lang=$(cli_getCurrentLocale --langcode-only) \
420e77
        --init-file=${MANUAL_BACKEND}/${MANUAL_NAME}-init.pl \
420e77
        --init-file=${MANUAL_TEMPLATE}/${MANUAL_NAME}-init.pl \
420e77
        --output=${MANUAL_BASEDIR}/${MANUAL_NAME}.xhtml \
420e77
        ${MANUAL_BASEDIR}/${MANUAL_NAME}.${FLAG_BACKEND}
bf016b
bf016b
    # Remove directory where xhtml files are stored from directory
bf016b
    # stack. The xhtml files have been already created.
bf016b
    popd > /dev/null
d3e9d7
25b773
    # Apply xhtml transformations. This transformation cannot be built
420e77
    # inside the initialization script (repository-init.pl). For example,
420e77
    # Would it be a possible way to produce different quotation HTML
420e77
    # outputs from the same texinfo quotation definition?  Instead,
25b773
    # once the HTML code is produced we can take que quotation HTML
25b773
    # definition plus the first letters inside it and transform the
25b773
    # structure to a completly different thing that can be handle
25b773
    # through classed inside CSS definitions.
420e77
    sed -r -i \
420e77
        -f ${MANUAL_BACKEND}/${MANUAL_NAME}.sed \
420e77
        -f ${MANUAL_TEMPLATE}/${MANUAL_NAME}.sed \
420e77
        ${MANUAL_BASEFILE}.xhtml/*.xhtml
25b773
25b773
    # Compress directory structure where xhtml files are stored in.
25b773
    # This compressed version is the one we put under version control.
25b773
    # The directory used to build the compressed version is left
25b773
    # unversion for the matter of human revision.
25b773
    tar -cjf ${MANUAL_BASEFILE}.xhtml.tar.bz2 ${MANUAL_BASEFILE}.xhtml
d3e9d7
25b773
    # Remove manual base directory from directory stack.
d3e9d7
    popd > /dev/null
d3e9d7
d3e9d7
}