Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | added command: wiki [export WikiName|list] |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5fb1152dab8160e5fd690c4d7e234dfa |
User & Date: | stephan 2008-05-14 19:51:18.000 |
Context
2008-05-14
| ||
20:02 | removed 2 remaining debug lines. Cleaned up help text. ... (check-in: 87a1a31d user: stephan tags: trunk) | |
19:51 | added command: wiki [export WikiName|list] ... (check-in: 5fb1152d user: stephan tags: trunk) | |
12:21 | Return a proper error message if the first line of an HTTP requested handed to the "http" command is blank. ... (check-in: 0a14f181 user: drh tags: trunk) | |
Changes
Changes to src/wiki.c.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code to do formatting of wiki text. */ #include <assert.h> #include "config.h" #include "wiki.h" /* ** Return true if the input string is a well-formed wiki page name. ** ** Well-formed wiki page names do not begin or end with whitespace, | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code to do formatting of wiki text. */ #include <assert.h> #include <ctype.h> #include "config.h" #include "wiki.h" /* ** Return true if the input string is a well-formed wiki page name. ** ** Well-formed wiki page names do not begin or end with whitespace, |
︙ | ︙ | |||
594 595 596 597 598 599 600 | @ <p>The <verbatim> tag disables all wiki and HTML markup @ up through the next </verbatim>. The <nowiki> tag @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 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 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | @ <p>The <verbatim> tag disables all wiki and HTML markup @ up through the next </verbatim>. The <nowiki> tag @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } void dump_blob_to_FILE( Blob * b, FILE * f ) { fwrite(blob_buffer(b), 1, blob_size(b), stdout); } /* ** COMMAND: wiki ** ** Usage: %fossil wiki (export|import) EntryName ** ** ** TODOS: ** ** export WikiName ?UUID? ?-f outfile? */ void wiki_cmd(void){ int n; db_find_and_open_repository(1); if( g.argc<3 ){ goto wiki_cmd_usage; } n = strlen(g.argv[2]); if( n==0 ){ goto wiki_cmd_usage; } if( strncmp(g.argv[2],"export",n)==0 ){ Stmt q; char *wname; Blob buf; int rid; char * sql; if( g.argc!=4 ){ usage("export EntryName"); } wname = g.argv[3]; //printf("exporting wiki entry %s\n",wname); rid = -1; sql = mprintf("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 ); printf("SQL=%s\n",sql); db_prepare(&q, "%z", sql ); while( db_step(&q) == SQLITE_ROW ){ rid = db_column_int(&q,0); break; } db_finalize(&q); if( -1 == rid ){ fprintf(stderr,"export error: wiki entry [%s] not found.\n",wname); exit(1); } fprintf(stderr,"export rid==%d\n", rid ); if( ! content_get(rid,&buf) ){ fprintf(stderr,"export error: content_get(%d) returned 0\n", rid ); exit(1); }else { /* Unfortunately, the content_get() routine does ALMOST what i want, but not quite. It is quite complex, so i don't want to fork a modified copy here. That's what all the skipping-over bits are for... We look for the first line starting with 'W', then expect ' NUMBER\n' immediately after that, followed by NUMBER bytes of plain blob content. */ int len; char * it; Blob numbuf; blob_zero(&numbuf); it = blob_buffer(&buf); while(*it){ if( *it != 'W' ){ ++it; while( *it ){ if( *it == '\n') { ++it; break; } ++it; } continue; } ++it; while( (*it) && (*it != '\n') ){ if( isspace(*it) ) { ++it; continue; } blob_append(&numbuf,it,1); ++it; } if( '\n' == *it ) ++it; if( 0 == blob_size(&numbuf) ){ fprintf(stderr, "export error: didn't find \"W NUMBER\" line in input!\n"); blob_zero(&buf); blob_zero(&numbuf); exit(1); } len = atoi(blob_buffer(&numbuf)); //fprintf(stderr,"Writing %d (%s) bytes...\n",len,blob_buffer(&numbuf)); blob_zero(&numbuf); fwrite(it,sizeof(char),len,stdout); blob_zero(&buf); return; } } blob_zero(&buf); return; }else if( strncmp(g.argv[2],"import",n)==0 ){ char *wname; if( g.argc!=4 ){ usage("import EntryName"); } wname = g.argv[3]; fprintf(stderr,"import not yet implemented.\n"); exit(1); }else if( strncmp(g.argv[2],"delete",n)==0 ){ if( g.argc!=5 ){ usage("delete WikiName"); } fprintf(stderr,"delete not yet implemented.\n"); exit(1); }else if( strncmp(g.argv[2],"list",n)==0 ){ Stmt q; db_prepare(&q, "SELECT substr(tagname, 6, 1000) 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|import|list [EntryName]"); } |