2 # ---------------------------------------------------------------------------
3 # Multi-Phasic Applications: SquirrelJME
4 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 # Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
6 # ---------------------------------------------------------------------------
7 # SquirrelJME is under the GNU General Public License v3+, or later.
8 # See license.mkd for licensing and copyright information.
9 # ---------------------------------------------------------------------------
10 # DESCRIPTION: Wikifies SquirrelJME for GitHub, since GitHub uses a different
11 # format for their Wikis...
16 echo "Usage: $0 [repo] [wiki-git-repo]"
20 # These are directories
21 __foss
="$1/assets/user-guide"
24 # These both must be directories
25 if [ ! -d "$__foss" ] ||
[ ! -d "$__gith" ]
27 echo "Both arguments must be directories."
31 # Target must be a Git repo
32 if [ ! -d "$__gith/.git" ]
34 echo "Target not a Git repository."
38 # Convert to GitHub name
43 if [ "$__srcName" = "readme.mkd" ]
47 echo "$__srcName" |
sed 's/\.mkd$/\.markdown/'
51 # Convert to Fossil name
56 if [ "$__srcName" = "Home.markdown" ]
60 echo "$__srcName" |
sed 's/\.markdown$/\.mkd/'
64 # Remove any other old files
65 find "$__gith" -type f |
grep -e '\.mkd$' -e '\.md$' |
while read __githFile
67 echo "Removing old file $__githFile..."
68 (cd "$__gith" && git
rm -f "$__githFile")
71 # Remove any files which are missing
72 find "$__gith" -type f |
grep '\.markdown$' |
while read __githFile
74 __baseGith
="$(basename "$__githFile")"
75 __baseFoss
="$(__toFossilName "$__baseGith")"
77 # The file may be in the root of the project or elsewhere...
78 if ! find "$__foss/" -type f |
grep "$__baseFoss" > /dev
/null
80 echo "Removing file $__githFile (aka $__baseFoss)..."
82 (cd "$__gith" && git
rm -f "$__githFile")
86 # Copy and convert the files for GitHub's Wiki
87 find "$__foss" -type f |
grep '\.mkd$' |
while read __fossFile
89 __baseFoss
="$(basename "$__fossFile")"
90 __baseGith
="$(__toGitHubName "$__baseFoss")"
92 echo "Converting $__baseFoss to $__baseGith..."
94 # Links need to be properly converted or they will be lost
95 sed 's/(readme\.mkd)/(Home)/g' < "$__fossFile" | \
96 sed 's/(\([^.]*\)\.mkd)/(\1)/g' > "$__gith/$__baseGith"
97 (cd "$__gith" && git add
"$__gith/$__baseGith")