Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [c541b6e734] Move attachment command from wiki.c to attach.c |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | technoteattachcli |
Files: | files | file ages | folders |
SHA1: |
64a5ef28e5e69c6dbed8e2d4575023e0 |
User & Date: | dave.vines 2016-01-05 08:40:09 |
Context
2016-01-05
| ||
10:12 | [c541b6e734] Remove unintended white space change in wiki.c ... (check-in: d4dc7ad8 user: dave.vines tags: technoteattachcli) | |
08:40 | [c541b6e734] Move attachment command from wiki.c to attach.c ... (check-in: 64a5ef28 user: dave.vines tags: technoteattachcli) | |
08:34 | [c541b6e734] Move attachment from wiki subcommand to top level command ... (check-in: 16f864af user: dave.vines tags: technoteattachcli) | |
Changes
Changes to src/attach.c.
︙ | ︙ | |||
677 678 679 680 681 682 683 | } if( cnt ){ @ </ul> } db_finalize(&q); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 747 748 749 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 | } if( cnt ){ @ </ul> } db_finalize(&q); } /* ** COMMAND: attachment* ** ** Usage: %fossil attachment add ?PAGENAME? FILENAME [-t|--technote DATETIME ] ** ** Add an attachment to an existing wiki page or tech note. One of ** PAGENAME or DATETIME must be specified. ** */ void attachment_cmd(void){ int n; db_find_and_open_repository(0, 0); if( g.argc<3 ){ goto attachment_cmd_usage; } n = strlen(g.argv[2]); if( n==0 ){ goto attachment_cmd_usage; } if( strncmp(g.argv[2],"add",n)==0 ){ const char *zPageName; /* Name of the wiki page to attach to */ const char *zFile; /* Name of the file to be attached */ const char *zETime; /* The name of the technote to attach to */ Manifest *pWiki = 0; /* Parsed wiki page content */ char *zBody = 0; /* Wiki page content */ int rid; const char *zTarget; /* Target of the attachment */ Blob content; /* The content of the attachment */ zETime = find_option("technote","t",1); if( !zETime ){ if( g.argc!=5 ){ usage("attachment add PAGENAME FILENAME"); } zPageName = 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", zPageName ); if( (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 ){ zBody = pWiki->zWiki; } if( zBody==0 ){ fossil_fatal("wiki page [%s] not found",zPageName); } zTarget = zPageName; zFile = g.argv[4]; }else{ if( g.argc!=4 ){ usage("attachment add FILENAME --technote DATETIME"); } rid = db_int(0, "SELECT objid FROM event" " WHERE datetime(mtime)=datetime('%q') AND type='e'" " ORDER BY mtime DESC LIMIT 1", zETime ); if( (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 ){ zBody = pWiki->zWiki; } if( zBody==0 ){ fossil_fatal("technote [%s] not found",zETime); } zTarget = db_text(0, "SELECT substr(tagname,7) FROM tag WHERE tagid=(SELECT tagid FROM event WHERE objid='%d')", rid ); zFile = g.argv[3]; } blob_read_from_file(&content, zFile); user_select(); attach_commit( zFile, /* The filename of the attachment */ zTarget, /* The artifact uuid to attach to */ blob_buffer(&content), /* The content of the attachment */ blob_size(&content), /* The length of the attachment */ 0, /* No need to moderate the attachment */ "" /* Empty attachment comment */ ); if( !zETime ){ fossil_print("Attached %s to wiki page %s.\n", zFile, zPageName); }else{ fossil_print("Attached %s to tech note %s.\n", zFile, zETime); } }else{ goto attachment_cmd_usage; } return; attachment_cmd_usage: usage("attachment add ?PAGENAME? FILENAME [-t|--technote DATETIME ]"); } |
Changes to src/wiki.c.
︙ | ︙ | |||
1336 1337 1338 1339 1340 1341 1342 | goto wiki_cmd_usage; } return; wiki_cmd_usage: usage("export|create|commit|list ..."); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1336 1337 1338 1339 1340 1341 1342 | goto wiki_cmd_usage; } return; wiki_cmd_usage: usage("export|create|commit|list ..."); } |