1 # ===================================================================== 2 # groupYearList: list all pages which vtime falls in a specified year. 3 # 4 # Copyright (c) 2007-2011 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 # ===================================================================== 22 # Local variables and functions 23 # ===================================================================== 24 25 cgi.group = () 26 cgi.group.literal = () 27 cgi.subcat = () 28 cgi.subcat.literal = () 29 cgi.year = () 30 cgi.paging = 0 # default is no paging. 31 32 # ===================================================================== 33 # Main program 34 # ===================================================================== 35 36 # Load call arguments. 37 csaGetArgs GET 38 39 ~ $'cgi.paging' 0 && csaTrue $TNS_PAGER_DEFAULT && cgi.paging = 1 40 41 . $CSA_ROOT/lib/group-stuff.rc 42 43 . $CSA_ROOT/lib/group-editor.rc 44 45 # Check required args. 46 ~ $'cgi.year' () && csaExit.fault 0041 cgi.year 47 48 # Set template vars to their final values. 49 tpl.var.tw.page = tw-group-yearlist 50 tpl.var.tw.page.object = $'tpl.var.tw.page' 51 tpl.var.tw.year = $'cgi.year' 52 tpl.var.html.title = $'tpl.var.tw.group'/$'tpl.var.tw.page' 53 54 if (csaIsFullPath --exists --quiet $CSA_TPL_ROOT/tw-group-yearlist.txt) { 55 # custom template. 56 tpl.include.html.body = $CSA_TPL_ROOT/tw-group-yearlist.txt 57 } else { 58 # default template. 59 tpl.include.html.body = $tw_dstem/tw-group-yearlist.txt 60 } 61 62 . $CSA_ROOT/lib/tpl-stuff.rc 63 64 ~ $'cgi.subcat' too.short && cgi.subcat = () 65 66 csaMkTemp tpl.include.tw.page 67 68 # This view is always sorted by 'vtime', regardless of any ranking value 69 # associated with the latter. 70 71 awktable -i $tw_gstem/page+dat '-vyear_=^([0-9],)?'$'cgi.year'- -- ' 72 73 BEGIN {print "\001p_vtime\t\001p_name\t\001p_uri\t\001p_descr"} 74 75 # Handle page expiration dates, accounting for older 76 # versions of page+dat which may lack that field. 77 p_etime/=1 { 78 # Set default expiration date. 79 if ($p_etime == "") $p_etime = "9999-12-31 23:59:59" 80 if ("'$CSA_TIME_ISO'" >= $p_etime && \ 81 $p_descr !~ /^ *-/) $p_descr = "-" $p_descr 82 } 83 84 # Explicit exclusions from static views apply here too, even if editor. 85 $p_descr ~ /^ *!/ {next} 86 87 # Exclude redirected pages if non-editor. In fact this test 88 # may be questionable here so it is currently not done. 89 #$p_descr ~ /\(:redirect / && ENVIRON["TNS_AUTH_GRP"] !~ /,editor,/{next} 90 91 # Unconditionally exclude hidden pages with no title, as they are 92 # to be considered logically deleted and the editor will only be 93 # able to edit them by calling groupPageMap. 94 $p_descr ~ /^ *-[- ]*$/ {next} 95 96 # Exclude hidden pages (with non-empty title) if non-editor. 97 $p_descr ~ /^ *-[- ]*[^- ]/ && ENVIRON["TNS_AUTH_GRP"] !~ /,editor,/{next} 98 99 # Exclude restricted pages unless authorized user or editor. 100 { auth_ = "(,editor,|," $p_allow ",)" } 101 $p_allow != "" && ENVIRON["TNS_AUTH_GRP"] !~ auth_ {next} 102 103 { 104 # Exclude pages non belonging into the specified subcat, if any. 105 if ("'$'cgi.subcat'^'" != "" && $k_page !~ /^'$'cgi.subcat'^'\./) next 106 107 sub(/^.*,/,"",$p_vtime) 108 if($p_vtime ~ year_) print $p_vtime,$p_name,$p_uri,$p_descr 109 110 }' | sorttable -r p_vtime > $'tpl.include.tw.page' 111 112 csaStatus || csaExit.fault 0003 getcolumn/awktable/sorttable 113 114 # Static views do not correspond to actual pages on disk, 115 # so we need to toggle unapplicable sections in templates. 116 117 tpl.if.tw.ispage = '(::DEL:)' 118 tpl.fi.tw.ispage = '(:DEL::)' 119 tpl.if.tw.printable = '(::DEL:)' 120 tpl.fi.tw.printable = '(:DEL::)' 121 tpl.if.tw.isview = () 122 tpl.fi.tw.isview = () 123 124 csaExit.ok --table $'tpl.include.tw.page' $tpl_file 125 126 # End of program.