1 # ===================================================================== 2 # genArchives.awk: W-TW group yearly archive list applet. 3 # 4 # Copyright (c) 2007,2009 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 fmt = tmp = ""; i = 0; delete a 24 25 # build links to recent pages. 26 27 # Set output format string. 28 29 fmt = readfmt("tw-year-links") 30 gsub(/%/,"%%",fmt) # turn plain '%' into '%%'. 31 gsub(/\\/,"\\\\&",fmt) # turn '\' into '\\'. 32 gsub(/[\n\r]+/,"",fmt) # just in case. 33 34 # this format string is currently not customizable. 35 for (i=1; i<=3; i++) { 36 if (!sub(//,"%s",fmt)) fmt = fmt "" 37 } 38 39 # encode any extra markers. 40 gsub(//,"\\<tw:s/\\>",fmt) 41 42 fmt = fmt "\n" 43 44 g_uri = _rcget("tbl_group.g_uri") 45 46 tmp = "" # needed again later. 47 48 print "" # documentation. 49 50 i = 0 # to be reused! 51 } 52 53 /^\001/ { next } # skip table header, if any. 54 55 { 56 # p_vtime, p_descr 57 58 split($0,a,"\t") # split each record into fields. 59 60 # Pages with nil descriptions are excluded from this view. 61 if (a[2] ~ /^ *-/) next 62 63 sub(/^.*,/,"",a[1]) # strip ranking. 64 sub(/-.*/,"",a[1]) # retain only year no. 65 66 if (tmp == "") tmp = a[1] # first record. 67 68 if (a[1] != tmp) { 69 printf(fmt,ENVIRON["CSA_RPC_URI"] \ 70 "/" ENVIRON["CSA_LANG"] "/" g_uri "/4/" tmp,tmp,i) 71 i = 1 72 } 73 74 else i++ 75 76 tmp = a[1] 77 } 78 79 END { 80 # flush last record, if any. 81 if (NR > 1) 82 printf(fmt,ENVIRON["CSA_RPC_URI"] \ 83 "/" ENVIRON["CSA_LANG"] "/" g_uri "/4/" a[1],a[1],i) 84 } 85 86 # EOF