republique

helper scripts for www.republique-numerique.fr
git clone https://a3nm.net/git/republique/
Log | Files | Refs | README

commit 216af807c0b0bc71537caa8c69b1c9e64ab23ff0
parent 4fd299d083c8e23c504375bcda48256ec2feec05
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 14 Oct 2015 22:56:14 +0100

create tables

Diffstat:
.gitignore | 2++
fmt.awk | 8++++++++
head | 8++++++++
maketable.sh | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,2 +1,4 @@ __pycache__/ dump/ +tables/ +dump.tsv diff --git a/fmt.awk b/fmt.awk @@ -0,0 +1,8 @@ +BEGIN { FS="\t" } +{ + printf "<tr><td>%s</td>\n", $1; + printf "<td><a href=\"https://www.republique-numerique.fr/profile/user/%s\">%s</a></td>", $2, $2; + print "<td>", $3, "</td><td>", $4, "</td><td>" $5, "</td><td>", $6, "</td><td>"; + printf "<a href=\"%s\">%s</a></td></tr>", $7, $8, $8; +} + diff --git a/head b/head @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<html dir="ltr" xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>République numérique</title> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <meta name="author" content="Antoine Amarilli" /> + </head> + <body> diff --git a/maketable.sh b/maketable.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# parse TSV $1 and generate report in $2 + +HEADER="<tr><th>id</th><th>auteur</th><th>vote_pour</th><th>vote_mitige</th><th>vote_contre</th><th>vote_tot</th><th>prop</th>" + +cat head >$2/prop_pos.html +echo "<h1>Propositions par votes positifs décroissants</h1>" >> $2/prop_pos.html +echo "<table>" >> $2/prop_pos.html +echo "$HEADER" >> $2/prop_pos.html +grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | sort -k3,3nr | + awk -f ./fmt.awk >> $2/prop_pos.html +echo "</table></body></html>" >> $2/prop_pos.html + +cat head >$2/prop_tot.html +echo "<h1>Propositions par votes totaux décroissants</h1>" >> $2/prop_tot.html +echo "<table>" >> $2/prop_tot.html +echo "$HEADER" >> $2/prop_tot.html +grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | sort -k6,6nr | + awk -f ./fmt.awk >> $2/prop_tot.html +echo "</table></body></html>" >> $2/prop_tot.html + + +cat head >$2/modi_pos.html +echo "<h1>Modifications par votes positifs décroissants</h1>" >> $2/modi_pos.html +echo "<table>" >> $2/modi_pos.html +echo "$HEADER" >> $2/modi_pos.html +grep '^opinion/[0-9]*/version/[0-9]*\s' "$1" | sed 's_^[^\t]*/__' | + sort -k3,3nr | awk -f ./fmt.awk \ + >> $2/modi_pos.html +echo "</table></body></html>" >> $2/modi_pos.html + +cat head >$2/modi_tot.html +echo "<h1>Modifications par votes totaux décroissants</h1>" >> $2/modi_tot.html +echo "<table>" >> $2/modi_tot.html +echo "$HEADER" >> $2/modi_tot.html +grep '^opinion/[0-9]*/version/[0-9]*\s' "$1" | sed 's_^[^\t]*/__' | + sort -k6,6nr | awk -f ./fmt.awk \ + >> $2/modi_tot.html +echo "</table></body></html>" >> $2/modi_tot.html + + +cat head >$2/argu_pos.html +echo "<h1>Arguments par votes décroissants</h1>" >> $2/argu_pos.html +echo "<table>" >> $2/argu_pos.html +echo "$HEADER" >> $2/argu_pos.html +grep '^[^ ]*/argument/' "$1" | sed 's_^[^\t]*/__' | sort -k3,3nr | + awk -f ./fmt.awk \ + >> $2/argu_pos.html +echo "</table></body></html>" >> $2/argu_pos.html +