#!/bin/csh -f # # Brent Chivers 2007/Jan/21 # # Find all LiveJournal Mood Icons and generate # HTML to copy/paste them into journal entries. # # Some icons are used for multiple moods, # so sort them to eliminate duplicates. # # This code works under MacOS X 10.4.8. It should # work under (or port easily to) other flavors of Unix. # If you have questions I will be glad to try to help. # (That sed and awk stuff on the actual URL retrieval is UGLY.) # # Add LJ Gifts. 2007/Feb/23 # Updating of the lj/gifts_list file has been moved to 2007/Feb/24 # a separate script (lj.gifts_list) for better control # of updating lj/mood_icons.html through the makefile. # ################################################################################################################################################################ # 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 ################################################################################################################################################################ # Add LJ Virtual Gifts: echo '

HTML to Copy/Paste Gift Icons for LiveJournal

' # output GIF and description in copy-paste table form # nest large/small pairs together in same table /usr/bin/awk -F' ' '\ /-large/ {printf ("\n", $2, $1, $2, $1, $1) ; next } \ /-small/ {printf ("
%s
<IMG SRC=\"%s\" ALT=\"%s\" TITLE=\"%s\" ALIGN=\"RIGHT\">
%s
<IMG SRC=\"%s\" ALT=\"%s\" TITLE=\"%s\" ALIGN=\"LEFT\">
\n", $2, $1, $2, $1, $1) ; next } \ {printf ("
%s
<IMG SRC=\"%s\" ALT=\"%s\" TITLE=\"%s\" ALIGN=\"ABSMIDDLE\">
\n", $2, $1, $2, $1, $1) }' lj/gifts_list echo '
' # Separate gift icons from following mood icons ################################################################################################################################################################ # Get LJ Mood Icons: echo '

HTML to Copy/Paste Mood Icons for LiveJournal

' echo '' echo '' echo '' echo '' # Get a list of mood themes. (All theme pages have the list, so just grab theme #1.) /usr/local/bin/lynx -source 'http://www.livejournal.com/moodlist.bml?moodtheme=1' | /usr/bin/grep "option value" | /usr/bin/sed -e "s/ selected='selected'//" -e 's/^$==' | /usr/bin/sort -n > /var/tmp/$cmd_name.$$ # Set list of mood numbers. (csh will choke if there are too many mood numbers.) set mood_numbers = `cut -f1 /var/tmp/$cmd_name.$$` # might want to edit the file to re-sequence the page of moods.... # Make links to each set of mood icons /usr/bin/awk -F' ' '{ printf ("%s ", $1, $2)}' /var/tmp/$cmd_name.$$ echo "
" # Separate links from mood icons foreach mood_number ( $mood_numbers ) # Make an internal link to the icon set echo '' # Get text name for icon set set mood_name = `/usr/bin/grep '^'$mood_number' ' /var/tmp/$cmd_name.$$ | /usr/bin/cut -f2` # Make a heading for the icon set echo "

$mood_name

" # Get page for each set of mood icons. # Filter out mode name (alt=) and image URL (livejournal.com/img/mood) /usr/local/bin/lynx -source 'http://www.livejournal.com/moodlist.bml?moodtheme='"$mood_number" | /usr/bin/tr '<' '\012' | /usr/bin/grep livejournal.com/img/mood/ | /usr/bin/sed -e 's/^.* alt='"'//" -e "s/' src="'"/ /' -e 's/" width=.*$//' | /usr/bin/sort -t' ' +1 | /usr/bin/awk -F' ' '\ NR == 1 { printf ("
%s", $2, $1) \ prev = $2 \ next } \ $2 == prev { printf (", %s", $1)} \ $2 != prev { printf ("\n
<IMG SRC=\"%s\" ALIGN=\"ABSMIDDLE\">
\n", prev) \ printf ("
%s", $2, $1) \ prev = $2 } \ END { printf ("\n
<IMG SRC=\"%s\" ALIGN=\"ABSMIDDLE\">
\n", prev) }' echo "
" # Separate links from mood icons end /bin/rm /var/tmp/$cmd_name.$$