#!/bin/sh
# createweb
# Modify pages downloaded from the NewbieDOC wiki and construct a stand-alone
# non-interactive website from them.
#
# Version 0.8
# Copyright 2007-2009 Chris Lale.
# 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/>.

# Find the wiki pages and convert them to standalone html
# Add .tmp extension
find ./newbiedoc.berlios.de/wiki/ -type f -exec mv '{}' '{}'.tmp \;
# Modify the HTML and add .html extension
find ./newbiedoc.berlios.de/wiki/ -type f -regex "./newbie.*/wiki/.*\.tmp$" -exec ./modify '{}' \;
# Replace .tmp.htl extension with .html
find ./newbiedoc.berlios.de/wiki/ -type f -regex "./newbie.*/wiki/.*\.tmp\.html$" -exec rename 's/\.tmp\.html$/\.html/' '{}' \;

# Remove original unconverted wiki pages
find ./newbiedoc.berlios.de/wiki/ -type f -regex "./newbie.*/wiki/.*\.tmp$" -delete
#find ./newbiedoc.berlios.de/wiki/ -type f -regex "./newbie.*/wiki/.*[)]$" -delete

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

#Tidy up
find . -type f -regex "./newbie.*/wiki\?.*" -delete
