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 |
table.sh (3463B)
1 #!/bin/bash 2 3 echo Building table.html 4 5 unsure(){ 6 # à revoir, ne capture pas "Grenoble?, Lyon?" par exemple 7 sed -e '/\?/s/\(.*\?\)\?/<span class=\"unsure\">\1<\/span>/' -e 's/\?//g' $1 8 } 9 format(){ 10 sed -e 's/\ mm/mm/g' $1 11 } 12 13 trim() { 14 sed "s/^[ \t]*//" 15 } 16 17 entree(){ 18 #echo "$line" | cut -d"," -f $1 19 echo "$line" | tsv-select -f $1 | unsure | format | trim 20 } 21 22 DIST="dist" 23 DB="src/db.tsv" 24 25 OUT=$(basename "$0" | sed "s/sh$/html/g") 26 27 LIGNE=1 28 cat << % > $DIST/$OUT 29 $(cat src/templates/head.html) 30 $(cat src/templates/nav-main.html) 31 $(cat src/templates/nav.html) 32 <section class="legende"> 33 <ul> 34 <li>Sources 35 <ul> 36 $(tsv-select -H -f Sources $DB | grep -v "Sources" | sed -e 's/, /\n/g' | sort | uniq -c | 37 awk ' 38 /BNF/{nom="Bibliothèque Nationale de France"} 39 /Atria/{nom="Atria"} 40 /MDP/{nom="Mouvement de presse"} 41 {printf "<li><span class=\"etiquette\">%s<sup>(%s)</sup></span>: %s</li>\n", $2, $1, nom}' 42 ) 43 </ul> 44 </li> 45 <li>Legend 46 <ul> 47 <li><span class="unsure">grayed</span>: uncertain data</li> 48 </ul> 49 </li> 50 </ul> 51 </section> 52 <table id="TABLEAU"> 53 $(while IFS= read -r line; do 54 if [ $LIGNE -eq 1 ]; then 55 cat <<- ENTETE 56 <thead> 57 <tr> 58 <td onclick="sortTable(1)" class="title">$(entree 2)</td> 59 <td onclick="sortTable(2)" class="start-date">$(entree 5)</td> 60 <td onclick="sortTable(3)" class="end-date">$(entree 6)</td> 61 <td onclick="sortTable(4)" class="number-of-issues"><!--$(entree 7)-->№</td> 62 <td onclick="sortTable(5)" class="city">$(entree 9)</td> 63 <td onclick="sortTable(6)" class="country">$(entree 10)</td> 64 <td onclick="sortTable(7)" class="language">$(entree 11)</td> 65 <td onclick="sortTable(8)" class="full-title">$(entree 3)</td> 66 <td onclick="sortTable(9)" class="type">$(entree 16)</td> 67 <td onclick="sortTable(10)" class="format">$(entree 8)</td> 68 <td onclick="sortTable(11)" class="frequency">$(entree 4)</td> 69 <td onclick="sortTable(12)" class="creators">$(entree 14)</td> 70 <td onclick="sortTable(13)" class="editor-in-chief">$(entree 13)</td> 71 <td onclick="sortTable(14)" class="publisher">$(entree 17)</td> 72 <td onclick="sortTable(15)" class="sources">$(entree 12)</td> 73 <td onclick="sortTable(16)" class="related-works">$(entree 15)</td> 74 <td onclick="sortTable(17)" class="comments">$(entree 16)</td> 75 </tr> 76 </thead> 77 78 ENTETE 79 80 else 81 cat <<- CORPS 82 <tr> 83 <td class="title">$(entree 2)</td> 84 <td class="start-date">$(entree 5)</td> 85 <td class="end-date">$(entree 6)</td> 86 <td class="number-of-issues">$(entree 7)</td> 87 <td class="city" $(entree 9) >$(entree 9 | unsure)</td> 88 <td class="country">$(entree 10)</td> 89 <td class="language">$(entree 11)</td> 90 <td class="full-title">$(entree 3)</td> 91 <td class="type">$(entree 16)</td> 92 <td class="format">$(entree 8)</td> 93 <td class="frequency">$(entree 4 | unsure)</td> 94 <td class="creators">$(entree 14)</td> 95 <td class="editor-in-chief">$(entree 13)</td> 96 <td class="publisher">$(entree 17)</td> 97 <td class="sources">$(entree 12)</td> 98 <td class="related-works">$(entree 15)</td> 99 <td class="comments">$(entree 16)</td> 100 </tr> 101 102 CORPS 103 104 fi 105 LIGNE=$(($LIGNE + 1)) 106 done < $DB 107 ) 108 </table> 109 110 $(cat src/templates/foot.html) 111 %