1 # ===================================================================== 2 # blogger.getTemplate: BloggerAPI method. 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 # ===================================================================== 22 # Notes: 23 # 24 # TW uses a more elaborated template mechanism than Blogger, and the 25 # latter API is not expressive enough to fulfill the TW capabilities. 26 # This RPC2 method is therefore provided only for completeness but 27 # it is of very limited use; please consider it a proof-of-concept. 28 # 29 # Getting a template is intentionally unrestricted, as I see no 30 # security implications associated with that. 31 # ===================================================================== 32 33 # ===================================================================== 34 # Local variables and functions 35 # ===================================================================== 36 37 cgi.group = () 38 cgi.group.literal = () 39 cgi.tpl = tb # Default. 40 41 # ===================================================================== 42 # Main program 43 # ===================================================================== 44 45 csaGetArgs POST 46 47 . $CSA_ROOT/lib/group-stuff.rc 48 49 # If no custom template of the requested type exists then send the 50 # corresponding default one. 51 52 if (csaIsFullPath --exists --quiet $CSA_TPL_ROOT/$'cgi.tpl') { 53 tpl.include.tw.page = $CSA_TPL_ROOT/$'cgi.tpl'.html 54 } else tpl.include.tw.page = $tw_dstem/$'cgi.tpl'.html 55 56 csaMkTemp tpl.include.tw.rpc 57 58 # Make sure no-parse mode is used on the template body by prepending 59 # its name with '--', to make sure no CSA tags will be substituted 60 # and no sub-templates (such as the rpc2 section) will be included 61 # by _envtoxml() in the returned template data. 62 63 tpl.include.tw.page = --$'tpl.include.tw.page':p 64 65 echo '$[tpl.include.tw.page]' > $'tpl.include.tw.rpc' 66 67 ~ $status 0 || csaExit.fault 0003 cat 68 69 # I currently let anyone request a template, as I see no reason 70 # to restrict this operation to editors. 71 72 #if (~ $tpl_name tw-*) { 73 # 74 # # Page names beginning with tw-* are reserved for TW use, and usually 75 # # refer to views that do not correspond to actual pages on disk, so 76 # # we need to toggle unapplicable sections in templates. 77 # 78 # tpl.if.tw.ispage = '(::DEL:)' 79 # tpl.fi.tw.ispage = '(:DEL::)' 80 # tpl.if.tw.editor = '(::DEL:)' 81 # tpl.fi.tw.editor = '(:DEL::)' 82 #} 83 84 csaExit.ok 85 86 # End of program.