Fossil

Check-in [06cd311c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added --glob and --like options to /json/wiki/list, to filter the list server-side.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 06cd311c17551de784d5227d673e4e4642c3c37a
User & Date: stephan 2012-03-25 03:10:11.949
Context
2012-03-25
03:23
Added --html|-h option to /json/diff to retrieve HTML-marked-up diffs. ... (check-in: a15214e8 user: stephan tags: trunk)
03:10
Added --glob and --like options to /json/wiki/list, to filter the list server-side. ... (check-in: 06cd311c user: stephan tags: trunk)
01:35
reverted that switch to sqlite3_mprintf() - i did not realize that vmprintf() is implemented locally. Changed some %s to %t/%T. ... (check-in: bb05bf6d user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/json_wiki.c.
417
418
419
420
421
422
423

424

425
426
427
428
429
430
431
432
433
434










435


436
437
438
439
440
441
442

/*
** Implementation of /json/wiki/list.
*/
static cson_value * json_wiki_list(){
  cson_value * listV = NULL;
  cson_array * list = NULL;

  Stmt q;

  char const verbose = json_find_option_bool("verbose",NULL,"v",0);

  if( !g.perm.RdWiki && !g.perm.Read ){
    json_set_err(FSL_JSON_E_DENIED,
                 "Requires 'j' or 'o' permissions.");
    return NULL;
  }
  db_prepare(&q,"SELECT"
             " substr(tagname,6) as name"
             " FROM tag WHERE tagname GLOB 'wiki-*'"










             " ORDER BY lower(name)");


  listV = cson_value_new_array();
  list = cson_value_get_array(listV);
  while( SQLITE_ROW == db_step(&q) ){
    cson_value * v;
    if( verbose ){
      char const * name = db_column_text(&q,0);
      v = json_get_wiki_page_by_name(name,0);







>
|
>







|
|
|
>
>
>
>
>
>
>
>
>
>
|
>
>







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456

/*
** Implementation of /json/wiki/list.
*/
static cson_value * json_wiki_list(){
  cson_value * listV = NULL;
  cson_array * list = NULL;
  char const * zGlob = NULL;
  Stmt q = empty_Stmt;
  Blob sql = empty_blob;
  char const verbose = json_find_option_bool("verbose",NULL,"v",0);

  if( !g.perm.RdWiki && !g.perm.Read ){
    json_set_err(FSL_JSON_E_DENIED,
                 "Requires 'j' or 'o' permissions.");
    return NULL;
  }
  blob_append(&sql,"SELECT"
              " substr(tagname,6) as name"
              " FROM tag WHERE tagname GLOB 'wiki-*' ",
              -1);
  zGlob = json_find_option_cstr("glob",NULL,"g");
  if(zGlob && *zGlob){
    blob_appendf(&sql," AND name GLOB %Q ", zGlob);
  }else{
    zGlob = json_find_option_cstr("like",NULL,"l");
    if(zGlob && *zGlob){
      blob_appendf(&sql," AND name LIKE %Q ", zGlob);
    }
  }
  blob_append(&sql,"ORDER BY lower(name)", -1);
  db_prepare(&q,"%s", blob_str(&sql));
  blob_reset(&sql);
  listV = cson_value_new_array();
  list = cson_value_get_array(listV);
  while( SQLITE_ROW == db_step(&q) ){
    cson_value * v;
    if( verbose ){
      char const * name = db_column_text(&q,0);
      v = json_get_wiki_page_by_name(name,0);