#!/bin/sh
# Invoke the download, and modify scripts and find to download
# and modify pages from the NewbieDOC wiki and construct a stand-alone
# non-interactive website from them.
#
# Version 0.8
# Copyright 2007-2009 Chris Lale, GPL v3.
# chrislale@users.berlios.de
#
#    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 3 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, see <http://www.gnu.org/licenses/>.

# Download wiki pages and linked files, eg images.
./download

# Remove :NewbieDOC from file and dir names
find . -regex ./newbie.*/wiki/.* -exec rename 's/NewbieDOC://' {} \;

# Find the wiki pages and convert them to standalone html
#find . -type f -regex ./newbie.*/wiki/*[^\.html] -exec ./modify '{}' \;
find . -regextype posix-basic -regex ./newbie.*/wiki/.* -type f -exec ./modify '{}' \;
find . -regextype posix-basic -regex ./newbie.*/wiki/.* -type f -exec mv {} {}.html \;

# Remove original unconverted wiki pages
find . -type f -regex ./newbie.*/wiki/.*[^\.html] -delete

# Remove other unwanted files
find . -type f -regex ./newbie.*/wiki.title=.* -delete

# Remove unwanted skins directory
find . -type d -regex ./newbie.*/skins -exec rm -R '{}' \;
