[ create a new paste ] login | about

Project: programmingpraxis
Link: http://programmingpraxis.codepad.org/DXzbpli1    [ raw code | fork ]

programmingpraxis - Plain Text, pasted on Jul 15:
export PRAXIS=/home/phil/praxis

awk ' # themes (page "themes")

BEGIN { FS = "\t"
        while (bash !~ /^number\t[1-9][0-9]*$/)
            getline
        split("Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec",
              monthname, ":") }

/^number\t/  { number = $2 }
/^file\t/    { file = $2 }
/^pubmon\t/  { pubmon = $2 }
/^pubday\t/  { pubday = $2 }
/^pubyear\t/ { pubyear = $2 }
/^title\t/   { title = $2 }
/^ptitle\t/  { ptitle = $2 }
/^blurb\t/   { blurb = $2 }
/^pblurb\t/  { pblurb = $2 }
/^exer\t/    { exer = $2 }
/^soln\t/    { soln = $2 }
/^extra\t/   { extra = $2 }
/^codepad\t/ { codepad = $2 }

# names[1..nthemes]              = sorted theme names
# counts[theme]                  = number of items in theme
# themes[theme,1..counts[theme]] = output line by theme/number

/^theme/ {
    counts[$2]++
    themes[$2,counts[$2]] =
    sprintf("<tr><td>&nbsp;</td><td>%d</td><td>%02d %s %d</td>" \
            "<td><a href=\"/%d/%02d/%02d/%s/\">%s</a>: \%s</td>"\
            "<td><a href=\"/%d/%02d/%02d/%s/\">exercise</a>" \
            "<a href=\"/%d/%02d/%02d/%s/%d/\">solution</a> "\
            "<a href=\"http://programmingpraxis.codepad.org/" \
            "%s\">codepad</a></td></tr>",
            number, pubday, monthname[pubmon], pubyear, pubyear,
            pubmon, pubday, file, title, blurb, pubyear, pubmon,
            pubday, file, pubyear, pubmon, pubday, file, soln, codepad) }

END {
    for (i in counts)
        names[++j] = i
    printf "<a name=\"top\" /><big><big>"
    n = asort(names)
    for (i=1; i<=n; i++)
        printf "<a href=\"#%s\">%s</a> (%d)%s",
               names[i], names[i], counts[names[i]],
               (i==n) ? "</big></big>\n" : " &middot; "
    printf "\n<table cellpadding=\"10\">\n"

    for (i=1; i<=n; i++) {
        printf "\n<tr><td colspan=\"6\"><a name=\"%s\" /><a href=\"#top\">" \
               "<big><big>%s</big></big></a></tr>\n", names[i], names[i]
        for (j=1; j<=counts[names[i]]; j++)
            printf "\n%s\n", themes[names[i],j] }
    printf "\n</table>\n" }

' $PRAXIS/praxis.info >$PRAXIS/pages/themes


Create a new paste based on this one


Comments: