pub / git_activity

Generates Github-style activity graphs as HTML
git clone https://src.jayvii.de/pub/git_activity.git
Home | Log | Files | Exports | Refs | README | RSS

commit c4aa889eb1a8a7041e5f40d6ba6cfb8d98485a5c
parent 643bbc78abf6a4f8341310bca4c3cb1ad93c602b
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Mon,  5 Aug 2024 15:21:41 +0200

feat: linear opacity scaling; smaller adjustments

Diffstat:
Mactivity.sh | 27+++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/activity.sh b/activity.sh @@ -4,7 +4,8 @@ # Configuration ---------------------------------------------------------------- -LANG="en" # ensure pretty names are always in english +# ensure pretty names are always in english +LANG="en" # Fetch Inputs ----------------------------------------------------------------- @@ -15,18 +16,28 @@ DIRS="$@" # HTML output function html_output { + # grab function input DTE="$1" CMT="$2" OPC="$3" + # if date is present, add it to the title if [[ ! -z $DTE ]]; then - TTL+=$(date --date "${CUR_TIME}-01" "+%b, %Y"); + TTL+=$(date --date "${DTE}-01" "+%b, %Y"); fi - if [[ ! -z $CMT ]]; then TTL+=": $CMT commits"; fi - if [[ $OPC -lt 10 ]]; then OPC=10; fi + # if date and comment are present, add separator to the title + if [[ ! -z $DTE ]] && [[ ! -z $CMT ]]; then + TTL+=": " + fi + # if comment is present, add it to the title + if [[ ! -z $CMT ]]; then TTL+="$CMT commits"; fi + # re-scale opacity linearly between 10-100 + OPC=$(((($OPC * 90) / 100) + 10)) + # create HTML arguments ID="activity-$DTE" CL="activitypoint" STL="opacity:calc($OPC/100);" ARGS="id=\"$ID\" class=\"activitypoint\" style=\"$STL\" title=\"$TTL\"" + # return HTML string printf "<span $ARGS>&#9632;</span>" } @@ -74,7 +85,7 @@ while [ $CUR_TIME != $MAX_TIME ]; do CUR_VAL=$(echo "$AGGREGATE" | grep $CUR_TIME | awk '{ print $1 }') # normalise current value [0, 100] - NRM_VAL=$((${CUR_VAL:-0} * 100 / $MAX_VAL)) + NRM_VAL=$((${CUR_VAL:-0} * 100 / ${MAX_VAL:-1})) # list data in variable # DATA+="$CUR_TIME ${CUR_VAL:-0} ${NRM_VAL:-5}\n" @@ -86,8 +97,8 @@ while [ $CUR_TIME != $MAX_TIME ]; do CUR_TIME=$(date --date "${CUR_TIME}-01 +1 month" +%Y-%m) # reset variables for next round - CUR_VAL="" - NRM_VAL="" + unset CUR_VAL + unset NRM_VAL done @@ -99,7 +110,7 @@ for LV in $(seq 0 25 100); do LND_VAL=$(($LV * $MAX_VAL / 100)) # Generate HTML - HTML+=$(html_output 'Legend' $LND_VAL $LV) + HTML+=$(html_output "" $LND_VAL $LV) done HTML+=" More</p>"