1 # =====================================================================
2 # pageTrackBacks.awk: W-TW page trackback 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 delete a; delete b # just in case.
24
25 # build links to recent pages.
26
27 # Set output format string.
28
29 fmt = readfmt("tw-page-trackbacks")
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
45 /^\001/ { next } # skip table header, if any.
46
47 {
48 # k_tbkurl, t_ctime, t_title, t_creip
49
50 split($0,a,"\t")
51
52 gsub(/ /,"%20",a[1]) # just in case.
53
54 out = sprintf(fmt,_localdate(a[2]),_xmlencode(a[1]),_xmlencode(a[3]))
55
56 i = split(out,b,/