1 # ===================================================================== 2 # exit-stuff.rc: provide local code to be executed by csaExit.{ok,fault} 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 # ===================================================================== 22 # Local variables and functions 23 # ===================================================================== 24 25 if (~ $CSA_TPL_ROOT /* && ~ $tw_dstem /*) { 26 27 # Style of response pages can be set in group+cf to be either 28 # 'blog' or 'wiki' (default). That is, 'tpl.{if,fi}.tw.blog' 29 # tags must delimit wiki-only stuff in templates, while 30 # 'tpl.{if,fi}.tw.wiki' tags must delimit blog-only stuff. 31 32 if (~ $TNS_TW_STYLE blog) { 33 tpl.if.tw.blog = () 34 tpl.fi.tw.blog = () 35 tpl.if.tw.wiki = '(::DEL:)' 36 tpl.fi.tw.wiki = '(:DEL::)' 37 } else { 38 tpl.if.tw.blog = '(::DEL:)' 39 tpl.fi.tw.blog = '(:DEL::)' 40 tpl.if.tw.wiki = () 41 tpl.fi.tw.wiki = () 42 } 43 } 44 45 # Define group-level static views. 46 47 if (~ $tw_gstem /*) { 48 49 tpl.include.tw.recent.links = $tw_gstem/recent-links+xml 50 tpl.include.tw.recent.cmts = $tw_gstem/recent-comments+xml 51 tpl.include.tw.year.links = $tw_gstem/year-links+xml 52 tpl.include.tw.group.cat = $tw_gstem/cat-links+xml 53 tpl.include.tw.group.tag = $tw_gstem/tag-cloud+xml 54 tpl.include.tw.group.cal = \ 55 $tw_gstem/cal-$CSA_TIME_LOCAL(1)^-$CSA_TIME_LOCAL(2)^+xml 56 57 # Test for the actual subcat file existence before setting the 58 # relevant include var, because some of the programs (such as 59 # groupPageMap) may use partial cgi.subcat strings for 60 # pattern-marching purposes. 61 62 ~ $'cgi.subcat' [a-z]* && csaIsFullPath --exists --quiet \ 63 $tw_gstem/$'cgi.subcat'-recent-links+xml && 64 tpl.include.tw.subcat.recent.links = \ 65 $tw_gstem/$'cgi.subcat'-recent-links+xml 66 } 67 68 # Define actions depending on call arguments. 69 70 if (~ $($#*) fault) { 71 72 # Handle selected custom error pages. Beginning with CSA version 73 # 1.1.5-rc34 the 'back' argument of CSA_EXIT_SCRIPT can also be 74 # specified directly as an argument of 'csaExit.fault', which 75 # is more convenient. It is currently still necessary to specify 76 # it explicitly for other exit types, such as 'csaExit.needauth' 77 # and possibly others. 78 79 if (~ $1 back) { 80 tns1 = $2 81 if (csaIsFullPath --exists --quiet \ 82 $CSA_TPL_ROOT/tw-nav-back.txt) { 83 # custom "back" action template. 84 tpl.include.nav.next = $CSA_TPL_ROOT/tw-nav-back.txt 85 } else { 86 # default "back" action template. 87 tpl.include.nav.next = $tw_dstem/tw-nav-back.txt 88 } 89 } else tns1 = $1 90 91 switch ($tns1) { 92 case 401 93 tns2 = TNS_REDIRECT_$tns1 94 ~ $$tns2 http://* https://* && csaExit.location $$tns2 95 } 96 } 97 98 if (~ $($#*) fault && ~ $1 back) { 99 100 # Handle selected custom error pages. 101 switch ($2) { 102 case 401 103 tns1 = TNS_REDIRECT_$2 104 ~ $$tns1 http://* https://* && csaExit.location $$tns1 105 } 106 107 # Make sure that all the required variables contain suitable values 108 # and silently ignore the request if they don't. Note that I do not 109 # provide any "back" buttons on errors caused by idempotent requests, 110 # not to mislead the user by taking her to an unappropriate page. 111 112 if (!csaIsIdempotent && ~ $CSA_TPL_ROOT /* && ~ $tw_dstem /*) { 113 114 if (csaIsFullPath --exists --quiet $CSA_TPL_ROOT/tw-nav-back.txt) { 115 # custom back" action template. 116 tpl.include.nav.next = $CSA_TPL_ROOT/tw-nav-back.txt 117 } else { 118 # custom back" action template. 119 tpl.include.nav.next = $tw_dstem/tw-nav-back.txt 120 } 121 } 122 123 } else { 124 125 # Set XML-RPC response envelope if unset. 126 if (~ $($#*) ok && ~ $CSA_PGM(1) CSA2 && ~ $CSA_RDF_ORB /dev/null) { 127 128 # Set a generic positive response body if the application didn't 129 # set a more specific one. 130 131 if (~ $'tpl.include.tw.rpc' /dev/null) { 132 csaMkTemp tpl.include.tw.rpc 133 echo '$[CSA_RPC2_OK]' > $'tpl.include.tw.rpc' 134 } else CSA_RDF_ORB = $CSA_ROOT/lib/default/tw-response.rpc2 135 } 136 } 137 138 # End of program.