Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added new "wiki create" command. Cleaned up the "wiki commit" code and added an option filename argument to both "wiki commit" and "wiki create". |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e03d1be55b3056e381dc76be4397cfc9 |
User & Date: | drh 2008-05-16 01:43:55.000 |
Context
2008-05-16
| ||
03:18 | added optional FILE arg to wiki export ... (check-in: 7adbf773 user: stephan tags: trunk) | |
01:43 | Added new "wiki create" command. Cleaned up the "wiki commit" code and added an option filename argument to both "wiki commit" and "wiki create". ... (check-in: e03d1be5 user: drh tags: trunk) | |
01:09 | Back out the "Home Page" configuration option added by [29374daa0d] ... (check-in: c51dd305 user: drh tags: trunk) | |
Changes
Changes to src/wiki.c.
︙ | ︙ | |||
598 599 600 601 602 603 604 | @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } /* | | | < < | > < < < < < | < < < < < < | < < | | | | > | | | | | | | > > | < < < > | | | > | | < | | | | > > > | | | 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 | @ disables all wiki formatting rules through the matching @ </nowiki> element. @ </ol> style_footer(); } /* ** Add a new wiki page to the respository. The page name is ** given by the zPageName parameter. isNew must be true to create ** a new page. If no previous page with the name zPageName exists ** and isNew is false, then this routine throws an error. ** ** The content of the new page is given by the blob pContent. */ int wiki_cmd_commit(char const * zPageName, int isNew, Blob *pContent){ Blob wiki; /* Wiki page content */ Blob cksum; /* wiki checksum */ int rid; /* artifact ID of parent page */ int nrid; /* artifact ID of new wiki page */ char *zDate; /* timestamp */ char *zUuid; /* uuid for rid */ 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", zPageName ); if( rid==0 && !isNew ){ fossil_fatal("no such wiki page: %s", zPageName); } if( rid!=0 && isNew ){ fossil_fatal("wiki page %s already exists", zPageName); } blob_zero(&wiki); zDate = db_text(0, "SELECT datetime('now')"); zDate[10] = 'T'; blob_appendf(&wiki, "D %s\n", zDate); free(zDate); blob_appendf(&wiki, "L %F\n", zPageName ); if( rid ){ zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); blob_appendf(&wiki, "P %s\n", zUuid); free(zUuid); } user_select(); if( g.zLogin ){ blob_appendf(&wiki, "U %F\n", g.zLogin); } blob_appendf( &wiki, "W %d\n%s\n", blob_size(pContent), blob_str(pContent) ); md5sum_blob(&wiki, &cksum); blob_appendf(&wiki, "Z %b\n", &cksum); blob_reset(&cksum); db_begin_transaction(); nrid = content_put( &wiki, 0, 0 ); db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); manifest_crosslink(nrid,&wiki); blob_reset(&wiki); content_deltify(rid,nrid,0); db_end_transaction(0); return 1; } /* ** COMMAND: wiki ** ** Usage: %fossil wiki (export|commit|list) WikiName ** ** Run various subcommands to fetch wiki entries. ** ** %fossil wiki export PAGENAME ** ** Sends the latest version of the PAGENAME wiki ** entry to stdout. ** ** %fossil wiki commit PAGENAME ?FILE? ** ** Commit changes to a wiki page from FILE or from standard. ** ** %fossil wiki create PAGENAME ?FILE? ** ** Create a new wiki page with initial content taken from ** FILE or from standard input. ** ** %fossil wiki list ** ** Lists all wiki entries, one per line, ordered ** case-insentively by name. ** ** TODOs: |
︙ | ︙ | |||
760 761 762 763 764 765 766 | if( zBody==0 ){ fossil_fatal("wiki page [%s] not found",zPageName); } for(i=strlen(zBody); i>0 && isspace(zBody[i-1]); i--){} printf("%.*s\n", i, zBody); return; }else | | > > | | > > > > > > | > > > | > > | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | if( zBody==0 ){ fossil_fatal("wiki page [%s] not found",zPageName); } 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 || strncmp(g.argv[2],"create",n)==0 ){ char *zPageName; Blob content; if( g.argc!=4 && g.argc!=5 ){ usage("commit PAGENAME ?FILE?"); } zPageName = g.argv[3]; if( g.argc==4 ){ blob_read_from_channel(&content, stdin, -1); }else{ blob_read_from_file(&content, g.argv[4]); } if( g.argv[2][1]=='r' ){ wiki_cmd_commit(zPageName, 1, &content); printf("Created new wiki page %s.\n", zPageName); }else{ wiki_cmd_commit(zPageName, 0, &content); printf("Updated wiki page %s.\n", zPageName); } blob_reset(&content); }else if( strncmp(g.argv[2],"delete",n)==0 ){ if( g.argc!=5 ){ usage("delete PAGENAME"); } fossil_fatal("delete not yet implemented."); }else |
︙ | ︙ |