#!/bin/bash # 06-07-2016 # Licence : GPLv3 echo "generating complete file" echo "creating folders" if [ ! -d ../output/images ]; then mkdir ../output/images fi if [ ! -d ../output/thumbs ]; then mkdir ../output/thumbs fi if [ ! -d ../output/sources ]; then mkdir ../output/sources fi # if [ -f content.textile ]; then # rm content.textile # fi if [ ! -d temp ]; then rm -rf tmp fi mkdir tmp touch tmp/content.textile touch tmp/summary # echo "" > tmp/summary echo "reading content" # _ _ # | | | | # ___ ___ _ __ | |_ ___ _ __ | |_ # / __/ _ \| '_ \| __/ _ \ '_ \| __| # | (_| (_) | | | | || __/ | | | |_ # \___\___/|_| |_|\__\___|_| |_|\__| echo "
" >> tmp/content.textile for i in ../content/*; do # if folder if not sys if not modele if [ -d "$i" ] && [[ ! "$i" =~ "model" ]]; then # if readme exists if [ -f "$i/readme.textile" ]; then # user name # record readme content on variable cont=$(cat "$i/readme.textile") echo "$i" # echo "$cont" # user=$(grep "h1\.\s*.+" "$i/readme.textile") # user="${cont% h1}" # user=$(expr "$cont" : "h1. \(.*\)$") # echo "user : $user" u=${i/..\//} # record link for menu # echo "
  • $u
  • " >> tmp/summary u=${u/content//} id=${u:2} echo "* \"$id\":#$id" >> tmp/summary # right html and contents on main tmp/content.textile echo "
    " >> tmp/content.textile # add user content to main content echo "
    "$'\n' >> tmp/content.textile # add content to main tmp/content.textile cat "$i/readme.textile" >> tmp/content.textile echo $'\n'"
    " >> tmp/content.textile # get folder name folder=$(basename "$i") # _ # (_) # _ _ __ ___ __ _ __ _ ___ ___ # | | '_ ` _ \ / _` |/ _` |/ _ \/ __| # | | | | | | | (_| | (_| | __/\__ \ # |_|_| |_| |_|\__,_|\__, |\___||___/ # __/ | # |___/ echo " images" images="" l=0 echo "
    "$'\n' >> tmp/content.textile for img in $i/images/*; do # echo "images : $img" if [ -f "$img" ] && [[ ! "$img" =~ ".db" ]] && [[ ! "$img" =~ ".avi" ]]; then # record file name fn=$(basename "$img") counter=$(printf %02d $l) # record extension ext="${fn##*.}" # record new image name fimg="$folder-$counter.$ext" # copy image file with new name cp -f "$img" ../output/images/$fimg # convert thumbs convert ../output/images/$fimg -resize 800x800\> ../output/thumbs/$fimg # replace image name in main tmp/content.textile file # pandoc can't render textile links sed -i \ "s/!images\/$fn!/!thumbs\/$fimg!<\/a>/g" tmp/content.textile # sed -i "s/!images\/$fn!/thumbs\/$fimg/g" tmp/content.textile # 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 "* !thumbs/$fimg!" >> tmp/content.textile fi fi done echo $'\n'"
    " >> tmp/content.textile # _________ __ _______________ _____ # / ___/ __ \/ / / / ___/ ___/ _ \/ ___/ # (__ ) /_/ / /_/ / / / /__/ __(__ ) # /____/\____/\__,_/_/ \___/\___/____/ # echo " sources" echo "
    "$'\n' >> tmp/content.textile for src in $i/sources/*; do # echo "patch : $src" if [ -f "$src" ]; then # if ~ is not on file name ... if [[ ! "$src" =~ "~" ]]; then # record file name fn=$(basename "$src") cp -f "$src" ../output/sources/$i/$fn # echo $'\r'"
  • " >> tmp/content.textile echo "* \"$fn\":sources/$i/$fn" >> tmp/content.textile # echo $'\r'"
  • " >> tmp/content.textile fi fi done echo $'\n'"
    " >> tmp/content.textile echo "
    " >> tmp/content.textile echo '
    ' >> tmp/content.textile fi fi done # ____ __ # / __ \____ _____/ / # / /_/ / __ `/ __ / # / ____/ /_/ / /_/ / # /_/ \__,_/\__,_/ # curl http://pads.osp.kitchen/p/ola-workshop/export/txt -o tmp/pad.md curl https://mypads.framapad.org/p/ola-5doc-6117z7kl/export/txt -o tmp/pad.md echo "* \"Pad\":#pad" >> tmp/summary # right html and contents on main tmp/content.textile echo "
    " >> tmp/content.textile echo "

    Pad

    " >> tmp/content.textile # add user content to main content echo "
    "$'\n' >> tmp/content.textile # add content to main tmp/content.textile pandoc -f markdown -t textile -o tmp/pad.textile tmp/pad.md cat tmp/pad.textile >> tmp/content.textile echo $'\n'"
    " >> tmp/content.textile echo "
    " >> tmp/content.textile echo '
    ' >> tmp/content.textile # ______ __ ____ __ # / ____/___ ____ / /__/ __ )____ ____ / /__ # / / / __ \/ __ \/ //_/ __ / __ \/ __ \/ //_/ # / /___/ /_/ / /_/ / ,< / /_/ / /_/ / /_/ / ,< # \____/\____/\____/_/|_/_____/\____/\____/_/|_| # curl http://pads.osp.kitchen/p/ola-cookbook/export/txt -o tmp/cookbook.md # # echo "* \"CookBook\":#cookbook" >> tmp/summary # # # right html and contents on main tmp/content.textile # echo "
    " >> tmp/content.textile # echo "

    CookBook

    " >> tmp/content.textile # # add user content to main content # echo "
    "$'\n' >> tmp/content.textile # # add content to main tmp/content.textile # pandoc -f markdown -t textile -o tmp/cookbook.textile tmp/cookbook.md # cat tmp/cookbook.textile >> tmp/content.textile # echo $'\n'"
    " >> tmp/content.textile # echo "
    " >> tmp/content.textile # # echo '
    ' >> tmp/content.textile # end main section echo "
    " >> tmp/content.textile # _ _ # | | | | # | |__ ___ __ _ __| | ___ _ __ # | '_ \ / _ \/ _` |/ _` |/ _ \ '__| # | | | | __/ (_| | (_| | __/ | # |_| |_|\___|\__,_|\__,_|\___|_| echo "header" touch tmp/header echo "" >> tmp/header cat tmp/header|cat - tmp/content.textile > tmp/out && mv tmp/out tmp/content.textile echo "Pandoc" pandoc -s \ -f textile \ -t html5 -o ../output/index.html \ -H style.tpl.html \ -A script.tpl.html \ tmp/content.textile # -H css/main.css \ cp -r css ../output/ cp -r fonts ../output/ cp -r bower_components ../output/ # echo "export markdown as html" # pandoc -s \ # -f markdown+hard_line_breaks+auto_identifiers+ascii_identifiers+tex_math_dollars+pipe_tables+all_symbols_escapable \ # -t html5 -o index.html \ # -c fonts/amiri/amiri.css \ # -H bower_components/lightbox2/dist/css/lightbox.min.css \ # -H css/styles.css \ # -B body-base-top.tpl.html \ # -A body-base-bot.tpl.html \ # -A js/jquery.min.js \ # -A js/script.js \ # # -A js/css-regions-polyfill.min.js \ # -A body-base-end.tpl.html \ # pad.md