Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | New TH1 command: wikicontent
Placed in its own branch for posterity. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | th1_wikicontent_cmd |
Files: | files | file ages | folders |
SHA1: | 6916054dc87d1fca89cfd8183af9e3f4f9ebbd13 |
User & Date: | bcsmith 2010-10-10 19:07:30 |
Context
2010-10-10
| ||
19:07 |
New TH1 command: wikicontent
Placed in its own branch for posterity. Leaf check-in: 6916054d user: bcsmith tags: th1_wikicontent_cmd | |
2010-10-06
| ||
12:15 | SLL uses system-wide default CAs. Ticket [f696bc85f8b91d263f5bf4c5bbd2]. check-in: 8995df3a user: drh tags: trunk | |
Changes
Changes to src/th_main.c.
139 139 Blob src; 140 140 blob_init(&src, (char*)argv[1], argl[1]); 141 141 wiki_convert(&src, 0, WIKI_INLINE); 142 142 blob_reset(&src); 143 143 } 144 144 return TH_OK; 145 145 } 146 + 147 +/* 148 +** TH command: wikicontent WIKIPAGE_NAME FALLBACK_TEXT 149 +** 150 +** Output the contents of the wiki page named by the input string. 151 +** If WIKIPAGE_NAME does not exist, then FALLBACK_TEXT is used, instead. 152 +*/ 153 +static int wikiContentCmd( 154 + Th_Interp *interp, 155 + void *p, 156 + int argc, 157 + const char **argv, 158 + int *argl 159 +){ 160 + if( argc!=3 ){ 161 + return Th_WrongNumArgs(interp, "wikicontent WIKIPAGE_NAME FALLBACK_TEXT"); 162 + } 163 + if( enableOutput ){ 164 + int rid; 165 + Blob content; 166 + Manifest m; 167 + rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" 168 + " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" 169 + " ORDER BY x.mtime DESC LIMIT 1", 170 + argv[1] 171 + ); 172 + if( content_get(rid, &content) ){ 173 + manifest_parse(&m, &content); 174 + if( m.type == CFTYPE_WIKI ){ 175 + Th_SetResult(interp, m.zWiki, -1); 176 + manifest_clear(&m); 177 + } 178 + else { 179 + return TH_ERROR; 180 + } 181 + } 182 + else { 183 + Th_SetResult(interp, (char*)argv[2], argl[2]); 184 + } 185 + } 186 + return TH_OK; 187 +} 146 188 147 189 /* 148 190 ** TH command: htmlize STRING 149 191 ** 150 192 ** Escape all characters of STRING which have special meaning in HTML. 151 193 ** Return a new string result. 152 194 */ ................................................................................ 348 390 {"linecount", linecntCmd, 0}, 349 391 {"hascap", hascapCmd, 0}, 350 392 {"htmlize", htmlizeCmd, 0}, 351 393 {"date", dateCmd, 0}, 352 394 {"html", putsCmd, 0}, 353 395 {"puts", putsCmd, (void*)1}, 354 396 {"wiki", wikiCmd, 0}, 397 + {"wikicontent", wikiContentCmd, 0}, 355 398 }; 356 399 if( g.interp==0 ){ 357 400 int i; 358 401 g.interp = Th_CreateInterp(&vtab); 359 402 th_register_language(g.interp); /* Basic scripting commands. */ 360 403 for(i=0; i<sizeof(aCommand)/sizeof(aCommand[0]); i++){ 361 404 Th_CreateCommand(g.interp, aCommand[i].zName, aCommand[i].xProc,