Skip to content

Instantly share code, notes, and snippets.

@matael
Created June 26, 2012 17:53
Show Gist options
  • Select an option

  • Save matael/2997444 to your computer and use it in GitHub Desktop.

Select an option

Save matael/2997444 to your computer and use it in GitHub Desktop.
Creation d'une page pour répertorier les pages à migrer (wiki partipirate)
#!/bin/bash
#prepare
csplit -f "sub_" listePageWiki.txt /Directory/ {50} -k -s
rm sub_00
rm subs/*
mv sub* subs/
#process
output="listePagesWiki.html"
base="http://forum.partipirate.org/wiki"
echo '<!DOCTYPE html>'
echo '<html>'
echo '<head>'
echo '<title>Lite des pages du wiki du partipirate</title>'
echo '<meta charset="utf-8"/>'
echo '</head>'
echo '<body>'
for i in `ls subs`; do
# real filename
filename="subs/$i"
# category ?
sub_sec=$(head -n 1 $filename | sed -e 's/\s*Directory:~\(.*\)$/\1/' | sed -e 's/\\/\//g' | sed -e 's/^\/*\(.*\)$/\1/g' )
if [[ $sub_sec="<U+FEFF>" ]]; then
sub_sec="/"
fi
echo "<h2>$sub_sec ($num_lines pages)</h2>"
echo "<ul>"
# how many line must we treat
num_lines=$(($(wc -l $filename |cut -d " " -f 1) - 3))
tail -n $num_lines $filename |
grep "^-a---" |
column -t |
sed -e 's/\s\s/|/g' |
cut -d '|' -f 5 |
cut -d '.' -f 1 |
sed -e 's/ //g' |
sed -e "s/^\(.*\)$/\<li\>\<a href\=\'$(echo $base|sed -e 's/\//\\\//g')\/$(echo $sub_sec|sed -e 's/\//\\\//g')\/\1\'\>$(echo $base|sed -e 's/\//\\\//g')\/$(echo $sub_sec|sed -e 's/\//\\\//g')\/\1\<\/a\>\<\/li\>/g" |sed -e 's/wiki\/\/\//wiki\//g'
echo "</ul>"
done
echo '</body>'
echo '</html>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment