Fossil

Check-in [6916054d]
Login

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
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/th_main.c.

139
140
141
142
143
144
145










































146
147
148
149
150
151
152
...
348
349
350
351
352
353
354

355
356
357
358
359
360
361
    Blob src;
    blob_init(&src, (char*)argv[1], argl[1]);
    wiki_convert(&src, 0, WIKI_INLINE);
    blob_reset(&src);
  }
  return TH_OK;
}











































/*
** TH command:      htmlize STRING
**
** Escape all characters of STRING which have special meaning in HTML.
** Return a new string result.
*/
................................................................................
    {"linecount",     linecntCmd,           0},
    {"hascap",        hascapCmd,            0},
    {"htmlize",       htmlizeCmd,           0},
    {"date",          dateCmd,              0},
    {"html",          putsCmd,              0},
    {"puts",          putsCmd,       (void*)1},
    {"wiki",          wikiCmd,              0},

  };
  if( g.interp==0 ){
    int i;
    g.interp = Th_CreateInterp(&vtab);
    th_register_language(g.interp);       /* Basic scripting commands. */
    for(i=0; i<sizeof(aCommand)/sizeof(aCommand[0]); i++){
      Th_CreateCommand(g.interp, aCommand[i].zName, aCommand[i].xProc,







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
    Blob src;
    blob_init(&src, (char*)argv[1], argl[1]);
    wiki_convert(&src, 0, WIKI_INLINE);
    blob_reset(&src);
  }
  return TH_OK;
}

/*
** TH command:      wikicontent WIKIPAGE_NAME FALLBACK_TEXT
**
** Output the contents of the wiki page named by the input string.
** If WIKIPAGE_NAME does not exist, then FALLBACK_TEXT is used, instead.
*/
static int wikiContentCmd(
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  if( argc!=3 ){
    return Th_WrongNumArgs(interp, "wikicontent WIKIPAGE_NAME FALLBACK_TEXT");
  }
  if( enableOutput ){
    int rid;
    Blob content;
    Manifest m;
    rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x"
                 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
                 " ORDER BY x.mtime DESC LIMIT 1",
                 argv[1]
                 );
    if( content_get(rid, &content) ){
      manifest_parse(&m, &content);
      if( m.type == CFTYPE_WIKI ){
        Th_SetResult(interp, m.zWiki, -1);
        manifest_clear(&m);
      }
      else {
        return TH_ERROR;
      }
    }
    else {
      Th_SetResult(interp, (char*)argv[2], argl[2]);
    }
  }
  return TH_OK; 
}

/*
** TH command:      htmlize STRING
**
** Escape all characters of STRING which have special meaning in HTML.
** Return a new string result.
*/
................................................................................
    {"linecount",     linecntCmd,           0},
    {"hascap",        hascapCmd,            0},
    {"htmlize",       htmlizeCmd,           0},
    {"date",          dateCmd,              0},
    {"html",          putsCmd,              0},
    {"puts",          putsCmd,       (void*)1},
    {"wiki",          wikiCmd,              0},
    {"wikicontent",   wikiContentCmd,       0},
  };
  if( g.interp==0 ){
    int i;
    g.interp = Th_CreateInterp(&vtab);
    th_register_language(g.interp);       /* Basic scripting commands. */
    for(i=0; i<sizeof(aCommand)/sizeof(aCommand[0]); i++){
      Th_CreateCommand(g.interp, aCommand[i].zName, aCommand[i].xProc,