This commit is contained in:
Bachir Soussi Chiadmi
2016-12-04 16:49:29 +01:00
parent b36ca5bcc0
commit ad756a8be3
4 changed files with 436 additions and 38 deletions
+44 -38
View File
@@ -17,12 +17,18 @@ if [ ! -d ../output/sources ]; then
mkdir ../output/sources
fi
if [ -f content.textile ]; then
rm content.textile
fi
touch content.textile
# if [ -f content.textile ]; then
# rm content.textile
# fi
echo "" > /tmp/summary
if [ ! -d temp ]; then
rm -rf tmp
fi
mkdir tmp
touch tmp/content.textile
touch tmp/summary
# echo "" > tmp/summary
echo "reading content"
# _ _
@@ -31,7 +37,7 @@ echo "reading content"
# / __/ _ \| '_ \| __/ _ \ '_ \| __|
# | (_| (_) | | | | || __/ | | | |_
# \___\___/|_| |_|\__\___|_| |_|\__|
echo "<section id='main'>" >> content.textile
echo "<section id='main'>" >> tmp/content.textile
for i in ../content/*; do
# if folder if not sys if not modele
if [ -d "$i" ] && [[ ! "$i" =~ "model" ]]; then
@@ -50,16 +56,16 @@ for i in ../content/*; do
u=${i/..\//}
# record link for menu
# echo "<li><a href='#$u'>$u</a></li>" >> /tmp/summary
echo "* \"$u\":#$u" >> /tmp/summary
# echo "<li><a href='#$u'>$u</a></li>" >> tmp/summary
echo "* \"$u\":#$u" >> tmp/summary
# right html and contents on main content.textile
echo "<div id='$u' class='user'>" >> content.textile
# right html and contents on main tmp/content.textile
echo "<div id='$u' class='user'>" >> tmp/content.textile
# add user content to main content
echo "<section class='content'>"$'\n' >> content.textile
# add content to main content.textile
cat "$i/readme.textile" >> content.textile
echo $'\n'"</section>" >> content.textile
echo "<section class='content'>"$'\n' >> tmp/content.textile
# add content to main tmp/content.textile
cat "$i/readme.textile" >> tmp/content.textile
echo $'\n'"</section>" >> tmp/content.textile
# get folder name
folder=$(basename "$i")
@@ -75,7 +81,7 @@ for i in ../content/*; do
echo " images"
images=""
l=0
echo "<section class='images'>"$'\n' >> content.textile
echo "<section class='images'>"$'\n' >> tmp/content.textile
for img in $i/images/*; do
# echo "images : $img"
if [ -f "$img" ] && [[ ! "$img" =~ ".db" ]] && [[ ! "$img" =~ ".avi" ]]; then
@@ -90,22 +96,22 @@ for i in ../content/*; do
cp -f "$img" ../output/images/$fimg
# convert thumbs
convert ../output/images/$fimg -resize 400x400\> ../output/thumbs/$fimg
# replace image name in main content.textile file
# replace image name in main tmp/content.textile file
# pandoc can't render textile links
sed -i "s/!images\/$fn!/<a data-lightbox='$folder' href='images\/$fimg'>!thumbs\/$fimg!<\/a>/g" content.textile
# sed -i "s/!images\/$fn!/thumbs\/$fimg/g" content.textile
sed -i "s/!images\/$fn!/<a data-lightbox='$folder' href='images\/$fimg'>!thumbs\/$fimg!<\/a>/g" tmp/content.textile
# sed -i "s/!images\/$fn!/thumbs\/$fimg/g" tmp/content.textile
# find "content.textile" -print0 | xargs -0 sed -i '' -e "s/images\/$fn/images\/$fimg/g"
# find "tmp/content.textile" -print0 | xargs -0 sed -i '' -e "s/images\/$fn/images\/$fimg/g"
l=$(($l+1))
# if image is not on content ...
if [[ ! "$cont" =~ "images/$fn" ]]; then
# ... add it at end of content
echo "* <a data-lightbox='$folder' href='images/$fimg'>!thumbs/$fimg!</a>" >> content.textile
echo "* <a data-lightbox='$folder' href='images/$fimg'>!thumbs/$fimg!</a>" >> tmp/content.textile
fi
fi
done
echo $'\n'"</section>" >> content.textile
echo $'\n'"</section>" >> tmp/content.textile
# _________ __ _______________ _____
@@ -114,7 +120,7 @@ for i in ../content/*; do
# /____/\____/\__,_/_/ \___/\___/____/
#
echo " sources"
echo "<section class='sources'>"$'\n' >> content.textile
echo "<section class='sources'>"$'\n' >> tmp/content.textile
for src in $i/sources/*; do
# echo "patch : $src"
if [ -f "$src" ]; then
@@ -123,22 +129,22 @@ for i in ../content/*; do
# record file name
fn=$(basename "$src")
cp -f "$src" ../output/sources/$fn
# echo $'\r'"<li>" >> content.textile
echo "* \"$fn\":sources/$fn" >> content.textile
# echo $'\r'"</li>" >> content.textile
# echo $'\r'"<li>" >> tmp/content.textile
echo "* \"$fn\":sources/$fn" >> tmp/content.textile
# echo $'\r'"</li>" >> tmp/content.textile
fi
fi
done
echo $'\n'"</section>" >> content.textile
echo $'\n'"</section>" >> tmp/content.textile
echo "</div>" >> content.textile
echo '<div class="pagebreak"></div>' >> content.textile
echo "</div>" >> tmp/content.textile
echo '<div class="pagebreak"></div>' >> tmp/content.textile
fi
fi
done
# end main section
echo "</section>" >> content.textile
echo "</section>" >> tmp/content.textile
# _ _
# | | | |
@@ -147,15 +153,15 @@ echo "</section>" >> content.textile
# | | | | __/ (_| | (_| | __/ |
# |_| |_|\___|\__,_|\__,_|\___|_|
echo "header"
touch /tmp/header
echo "<header id='header'>"$'\n' > /tmp/header
echo "h1. OLA#3 Documentation"$'\n' >> /tmp/header
echo "<nav id='menu'>"$'\n' >> /tmp/header
cat /tmp/summary >> /tmp/header
echo $'\n'"</nav>" >> /tmp/header
echo "</header>" >> /tmp/header
touch tmp/header
echo "<header id='header'>"$'\n' > tmp/header
echo "h1. OLA#3 Documentation"$'\n' >> tmp/header
echo "<nav id='menu'>"$'\n' >> tmp/header
cat tmp/summary >> tmp/header
echo $'\n'"</nav>" >> tmp/header
echo "</header>" >> tmp/header
cat /tmp/header|cat - content.textile > /tmp/out && mv /tmp/out content.textile
cat tmp/header|cat - tmp/content.textile > tmp/out && mv tmp/out tmp/content.textile
echo "Pandoc"
pandoc -s \
@@ -163,7 +169,7 @@ pandoc -s \
-t html5 -o ../output/index.html \
-H style.tpl.html \
-A script.tpl.html \
content.textile
tmp/content.textile
# -H css/main.css \