tools: Add yearly stats to mkkudos.sh.
authorWerner Koch <wk@gnupg.org>
Fri, 17 Oct 2014 11:12:16 +0000 (13:12 +0200)
committerWerner Koch <wk@gnupg.org>
Fri, 17 Oct 2014 11:12:16 +0000 (13:12 +0200)
tools/mkkudos.sh
web/donate/kudos.org

index 3c42a8a..8e5ed96 100755 (executable)
@@ -8,6 +8,45 @@ htdocs="/var/www/www/www.gnupg.org/htdocs"
 donors="$htdocs/donate/donors.dat"
 donations="$htdocs/donate/donations.dat"
 
+
+usage()
+{
+    cat <<EOF
+Usage: $0 [OPTIONS]
+Options:
+       --force    Force re-creation of files.
+EOF
+    exit $1
+}
+
+
+force=no
+while [ $# -gt 0 ]; do
+    case "$1" in
+       # Set up `optarg'.
+       --*=*)
+           optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+           ;;
+       *)
+           optarg=""
+           ;;
+    esac
+
+    case $1 in
+       --force)
+           force=yes
+           ;;
+        --help)
+            usage 0
+            ;;
+       *)
+           usage 1 1>&2
+           ;;
+    esac
+    shift
+done
+
+
 if [ ! -f "$donors" ]; then
   echo "mkkudos.sh: '$donors' not found" >&2;
   exit 1
@@ -24,10 +63,14 @@ monyear=$(echo "$tmp" | awk -F: 'BEGIN { m[1] = "January";
       m[10] = "October"; m[11] = "November"; m[12] = "December"; }
       {printf "%s %d", m[$2] , $1}')
 euro=$(echo "$tmp" | awk -F: '{printf "%d Euro", int($8 + 0.5)}')
-
+euroyr=$(echo "$tmp" | awk -F: '{printf "%d Euro", int($10 + 0.5)}')
+n=$(echo "$tmp" | awk -F: '{printf "%d", $7}')
+nyr=$(echo "$tmp" | awk -F: '{printf "%d", $9}')
 
 for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html; do
-   [ "$file" -ot "$donors" ] || continue
+   if [ $force = no ]; then
+     [ "$file" -ot "$donors" ] || continue
+   fi
    if [ "$file" = "$htdocs/donate/"kudos.html ]; then
      year=$(date +%Y)
    else
@@ -37,7 +80,9 @@ for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html; do
    echo "processing $file" >&2
    [ -f "$file.tmp" ] && rm "$file.tmp"
    awk -F: -v year=$year -v donors="$donors" \
-           -v monyear="$monyear" -v euro="$euro" <"$file"  >"$file.tmp" '
+           -v monyear="$monyear" -v euro="$euro" -v euroyr="$euroyr" \
+           -v n="$n" -v nyr="$nyr" \
+            <"$file"  >"$file.tmp" '
      /<!--BEGIN-DONATIONS-->/ {indon=1; print; insert("") }
      /<!--END-DONATIONS-->/ {indon=0}
      /<!--BEGIN-DONATIONS_goteo13-->/ {indon=1; print; insert("goteo13") }
@@ -50,6 +95,18 @@ for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html; do
            printf "<!--INSERT-MONTH-EURO--> %s\n", euro;
            next
      }
+     /<!--INSERT-MONTH-N-->/ {
+           printf "<!--INSERT-MONTH-N--> %s\n", n;
+           next
+     }
+     /<!--INSERT-YEAR-EURO-->/ {
+           printf "<!--INSERT-YEAR-EURO--> %s\n", euroyr;
+           next
+     }
+     /<!--INSERT-YEAR-N-->/ {
+           printf "<!--INSERT-YEAR-N--> %s\n", nyr;
+           next
+     }
      !indon { print }
 
      function insert (tag) {
index fbee1a5..2e6e151 100644 (file)
 
 ** Donation summary
 
-#+HTML: <p>In
-#+HTML: <!--INSERT-MONTH-DATE-->
-#+HTML: we received
-#+HTML: <!--INSERT-MONTH-EURO-->
-#+HTML: of donations by credit card plus some more donations via Paypal.
-#+HTML: </p>
+#+HTML:<p>In
+#+HTML:<!--INSERT-MONTH-DATE--> October 2014
+#+HTML:we received
+#+HTML:<!--INSERT-MONTH-N--> 2
+#+HTML:donations of
+#+HTML:<!--INSERT-MONTH-EURO--> 28 Euro
+#+HTML:.  For the entire year we
+#+HTML:received a total of
+#+HTML:<!--INSERT-YEAR-EURO--> 52 Euro
+#+HTML:from
+#+HTML:<!--INSERT-YEAR-N--> 28
+#+HTML:donations.  Note that these numbers are only for donations via Stripe
+#+HTML:(credit card) and do not yet account for those received via Paypal.
+#+HTML:</p>
 
 
 | Year |   # |  \EUR | net \EUR |