#!/bin/csh -f
#
# Brent Chivers 2005/Jul/08
#
# From my webpage of LJ icon images, generate a new page
# of the HTML commands to imbed each image into a journal entry.
#
# Selecting the HTML next to a tabled image is a bizzare process.
#
# There seems to be a limit to the number of A-NAME= links;
# if there are too many, only the first ones work.
# [2005/Sept] That problem was something broken in Safari;
# Firefox has no problem with lots of links.
# (Safari also broke displaying all the content of the original page.)
#
# Assumes and string delimiters are always "". BDC 2005/Nov/13
# Allow for delimiters of '' or ``.
# ['' got too messy; dropped for now....]
#
# Ignore case making the sorted link list. BDC 2006/Oct/25
#
# Add $baseref to tags too if they don't start BDC 2007/Jan/06
# with "HTTP" (i.e. treat them the same way as IMG SRC tags).
# (Don't specify "http:" because that will fail on "https".)
#
# Set ALIGN=TOP (instead of LEFT) for LiveJournal smilies BDC 2007/Jan/19
# (identified by having images at http://stat.livejournal.com/img/).
#
# Changed the baseref from BDC 2009/Sep/07
# from "http://bdchivers.home.comcast.net/lj/"
# to "http://home.comcast.net/~bdchivers/lj/"
#
# Condense "lj/../photos" links to just "photos". BDC 2012/Aug/28
#
# Moved directory from "lj" to "icons" for new website. BDC 2016/Sep/10
#
# I changed the awk.copy-paste script to do ALIGN=RIGHT BDC 2018/Mar/17
# instead of LEFT in the output (since I actually want
# the icons aligned to the right far more often). This
# means LJ smilies changes are from RIGHT instead of LEFT.
# the next two lines can be uncommented for diagnostics
# set verbose # see commands before variable substitution
# set echo # see commands after variable substitution
unset histchars # get user's history characters out of the way
unalias * # get user's .cshrc stuff out of the way
## set nonomatch # don't require wildcard matches
set cmd_name = $0 # $0:t construction doesn't work!
set cmd_name = $cmd_name:t # the name of this command
# HTML generated cannot link relative to $dest page
# set baseref = "http://bdchivers.home.comcast.net/lj/"
set baseref = "http://bchivers.name/icons/"
set src = icons/index.html # icon collection web page
set head = icons/copy-paste.head # static beginning of icon-link HTML web page
set dest = icons/copy-paste.html # icon-link HTML web page
set tail = icons/copy-paste.tail # static ending of icon-link HTML web page
cat $head > $dest # start the new file
# count the images (I was curious)
set count = `grep -i '
.*//' -e 's/"/'"'/g" -e 's_.*_&_' >> $dest
echo "