script pour établir une bdd Ãà partir d'un tsv avec différent format - retour accueil
git clone git://bebou.netlib.re/laradb
Log | Files | Refs |
timeline.sh (1941B)
1 #!/bin/sh 2 3 # @todo: DONE 4 # - no dist directory in the git repo 5 # - set up manually start date (min) and end date (max) DONE 6 # - volumes 7 # - 8 9 #./src/utils/date_epoch.sh 10 11 echo Building timeline.html 12 13 DIST="dist" 14 DB="src/db.tsv" 15 OUT=$(basename "$0" | sed "s/sh$/html/g") 16 17 epoch_start="tmp/start_unixepoch" 18 epoch_end="tmp/end_unixepoch" 19 20 #max=$( sort tmp/end | tail -n1 | grep -o "^.\{4\}" | sed 's/$/ + 1/' | bc ) 21 #min=$( sort tmp/start | head -n1 | grep -o "^.\{4\}") 22 23 max=1991 24 min=1971 25 26 #echo "max = $max : min = $min" 27 # max = 2012 : min = 1971 28 29 min_epoch=$(date +%s --date="${min}-01-01" ) 30 max_epoch=$(date +%s --date="${max}-01-01" ) 31 #echo "$min_epoch ; $max_epoch " 32 33 34 entree(){ 35 echo "$line" | cut -d" " -f $1 36 #echo "$line" | tsv-select -f $1 37 } 38 39 round(){ 40 cut -d "." -f 1 41 } 42 43 left(){ 44 echo "( $(entree 19) - $min_epoch )/ $max_epoch * 100" | bc -l | round| sed "s/-.*/0/g" 45 } 46 47 width(){ 48 echo "( $(entree 20) - $(entree 19) )/ $max_epoch * 100" | bc -l | round 49 } 50 annees(){ 51 #seq $min $max | xargs printf '<td onclick="sortTable(2)" class="annee">%s</td>\n' 52 seq $min $max | xargs printf '<td class="annee">%s</td>\n' 53 } 54 55 LIGNE=1 56 cat << % > $DIST/$OUT 57 $(cat src/templates/head.html) 58 $(cat src/templates/nav-main.html) 59 $(cat src/templates/nav.html) 60 <table id="TIMELINE"> 61 $(while IFS= read -r line; do 62 if [ $LIGNE -eq 1 ]; then 63 cat <<- ENTETE 64 <thead> 65 <tr> 66 <td class="empty"></td> 67 <td class="numbers"></td> 68 <!--<td class="titre-complet">$(entree 2; entree 7 )</td>--> 69 <!--$(annees)--> 70 </tr> 71 </thead> 72 73 ENTETE 74 else 75 cat <<- CORPS 76 <tr> 77 <td class="titre-complet">$(entree 2)<span></span></td> 78 <td class="rectangle"> 79 <div data-number-of-issues="$(entree 7)" style="left: $(left)% ; width: $(width)%;"></div> 80 </td> 81 </tr> 82 83 CORPS 84 fi 85 LIGNE=$(($LIGNE + 1)) 86 done < $DB 87 ) 88 </table> 89 90 $(cat src/templates/foot.html) 91 % 92