Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch technoteattachcli Through [d4dc7ad8dc] Excluding Merge-Ins
This is equivalent to a diff from d891af8385 to d4dc7ad8dc
|
2016-03-13
| ||
| 23:55 | Merged trunk for changes since January and test suite improvements. check-in: 8fa24960ac user: rberteig tags: technoteattachcli | |
|
2016-01-05
| ||
| 10:12 | [c541b6e734] Remove unintended white space change in wiki.c check-in: d4dc7ad8dc user: dave.vines tags: technoteattachcli | |
| 08:40 | [c541b6e734] Move attachment command from wiki.c to attach.c check-in: 64a5ef28e5 user: dave.vines tags: technoteattachcli | |
|
2016-01-02
| ||
| 10:34 | Create new branch named "technoteattachcli" check-in: 5712fa8f13 user: dave.vines tags: technoteattachcli (unpublished) | |
|
2016-01-01
| ||
| 17:30 | Update the built-in SQLite to the second beta for 3.10.0. check-in: 987a80ef06 user: drh tags: trunk | |
|
2015-12-31
| ||
| 16:10 | Fix a harmless compiler warning in an assert() in delta.c. check-in: d891af8385 user: drh tags: trunk | |
| 16:06 | Add the ability to have attachments on technotes. Add command-line support for technotes in the "fossil wiki" command. check-in: 045deb27ce user: drh tags: trunk | |
Changes to src/attach.c.
| ︙ | ︙ | |||
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
rid = content_put(pAttach);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
}
manifest_crosslink(rid, pAttach, MC_NONE);
}
/*
** WEBPAGE: attachadd
** Add a new attachment.
**
** tkt=TICKETUUID
** page=WIKIPAGE
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
rid = content_put(pAttach);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
}
manifest_crosslink(rid, pAttach, MC_NONE);
}
/*
** Commit a new attachment into the repository
*/
void attach_commit(
const char *zName, /* The filename of the attachment */
const char *zTarget, /* The artifact uuid to attach to */
const char *aContent, /* The content of the attachment */
int szContent, /* The length of the attachment */
int needModerator, /* Moderate the attachment? */
const char *zComment /* The comment for the attachment */
){
Blob content;
Blob manifest;
Blob cksum;
char *zUUID;
char *zDate;
int rid;
int i, n;
int addCompress = 0;
Manifest *pManifest;
db_begin_transaction();
blob_init(&content, aContent, szContent);
pManifest = manifest_parse(&content, 0, 0);
manifest_destroy(pManifest);
blob_init(&content, aContent, szContent);
if( pManifest ){
blob_compress(&content, &content);
addCompress = 1;
}
rid = content_put_ex(&content, 0, 0, 0, needModerator);
zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_zero(&manifest);
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' || zName[i]=='\\' ) n = i+1;
}
zName += n;
if( zName[0]==0 ) zName = "unknown";
blob_appendf(&manifest, "A %F%s %F %s\n",
zName, addCompress ? ".gz" : "", zTarget, zUUID);
while( fossil_isspace(zComment[0]) ) zComment++;
n = strlen(zComment);
while( n>0 && fossil_isspace(zComment[n-1]) ){ n--; }
if( n>0 ){
blob_appendf(&manifest, "C %#F\n", n, zComment);
}
zDate = date_in_standard_format("now");
blob_appendf(&manifest, "D %s\n", zDate);
blob_appendf(&manifest, "U %F\n", login_name());
md5sum_blob(&manifest, &cksum);
blob_appendf(&manifest, "Z %b\n", &cksum);
attach_put(&manifest, rid, needModerator);
assert( blob_is_reset(&manifest) );
db_end_transaction(0);
}
/*
** WEBPAGE: attachadd
** Add a new attachment.
**
** tkt=TICKETUUID
** page=WIKIPAGE
|
| ︙ | ︙ | |||
320 321 322 323 324 325 326 |
zTkt, zTkt);
}
if( zFrom==0 ) zFrom = mprintf("%s/home", g.zTop);
if( P("cancel") ){
cgi_redirect(zFrom);
}
if( P("ok") && szContent>0 && (goodCaptcha = captcha_is_correct()) ){
| < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < | < | < < < < < < < < < < < < | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
zTkt, zTkt);
}
if( zFrom==0 ) zFrom = mprintf("%s/home", g.zTop);
if( P("cancel") ){
cgi_redirect(zFrom);
}
if( P("ok") && szContent>0 && (goodCaptcha = captcha_is_correct()) ){
int needModerator = (zTkt!=0 && ticket_need_moderation(0)) ||
(zPage!=0 && wiki_need_moderation(0));
const char *zComment = PD("comment", "");
attach_commit(zName, zTarget, aContent, szContent, needModerator, zComment);
cgi_redirect(zFrom);
}
style_header("Add Attachment");
if( !goodCaptcha ){
@ <p class="generalError">Error: Incorrect security code.</p>
}
@ <h2>Add Attachment To %s(zTargetType)</h2>
|
| ︙ | ︙ | |||
666 667 668 669 670 671 672 |
}
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/info.c.
| ︙ | ︙ | |||
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 |
);
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
const char *zUser = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zType = db_column_text(&q, 3);
const char *zUuid = db_column_text(&q, 4);
if( cnt>0 ){
@ Also
}
if( zType[0]=='w' ){
@ Wiki edit
objType |= OBJTYPE_WIKI;
}else if( zType[0]=='t' ){
@ Ticket change
objType |= OBJTYPE_TICKET;
}else if( zType[0]=='c' ){
@ Manifest of check-in
objType |= OBJTYPE_CHECKIN;
}else if( zType[0]=='e' ){
| > > | | | > > > | | 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 |
);
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
const char *zUser = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zType = db_column_text(&q, 3);
const char *zUuid = db_column_text(&q, 4);
int eventTagId = db_column_int(&q, 5);
if( cnt>0 ){
@ Also
}
if( zType[0]=='w' ){
@ Wiki edit
objType |= OBJTYPE_WIKI;
}else if( zType[0]=='t' ){
@ Ticket change
objType |= OBJTYPE_TICKET;
}else if( zType[0]=='c' ){
@ Manifest of check-in
objType |= OBJTYPE_CHECKIN;
}else if( zType[0]=='e' ){
if( eventTagId != 0) {
@ Instance of technote
objType |= OBJTYPE_EVENT;
hyperlink_to_event_tagid(db_column_int(&q, 5));
}else{
@ Attachment to technote
}
}else{
@ Tag referencing
}
if( zType[0]!='e' || eventTagId == 0){
hyperlink_to_uuid(zUuid);
}
@ - %!W(zCom) by
hyperlink_to_user(zUser,zDate," on");
hyperlink_to_date(zDate, ".");
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_appendf(pDownloadName, "%S.txt", zUuid);
|
| ︙ | ︙ | |||
1381 1382 1383 1384 1385 1386 1387 |
if( cnt>0 ){
@ Also attachment "%h(zFilename)" to
}else{
@ Attachment "%h(zFilename)" to
}
objType |= OBJTYPE_ATTACHMENT;
if( strlen(zTarget)==UUID_SIZE && validate16(zTarget,UUID_SIZE) ){
| > > > | | | | > > > > > > > > > > > > > > > | 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
if( cnt>0 ){
@ Also attachment "%h(zFilename)" to
}else{
@ Attachment "%h(zFilename)" to
}
objType |= OBJTYPE_ATTACHMENT;
if( strlen(zTarget)==UUID_SIZE && validate16(zTarget,UUID_SIZE) ){
if ( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'",
zTarget)
){
if( g.perm.Hyperlink && g.anon.RdTkt ){
@ ticket [%z(href("%R/tktview?name=%!S",zTarget))%S(zTarget)</a>]
}else{
@ ticket [%S(zTarget)]
}
}else if( db_exists("SELECT 1 FROM tag WHERE tagname='event-%q'",
zTarget)
){
if( g.perm.Hyperlink && g.anon.RdWiki ){
@ tech note [%z(href("%R/technote/%h",zTarget))%S(zTarget)</a>]
}else{
@ tech note [%S(zTarget)]
}
}else{
if( g.perm.Hyperlink && g.anon.RdWiki ){
@ wiki page [%z(href("%R/wiki?name=%t",zTarget))%h(zTarget)</a>]
}else{
@ wiki page [%h(zTarget)]
}
}
}else{
if( g.perm.Hyperlink && g.anon.RdWiki ){
@ wiki page [%z(href("%R/wiki?name=%t",zTarget))%h(zTarget)</a>]
}else{
@ wiki page [%h(zTarget)]
}
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
1135 1136 1137 1138 1139 1140 1141 | db_end_transaction(0); return 1; } /* ** COMMAND: wiki* ** | | | | | | | 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | db_end_transaction(0); return 1; } /* ** COMMAND: wiki* ** ** Usage: %fossil wiki (export|create|commit|list) WikiName ** ** Run various subcommands to work with wiki entries or tech notes. ** ** %fossil wiki export ?PAGENAME? ?FILE? [-t|--technote DATETIME ] ** ** Sends the latest version of either the PAGENAME wiki entry ** or the DATETIME tech note to the given file or standard ** output. One of PAGENAME or DATETIME must be specified. ** ** %fossil wiki (create|commit) PAGENAME ?FILE? ?OPTIONS? ** ** Create a new or commit changes to an existing wiki page or ** technote from FILE or from standard input. ** ** Options: ** -M|--mimetype TEXT-FORMAT The mime type of the update defaulting ** defaulting to the type used by the ** previous version of the page or (for ** new pages) text/x-fossil-wiki. ** -t|--technote DATETIME Specifies the timestamp of the technote ** to be created or updated. ** --technote-tags TAGS The set of tags for a technote. ** --technote-bgcolor COLOR The color used for the technote on the ** timeline. ** ** %fossil wiki list ?--technote? ** %fossil wiki ls ?--technote? ** ** Lists all wiki entries, one per line, ordered ** case-insensitively by name. The --technote flag ** specifies that technotes will be listed instead of ** the wiki entries, which will be listed in order ** timestamp. ** |
| ︙ | ︙ | |||
1223 1224 1225 1226 1227 1228 1229 |
" ORDER BY mtime DESC LIMIT 1",
zETime
);
if( (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 ){
zBody = pWiki->zWiki;
}
if( zBody==0 ){
| | | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 |
" 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);
}
zFile = (g.argc==3) ? "-" : g.argv[3];
}
for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){}
zBody[i] = 0;
blob_init(&body, zBody, -1);
blob_append(&body, "\n", 1);
|
| ︙ | ︙ |