1 # ===================================================================== 2 # genCalendar.awk: W-TW calendar applet generator. 3 # 4 # Copyright (c) 2007,2008 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 BEGIN { 22 23 cal=tmp=""; i=j=x=y=0; delete a 24 25 url = ENVIRON["CSA_RPC_URI"] "/" \ 26 ENVIRON["CSA_LANG"] "/" _rcget("tbl_group.g_uri") "/" 27 } 28 29 /^\001/ { next } # skip table header, if any. 30 31 { 32 # p_uri, p_vtime, p_descr 33 34 split($0,a,"\t") # split each record into fields. 35 36 # Pages with nil descriptions are excluded from this view. 37 if (a[3] ~ /^ *-/) next 38 39 # strip ranking. 40 sub(/^.*,/,"",a[2]) 41 42 # retain only day no. 43 sub(/.*-/,"",a[2]); sub(/ .*/,"",a[2]) 44 45 a[2]/=1 # drop any leading "0" 46 47 # retain only the most recent link for a day. 48 if (page[a[2]] == "") page[a[2]] = a[1] 49 } 50 51 END { 52 while (getline tmp < ENVIRON["gencal_cal"] > 0) { 53 j=0 54 sub(/^ */,"",tmp); sub(/ *$/,"",tmp) 55 if (tmp == "") break 56 # turn "april" into "April", etc. 57 if (++i==1) cal = "