| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function texinfo_createChapter { |
| |
| |
| |
| |
| |
| |
| if [[ -d $MANUAL_CHAPTER_DIR ]];then |
| return |
| else |
| cli_printMessage "`gettext "The following documentation chapter doesn't exist:"`" --as-stdout-line |
| cli_printMessage "${MANUAL_CHAPTER_DIR}" --as-response-line |
| cli_printMessage "`gettext "Do you want to create it now?"`" --as-yesornorequest-line |
| fi |
| |
| # Initialize chapter node, chapter index and chapter title. |
| local MANUAL_CHAPTER_NODE='' |
| local MANUAL_CHAPTER_TITLE='' |
| local MANUAL_CHAPTER_CIND='' |
| |
| # Request the user to enter a chapter title. |
| cli_printMessage "`gettext "Chapter Title"`" --as-request-line |
| read MANUAL_CHAPTER_TITLE |
| |
| # Sanitate chapter node, chapter index and chapter title. |
| MANUAL_CHAPTER_NODE=$(texinfo_getEntryNode "$MANUAL_CHAPTER_NAME") |
| MANUAL_CHAPTER_CIND=$(texinfo_getEntryIndex "$MANUAL_CHAPTER_TITLE") |
| MANUAL_CHAPTER_TITLE=$(texinfo_getEntryTitle "$MANUAL_CHAPTER_TITLE") |
| |
| # Print action message. |
| cli_printMessage "-" --as-separator-line |
| cli_printMessage "`gettext "Creating chapter files."`" --as-response-line |
| |
| # Define list of template files used to build the chapter main |
| # definition files. |
| local FILE='' |
| local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}/Chapters" \ |
| --maxdepth='1' \ |
| --pattern="chapter(-menu|-nodes)?\.${MANUAL_EXTENSION}") |
| |
| # Create chapter directory using subversion. This is the place |
| # where all chapter-specific files will be stored in. |
| if [[ ! -d ${MANUAL_CHAPTER_DIR} ]];then |
| ${CLI_NAME} svn --mkdir ${MANUAL_CHAPTER_DIR} |
| fi |
| |
| # Create chapter-specific files using template files as reference. |
| for FILE in $FILES;do |
| |
| # Verify texinfo templates used as based to build the chapter |
| # structure. Be sure they are inside the working copy of |
| # The CentOS Artwork Repository (-w) and under version control |
| # (-n), too. |
| cli_checkFiles ${FILE} --is-versioned |
| |
| # Copy template files into the chapter directory. |
| ${CLI_NAME} svn --copy ${FILE} ${MANUAL_CHAPTER_DIR} |
| |
| done |
| |
| # Before expanding chapter information, be sure the slash (/) |
| # character be scaped. Otherwise, if the slashes aren't scape, |
| |
| |
| MANUAL_CHAPTER_NODE=$(echo "$MANUAL_CHAPTER_NODE" | sed -r 's/\//\\\//g') |
| MANUAL_CHAPTER_CIND=$(echo "$MANUAL_CHAPTER_CIND" | sed -r 's/\//\\\//g') |
| MANUAL_CHAPTER_TITLE=$(echo "$MANUAL_CHAPTER_TITLE" | sed -r 's/\//\\\//g') |
| MANUAL_CHAPTER_NAME=$(echo "$MANUAL_CHAPTER_NAME" | sed -r 's/\//\\\//g') |
| |
| |
| sed -i -r \ |
| -e "s/=CHAPTER_NODE=/${MANUAL_CHAPTER_NODE}/" \ |
| -e "s/=CHAPTER_TITLE=/${MANUAL_CHAPTER_TITLE}/" \ |
| -e "s/=CHAPTER_CIND=/${MANUAL_CHAPTER_CIND}/" \ |
| -e "s/=CHAPTER_NAME=/${MANUAL_CHAPTER_NAME}/" \ |
| ${MANUAL_CHAPTER_DIR}/chapter.${MANUAL_EXTENSION} |
| |
| |
| |
| |
| |
| |
| |
| echo "" > ${MANUAL_CHAPTER_DIR}/chapter-nodes.${MANUAL_EXTENSION} |
| |
| |
| cli_printMessage "`gettext "Updating chapter menu and nodes inside manual structure."`" --as-response-line |
| |
| |
| |
| texinfo_updateChapterMenu |
| texinfo_updateChapterNodes |
| |
| } |