#!/bin/csh -f # # Set the background color for day in the alco.html web page. # Arguments: n/nn day of the month; previous month if future day # +n/-n to set the date relative to today's date # color color name to set the color # XXXXXX 6-digit hex number to set the color # #XXXXXX 6-digit hex number to set the color # Default action is to set today's color to "grey". # Script can be linked to color names. # # List of color names, FYI: # http://www.w3schools.com/Html/html_colornames.asp # # Brent Chivers 2009/Feb/28 # # [A-F] are valid hex digits. 2009/Mar/08 # # date_name4 compiled (after re-installing OS). 2009/Dec/02 # # Linux grep and sed are in /bin, not /usr/bin (Darwin). 2011/Jan/07 # Home directory is no longer /Users/bchivers. # (Why didn't I use $HOME before?) # # Copy the (updated?) file to the web server. 2017/Jul/02 # # Added two more shades of yellow-green. 2018/Nov/18 # Added another shade of yellow-green. 2019/Jan/23 # Added light gray. 2019/Sep/28 # Added orange-red. 2021/Feb/11 # Orange-red was too close to red. #FF4500 -> #FF6800 2021/Jun/28 # Add yelora, yellora (yellow-orange) 2021/Aug/30 # Add "aqua" as a new link for the command. 2021/Sep/04 # Recognize "redd" for "red" (restricted "ed" editor). 2021/Nov/16 # Recognize "yelo" and "yelor" as yellora. 2022/Jan/25 ##! /bin/csh -fb # for setuid/setgid scripts (tsk) # set verbose # see commands before variable substitution # set echo # see commands after variable substitution unset histchars # get other users' history characters out of the way unalias * # get other users' .cshrc stuff out of the way ## set nonomatch # don't require wildcard matches # $0:t construction doesn't work! set cmd_name = $0 set cmd_name = $cmd_name:t # the name of this command # month strings must match makecalhtml.c months set months = ( "Jan" "Feb" "Mar" "Apr" "May" "June" "July" "Aug" "Sept" "Oct" "Nov" "Dec" ) # set file = "/Users/bchivers/webpages/bdchivers/alco_20" # until date_name4.c compiles.... set file = "$HOME/webpages/bdchivers/alco_" set ext = "html" set changes = 0 # changed anything? set offset = 0 # default day is today set color = "gray" # default color is "gray" set today = `~/bin/date_name4 $offset | tr - " " | /bin/sed 's/ 0/ /g'` switch ( $cmd_name ) # command name case alco: case grey: set color = "gray" # default: gray #808080 breaksw case lgray: case lgrey: case lightgray: case lightgrey: set color = "lightgray" # lightgray #D3D3D3 breaksw case yel: set color = "yellow" # bright yellow #FFFF00 breaksw case gold: # (name conflicts with the GNU ELF linker) case yo: case oy: case yelo: case yelor: case yelora: case yellora: case yellow-orange: case orange-yellow: set color = "gold" # gold #FFD700 breaksw case ora: case orange: set color = "darkorange" # dark orange #FF8C00 (preferred to orange #FFA500) breaksw case ored: case orared: case orangered: case orange-red: case redor: case redora: case redorange: case red-orange: # set color = "#FF4500" # between dark orange and full red #FF4500 set color = "#FF6800" # less red than #FF4500 breaksw case brown: set color = "sienna" # sienna #A0522D (preferred to brown #A52A2A) breaksw # case green: ## do not force green to lime # set color = "lime" # bright green #0000FF # breaksw # lime should be one of the link names case ltb: case sky: case skyblue: case lightblue: set color = "lightskyblue" # light sky blue #87CEFA (preferred to skyblue #87CEEB) breaksw case ltg: case ltgrn: set color = "lightgreen" # light green breaksw case bfo: case boffo: case boffoo: case greenyellow: case green-yellow: case yellow-green: case yellowgreen: case yelg: case yg: set color = "#B0FF00" # a bright greenish/yellow #B0FF00 breaksw case doffo: case doffoo: case yyg: set color = "#D0FF00" # a yellower greenish/yellow #D0FF00 -- less sober breaksw case eoffo: case eoffoo: case yyyg: set color = "#E0FF00" # an even yellower greenish/yellow #E0FF00 -- even less sober breaksw case foffo: case foffoo: case yyyyg: set color = "#F0FF00" # an even yellower yet greenish/yellow breaksw case red: # (name conflicts with the restricted ed editor.) case redd: # There is already another command named "red". case bad: set color = "#FF0000" # red #FF0000 breaksw default: set color = "$cmd_name" # hope user picked a valid color.... breaksw # (If it's not a valid color, the script endsw # shouldn't be linked to that name.) foreach arg ( $* ) switch ( $arg ) case [1-9]: case [1-3][0-9]: @ changes += 1 # we'll modify the page if ($arg > $today[3]) then # future date; must be last month @ month = $today[2] - 1 if ($month < 1) then # zero month; must be December last year set month = 12 @ year = $today[1] - 1 else # month OK, this year set year = $today[1] endif else # day is today or earlier this month set month = $today[2] set year = $today[1] endif # each year has its own file/web page set page = "$file$year[1].$ext" set month = $months[$month] set day = "$month $arg" # find the day in the right file and strip off everything around the background color set old_color = `/bin/grep ">$day<" "$page" | /bin/sed -e 's/.*BGCOLOR=//' -e 's/[ ].*//'` # echo change 1 # echo s/BGCOLOR=$old_color/BGCOLOR=\"$color\"/p /bin/ed $page << EnDoFeDiT />$day

$day<" "$page" | /bin/sed -e 's/.*BGCOLOR=//' -e 's/[ ].*//'` # echo change 2 # echo s/BGCOLOR=$old_color/BGCOLOR=\"$color\"/p /bin/ed $page << EnDoFeDiT />$day

$day<" "$page" | /bin/sed -e 's/.*BGCOLOR=//' -e 's/[ ].*//'` # echo change 3 # echo s/BGCOLOR=$old_color/BGCOLOR=\"$color\"/p /bin/ed $page << EnDoFeDiT />$day

$day<" "$page" | /bin/sed -e 's/.*BGCOLOR=//' -e 's/[ ].*//'` # echo change 4 # echo s/BGCOLOR=$old_color/BGCOLOR=\"$color\"/p /bin/ed $page << EnDoFeDiT />$day