1 # ===================================================================== 2 # mtRecentPostTitles.awk: Movable Type API 3 # 4 # Copyright (c) 2008 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 24 25 #page_dir = _rcget("tw_gstem") 26 27 # I use the unixified group name as a URI here, so that 28 # blogger.getRecentPosts does not need to read the actual group 29 # record into memory. Fortunately the TW design provides enough 30 # flexibility :-) 31 32 g_name = _rcget("cgi.group") 33 34 printf("\n") 35 } 36 37 /^\001/ { next } # skip table header, if any. 38 39 { 40 # Process each input record in turn. 41 42 # k_page,p_ctime,p_name,p_creau,p_uri,\ 43 # p_descr,p_vtime,p_modau,p_tags,p_allow,k_node,p_link 44 45 split($0,a,"\t") # split each record into fields. 46 47 if (a[4] == _NULL) a[4] = _nlsmap(_NULL,"anonymous") 48 49 # Fix 'ctime' to meet XML-RPC specs. 50 gsub(/-/,"",a[2]); sub(/ /,"T",a[2]) 51 52 # Load each page body in turn. This used to be necessary to check 53 # whether a page was logically deleted, but given the new mechanism 54 # whereby a deleted page MUST have is p_descr field set to a single 55 # hyphen, it will already have been excluded from the input of this 56 # script, so this further costly test is no longer necessary. 57 # 58 #page = page_dir "/" a[1] "+wki" 59 #value = _NULL 60 #while (getline tmp1 < page > 0) value = value tmp1; close(page) 61 # 62 # skip empty pages, as they are to be considered as logically deleted. 63 #if (value !~ /(>[^<>]+|[^<>]+<)/) next 64 65 if (_rcget("cgi.numeric",1) == _NULL) 66 id = "" ENVIRON["CSA_LANG"] "/" g_name "/" a[1] "" 67 else id = "" a[11] "" 68 69 print "\n\n" \ 70 "\n" \ 71 "postid\n" \ 72 "" id "\n" \ 73 "\n" \ 74 "\n" \ 75 "userid" \ 76 "" a[4] "" \ 77 "\n" \ 78 "\n" \ 79 "title" \ 80 "" _xmlencode(a[6]) "" \ 81 "\n" \ 82 "\n" \ 83 "dateCreated" \ 84 "" a[2] "" \ 85 "" 86 87 printf("") 88 89 } 90 91 END { 92 93 print "\n\n" 94 } 95 96 # EOF