Various shell scripts for use on the RTC server. Not your official RTC stuff!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.9 KiB

#! /bin/bash
# newgit - lists latest changes in gitea
# Author: samhunter@rawtext.club
# with modifications by: hedy@rawtext.club
# https://git.rawtext.club/samhunter/rtc-shell-scripts
readonly PROGNAME="${0##*/}"
readonly VERSION="2.1"
# "borrowed" from ~hedy
case "$1" in
--help|-h)
cat <<END
Usage: $PROGNAME [ -hv | --help | --version | <gitea instance url> ]
Example:
Updates on git.rawtext.club:
$PROGNAME
Updates on tildegit:
$PROGNAME https://tildegit.org
END
exit
;;
--version|-v)
echo "$PROGNAME", v"$VERSION"
exit
;;
*)
site="${1:-https://git.rawtext.club}"
;;
esac
lynx -dump ${site}/explore/repos \
|awk '
BEGIN {
DEFAULT_FORMAT = "%-16.16s %-20.20s %-14.14s\n";
WIDE_FORMAT = "%-16.16s %-32.32s %-14.14s\n";
FORMAT=DEFAULT_FORMAT;
SECONDS_IN_DAY = 86400;
SECONDS_IN_HOUR = 3600;
SECONDS_IN_MINUTE = 60;
}
/___.*Sear/,/First.*Prev/ {
if ($0 !~ /https*:/ && $0 ~/\[[0-9].*\]/) {
l=$0;
gsub(/^[^\]].*\]/,"",l);
gsub(/ /,"",l);
split(l,la, /\//);
user = la[1];
repo = la[2];
next;
}
if($0 ~/Updated.*(seconds|minute|hour|day)/) {
when=$0
gsub(/^ *Updated /,"",when)
gsub(/ ago/,"",when)
split(when,wh,/ */);
if(wh[2] ~ "day")
tm = wh[1] * SECONDS_IN_DAY;
if(wh[2] ~ "hour")
tm = wh[1] * SECONDS_IN_HOUR;
if(wh[2] ~ "minute")
tm = wh[1] * SECONDS_IN_MINUTE;
if(tm > SECONDS_IN_DAY)
when = strftime("%Y-%m-%d 12:00", systime()-tm);
else
when = strftime("%Y-%m-%d %H:%M", systime()-tm);
printf(FORMAT, when, repo, user);
}
}'
# vim: ts=4 sw=4 expandtab