Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Cleanup and simplify the code for the recently added "wiki" command. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
decac09b7d246ca64cd916121ba74fe8 |
User & Date: | drh 2008-05-14 20:59:10.000 |
Context
2008-05-14
| ||
23:01 | added some help docs + TODO ... (check-in: cf5bbd92 user: stephan tags: trunk) | |
20:59 | Cleanup and simplify the code for the recently added "wiki" command. ... (check-in: decac09b user: drh tags: trunk) | |
20:26 | cleaned up error handling a bit, minor code style changes, s/import/commit/ ... (check-in: feee32d3 user: stephan tags: trunk) | |
Changes
Changes to src/wiki.c.
︙ | ︙ | |||
596 597 598 599 600 601 602 | @ up through the next </verbatim>. The <nowiki> tag @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } | < < < < < | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | @ up through the next </verbatim>. The <nowiki> tag @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } /* ** COMMAND: wiki ** ** Usage: %fossil wiki (export|commit|list) WikiName ** ** Run various subcommands to fetch wiki entries. ** |
︙ | ︙ | |||
635 636 637 638 639 640 641 | } n = strlen(g.argv[2]); if( n==0 ){ goto wiki_cmd_usage; } if( strncmp(g.argv[2],"export",n)==0 ){ | < | < | > > > | | < | | < < < < | | < | < | | < < < < < < | < < < < < < < < | < < < < < < | < | | < < < < > | < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < | | < | | < | | | | | | < | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | } n = strlen(g.argv[2]); if( n==0 ){ goto wiki_cmd_usage; } if( strncmp(g.argv[2],"export",n)==0 ){ char *wname; /* Name of the wiki page to export */ int rid; /* Artifact ID of the wiki page */ int i; /* Loop counter */ char *zBody = 0; /* Wiki page content */ Manifest m; /* Parsed wiki page content */ if( g.argc!=4 ){ usage("export PAGENAME"); } wname = g.argv[3]; 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", wname ); if( rid ){ Blob content; content_get(rid, &content); manifest_parse(&m, &content); if( m.type==CFTYPE_WIKI ){ zBody = m.zWiki; } } if( zBody==0 ){ fossil_fatal("wiki page [%s] not found",wname); } for(i=strlen(zBody); i>0 && isspace(zBody[i-1]); i--){} printf("%.*s\n", i, zBody); return; }else if( strncmp(g.argv[2],"commit",n)==0 ){ char *wname; if( g.argc!=4 ){ usage("commit PAGENAME"); } wname = g.argv[3]; fossil_fatal("wiki commit not yet implemented."); }else if( strncmp(g.argv[2],"delete",n)==0 ){ if( g.argc!=5 ){ usage("delete PAGENAME"); } fossil_fatal("delete not yet implemented."); }else if( strncmp(g.argv[2],"list",n)==0 ){ Stmt q; db_prepare(&q, "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" " ORDER BY lower(tagname)" ); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); printf( "%s\n",zName); } db_finalize(&q); }else { goto wiki_cmd_usage; } return; wiki_cmd_usage: usage("delete|export|commit|list ..."); } |