Commit acd1917c authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Update script to do the GitHub conversion possibly better.

parent ba4599e2
......@@ -7,7 +7,8 @@
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Wikifies SquirrelJME
# DESCRIPTION: Wikifies SquirrelJME for GitHub, since GitHub uses a different
# format for their Wikis...
# Must be valid!
if [ "$#" -lt "2" ]
......@@ -17,42 +18,66 @@ then
fi
# These are directories
__repo="$1/assets/user-guide"
__wiki="$2"
__foss="$1/assets/user-guide"
__gith="$2"
# These both must be directories
if [ ! -d "$__repo" ] || [ ! -d "$__wiki" ]
if [ ! -d "$__foss" ] || [ ! -d "$__gith" ]
then
echo "Both arguments must be directories."
exit 1
fi
# Target must be a Git repo
if [ ! -d "$__wiki/.git" ]
if [ ! -d "$__gith/.git" ]
then
echo "Target not a Git repository."
exit 1
fi
# Convert to GitHub name
__toGitHubName()
{
__srcName="$1"
echo "$__srcName" | sed 's/\.mkd$/\.markdown/'
}
# Convert to Fossil name
__toFossilName()
{
__srcName="$1"
echo "$__srcName" | sed 's/\.markdown$/\.mkd/'
}
# Remove any other old files
find "$__gith" -type f | grep -e '\.mkd$' -e '\.md$' | while read __githFile
do
echo "Removing old file $__githFile..."
git rm -f "$__githFile"
done
# Remove any files which are missing
find "$__wiki" -type f | while read __wikiFile
find "$__gith" -type f | grep '\.markdown$' | while read __githFile
do
__baseName="$(basename "$__wikiFile")"
__baseGith="$(basename "$__githFile")"
__baseFoss="$(__toFossilName "$__baseGith")"
# File is missing, remove it
if [ ! -f "$__repo/$__baseName" ]
# The file may be in the root of the project or elsewhere...
if ! find "$__foss/" -type f | grep "$__baseFoss" > /dev/null
then
echo "Removing file $___baseName..."
echo "Removing file $__githFile (aka $__baseFoss)..."
git rm -f "$__wikiFile"
git rm -f "$__githFile"
fi
done
# Copy and add any files over
find "$__repo" -type f | while read __repoFile
# Copy and convert the files for GitHub's Wiki
find "$__foss" -type f | grep '\.mkd$' | while read __fossFile
do
__baseName="$(basename "$__repoFile")"
__baseFoss="$(basename "$__fossFile")"
__baseGith="$(__toGitHubName "$__baseFoss")"
cp -vf "$__repoFile" "$__wiki/$__baseName"
(cd "$__wiki" && git add "$__wiki/$__baseName")
# Links need to be properly converted or they will be lost
sed 's/(\([^.]*\)\.mkd)/(\1)/g' < "$__fossFile" > "$__gith/$__baseGith"
(cd "$__gith" && git add "$__gith/$__baseGith")
done
......@@ -8,10 +8,10 @@ some fun with it and otherwise!
You may view this guide on the following:
* [Main Website](https://squirreljme.cc/doc/ckout/assets/user-guide/Home.md)
* [SquirrelJME.cc](https://squirreljme.cc/doc/trunk/assets/user-guide/readme.mkd)
* [GitHub](https://github.com/SquirrelJME/SquirrelJME/wiki)
## Table of Contents
* [Frequently Asked Questions](faq.md)
* [List of errors](error-list.md)
* [Frequently Asked Questions](faq.mkd)
* [List of errors](error-list.mkd)
......@@ -58,7 +58,7 @@ https://img.shields.io/github/commit-activity/w/SquirrelJME/SquirrelJME.svg)
Information:
* [User Guide](assets/user-guide/Home.md)
* [User Guide](assets/user-guide/readme.mkd)
* [Code of Conduct](code-of-conduct.mkd)
* [License](license.mkd)
* _Source_: GNU General Public License, Version 3 or later
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment