diff --git a/tools/mkkudos.sh b/tools/mkkudos.sh index 3db6743..f88b48b 100755 --- a/tools/mkkudos.sh +++ b/tools/mkkudos.sh @@ -1,370 +1,370 @@ #!/bin/sh # Update the list of donors and a few other things. # # ==================================================================== # This org-mode snippet is used to insert the progress bar into a HTML # file: # # #+BEGIN_HTML #
#
#

 

#

# # # # # #

#

# #+END_HTML # # For the 2017 campaign new variables which work slightly different # are introduced: # # #+BEGIN_HTML #
# # a month #
#
#

# a month of # # needed #

#

+ # in one-time donations #

#

# Supporters #

# #+END_HTML # # To use it the code at "Campaign data" below needs to be adjusted as # well. # =================================================================== set -e LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH usage() { cat <&2 ;; esac shift done if [ $testmode = yes ]; then htdocs="/var/www/www/preview.gnupg.org/htdocs" else htdocs="/var/www/www/www.gnupg.org/htdocs" fi donors="$htdocs/donate/donors.dat" donations="$htdocs/donate/donations.dat" blogheadlinefile="/var/www/www/blog.gnupg.org/htdocs/headlines.txt" if [ ! -f "$donors" ]; then echo "mkkudos.sh: '$donors' not found" >&2; exit 1 fi if [ ! -f "$donations" ]; then echo "mkkudos.sh: '$donations' not found" >&2; exit 1 fi if [ ! -f "$blogheadlinefile" ]; then echo "mkkudos.sh: '$blogheadlinefile' not found" >&2; blogheadline="" else blogheadline=$(awk -F\| ' NR<=3 {printf "
  • %s
  • ", $1, $2} ' "$blogheadlinefile") fi tmp=$(head -1 "$donations") monyear=$(echo "$tmp" | awk -F: 'BEGIN { m[1] = "January"; m[2] = "February"; m[3] = "March"; m[4] = "April"; m[5] = "May"; m[6] = "June"; m[7] = "July"; m[8] = "August"; m[9] = "September"; m[10] = "October"; m[11] = "November"; m[12] = "December"; } {printf "%s %d", m[int($2)] , $1}') thisyear=$(echo "$tmp" | awk -F: '{print $1}') nyr=$(echo "$tmp" | awk -F: '{printf "%d", $9}') euroyr=$(echo "$tmp" | awk -F: '{printf "%d", int($10 + 0.5)}') recur_nyr=$(echo "$tmp" | awk -F: '{printf "%d", $13}') recur_euroyr=$(echo "$tmp" | awk -F: '{printf "%d", int($14 + 0.5)/12}') dontable=$(awk -F: <"$donations" -v thisyear="$thisyear" ' BEGIN { m[1] = "January"; m[2] = "February"; m[3] = "March"; m[4] = "April"; m[5] = "May"; m[6] = "June"; m[7] = "July"; m[8] = "August"; m[9] = "September"; m[10] = "October"; m[11] = "November"; m[12] = "December" ; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; printf "\n"; } NR==1 { nyear = $9; totalyear = int($10 + 0.5); } $1 != thisyear { printf "\n"; printf "\n"; printf "\n", thisyear; printf " \n", nyear; printf " \n", totalyear; printf "\n"; printf "
    Month#
    %d%d%d
    \n"; exit 0 } { printf "%s\n", m[int($2)]; printf " %d\n", $7; printf " %d\n", int($8 + 0.5); } ') # Campaign data # Watchout for the 9074 below which are the donations received before the # campaign start. goal="120000" recur_goal="15000" percent=$(echo "$euroyr:$goal" | awk -F: '{ p = (int($1)*100)/int($2); if(p > 100) { p = 100 }; printf "%d", p}') recur_percent=$(echo "$recur_euroyr:$recur_goal" \ | awk -F: '{ p = (int($1)*100)/int($2); if(p > 100) { p = 100 }; printf "%d", p}') for file in "$htdocs/donate/"kudos-????.html "$htdocs/donate/"kudos.html \ "$htdocs/donate/"index.html "$htdocs/donate/"index.??.html \ "$htdocs/"index.html do [ -f "$file" ] || continue if [ $force = no ]; then [ "$file" -ot "$donors" ] || continue fi if [ "$file" = "$htdocs/donate/"kudos.html ]; then year=$(date +%Y) else year=${file#$htdocs/donate/kudos-} year=${year%.html} fi [ $verbose = yes ] && echo "processing $file" >&2 [ -f "$file.tmp" ] && rm "$file.tmp" # We need gawk to use "%'d" in inprint gawk -F: -v year=$year -v donors="$donors" -v dontable="$dontable" \ -v monyear="$monyear" -v thisyear="$thisyear" \ -v euro="$euro" -v euroyr="$euroyr" \ -v nyr="$nyr" -v goal="$goal" -v percent="$percent" \ -v recur_nyr="$recur_nyr" -v recur_euroyr="$recur_euroyr" \ -v recur_goal="$recur_goal" -v recur_percent="$recur_percent" \ -v blogheadline="$blogheadline" \ <"$file" >"$file.tmp" ' // {indon=1; print; insert("") } // {indon=0} // {indon=1; print; insertsome("") } // {indon=0} // {indon=1; print; insert("goteo13") } // {indon=0} // {indon=1; print; print dontable } // {indon=0} // { printf " %s\n", monyear; next } // { printf " %d\n", thisyear; next } // { printf " %s €\n", euroyr; next } // { printf " %s\n", nyr; next } // { printf "%s €\n", euro; next } // { printf "goal: %s €\n", goal; next } // { printf "style=\"width: %d%%\"\n", percent; next } // { printf " %s\n", blogheadline; next } /A-CMPGN-RECUR-EURO=""/ { n = index($0,"\""); printf "%s%s\" A-CMPGN-RECUR-EURO=\"\"\n", substr($0,1,n), recur_euroyr; next } /A-CMPGN-RECUR-EURO-GOAL=""/ { n = index($0,"\""); printf "%s%s\" A-CMPGN-RECUR-EURO-GOAL=\"\"\n", substr($0,1,n), recur_goal; next } /A-CMPGN-RECUR-PERCENT=""/ { n = index($0,":"); printf "%s %s%\" A-CMPGN-RECUR-PERCENT=\"\"\n", substr($0,1,n), recur_percent; next } // { n = index($0,"%s €\n", substr($0,1,n), format_number(recur_euroyr); next } // { n = index($0,"%s €\n", substr($0,1,n), format_number(recur_goal); next } // { n = index($0,"%s €\n", substr($0,1,n), format_number( int(euroyr) - 9074 ); next } // { n = index($0,"%s\n", substr($0,1,n), format_number(recur_nyr); next } // { n = index($0,"%s\n", + printf "%s!--CMPGN-FLM-USD-->%s USD\n", substr($0,1,n), format_number( xflm ); next } !indon { print } function format_number (n) { buf = sprintf("%'"'"'d", int(n)); gsub(/,/, "\\ ", buf); return buf; } function insert (tag) { while (getline < donors) { if ( $0 ~ /^(#.*)?$/ ) continue; if ( $3 == "" ) continue; if ($1==year && $4==tag) { printf "
  • %s
  • \n", $3 } else if ($1==year && $4=="S") { printf "
  • %s*
  • \n", $3 } } close (donors) } function insertsome (tag) { i = 0 while (getline < donors) { if ( $0 ~ /^(#.*)?$/ ) continue; if ( $3 == "" ) continue; if ($4==tag) { data[i++] = $3 } else if ($4=="S") { data[i++] = $3 "*" } } close (donors) j = i > 16 ? ( i - 16 ) : 0 while (j < i) { printf "
  • %s
  • \n", data[j++] } } ' mv "$file.tmp" "$file" || echo "mkkudos.sh: error updating $file" >&2 done