1 # =====================================================================
2 # groupRecentChanges.awk: W-TW group recent-changes applet.
3 #
4 # Copyright (c) 2007,2008,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 = ""; delete a; delete a; delete f
24
25 # build links to recent pages.
26
27 fmt = readfmt("tw-recent-changes")
28 gsub(/%/,"%%",fmt) # turn plain '%' into '%%'.
29 gsub(/\\/,"\\\\&",fmt) # turn '\' into '\\'.
30 gsub(/[\n\r]+/,"",fmt) # just in case.
31 tmp = fmt
32
33 # Handle custom positioning of output tokens.
34 sub(/.*\[:/,_NULL,tmp); sub(/:].*/,_NULL,tmp)
35 tmp = _strip(tmp,_O_MIDDLE)
36 if (tmp !~ /^[0-3 ]+$/) tmp = "1 2 3"
37
38 # pad missing arg specs with "0".
39 if ((i=split(tmp,f," ")) < 3) {
40 while (i++ <= 3) tmp = tmp " 0"
41 i = split(tmp,f," ")
42 }
43
44 tmp = _NULL
45
46 for (j=1; j<=i; j++) {
47 if (j > 3) break # ignore excess arg specs.
48 if (!sub(//,"%s",fmt)) fmt = fmt ""
49 tmp = tmp " " f[j]
50 }
51
52 # encode any extra markers.
53 gsub(//,"\\<tw:s/\\>",fmt)
54
55 fmt = fmt "\n"
56
57 split(_strip(tmp),f," "); f[0] = 0
58
59 g_uri = _rcget("tbl_group.g_uri")
60
61 e[0] = _NULL
62 }
63
64 /^\001/ { next } # skip table header, if any.
65
66 {
67 # p_uri, p_name, p_mtime, p_modip, p_descr
68
69 split($0,a,"\t")
70
71 # Exclude hidden pages from this view. Note that this is now done
72 # directly by 'updatePage' before the input list is fed into this
73 # script, so that we always get the configured no. of entries on
74 # output even after skipping hidden/redirected pages (although
75 # restricted pages are still included, as explained in 'updatePage').
76 #
77 #if (a[5] ~ /^ *-/) next
78
79 e[1] = ENVIRON["CSA_RPC_URI"] "/" ENVIRON["CSA_LANG"] "/" g_uri "/" a[1]
80 e[2] = _xmlencode(a[2])
81
82 # Turn mtime back into simplified format for display.
83 sub(/T/," ",a[3])
84 e[3] = _xmlencode(substr(a[3],1,19))
85
86 printf(fmt,e[f[1]],e[f[2]],e[f[3]])
87 }
88
89 # EOF