Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch technoteattachcli Excluding Merge-Ins
This is equivalent to a diff from a13ef5e6a6 to 6fa5570b9a
|
2016-05-14
| ||
| 00:48 | Collected improvements to the fossil wiki and attach commands to support technotes as well as wiki pages, including attachments to either and new test cases. Passes all tests. check-in: 05cd9fa2bf user: rberteig tags: trunk | |
|
2016-05-06
| ||
| 14:08 | Add tests for the mimetype on wiki command. Update help text to list valid mimetypes Closed-Leaf check-in: 6fa5570b9a user: dave.vines tags: technoteattachcli | |
|
2016-05-05
| ||
| 18:26 | Fix bug detected by wiki-15 and wiki-15.1. Left hand thought that the mtime column was the timestamp of the tech note. Right hand thought that the mtime column was the last modification time of the tech note. Left hand was right and the relevant query has been updated to use the objid (assigned as the new tech note manifest is added) as the indication of the most recently modified version of the tech note check-in: e9d7c5aa29 user: dave.vines tags: technoteattachcli | |
|
2016-05-03
| ||
| 20:30 | Update referenced OpenSSL version. check-in: 5399251230 user: mistachkin tags: trunk | |
| 08:17 | Merged trunk and resolved conflicts. Passes all current tests, except for tests wiki-15 and wiki-15.1 in wiki.test. check-in: 8c8ccac9be user: rberteig tags: technoteattachcli | |
|
2016-05-02
| ||
| 16:19 | Do not run "all" commands against encrypted repos if encryption is not supported. check-in: a13ef5e6a6 user: drh tags: trunk | |
| 16:14 | Update the built-in SQLite to an early beta of 3.13.0 for testing. check-in: fc5f1728d5 user: drh tags: trunk | |
Changes to src/attach.c.
| ︙ | |||
244 245 246 247 248 249 250 251 252 253 254 255 256 257 | 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
|
| ︙ | |||
298 299 300 301 302 303 304 | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | - + |
}
if( !db_exists("SELECT 1 FROM tag WHERE tagname='event-%q'", zTechNote) ){
zTechNote = db_text(0, "SELECT substr(tagname,7) FROM tag"
" WHERE tagname GLOB 'event-%q*'", zTechNote);
if( zTechNote==0) fossil_redirect_home();
}
zTarget = zTechNote;
|
| ︙ | |||
320 321 322 323 324 325 326 | 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()) ){
|
| ︙ | |||
668 669 670 671 672 673 674 | 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 777 778 779 780 781 782 783 784 785 786 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
}
if( cnt ){
@ </ul>
}
db_finalize(&q);
}
/*
** COMMAND: attachment*
**
** Usage: %fossil attachment add ?PAGENAME? FILENAME ?OPTIONS?
**
** Add an attachment to an existing wiki page or tech note.
**
** Options:
** -t|--technote DATETIME Specifies the timestamp of
** the technote to which the attachment
** is to be made. The attachment will be
** to the most recently modified tech note
** with the specified timestamp.
** -t|--technote TECHNOTE-ID Specifies the technote to be
** updated by its technote id.
**
** One of PAGENAME, DATETIME or TECHNOTE-ID 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("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("add FILENAME --technote DATETIME|TECHNOTE-ID");
}
rid = wiki_technote_to_rid(zETime);
if( rid<0 ){
fossil_fatal("ambiguous tech note id: %s", 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("add ?PAGENAME? FILENAME [-t|--technote DATETIME ]");
}
|
Changes to src/event.c.
| ︙ | |||
538 539 540 541 542 543 544 | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | - + - + - - - - - - - - - - - - + - - - - - - - - + | @ </td></tr></table> @ </div></form> style_footer(); } /* ** Add a new tech note to the repository. The timestamp is |
| ︙ |
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 | 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) {
|
| ︙ | |||
1381 1382 1383 1384 1385 1386 1387 | 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)
){
|
| ︙ |
Changes to src/json_wiki.c.
| ︙ | |||
372 373 374 375 376 377 378 379 | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | + - + |
jstr = cson_value_get_string(contentV);
contentLen = (int)cson_string_length_bytes(jstr);
if(contentLen){
blob_append(&content, cson_string_cstr(jstr),contentLen);
}
zMimeType = json_find_option_cstr("mimetype","mimetype","M");
zMimeType = wiki_filter_mimetypes(zMimeType);
|
| ︙ |
Changes to src/manifest.c.
| ︙ | |||
2064 2065 2066 2067 2068 2069 2070 | 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 | - + - - + + + + |
const char *zTarget = db_column_text(&qatt, 2);
const char *zName = db_column_text(&qatt, 3);
const char isAdd = (zSrc && zSrc[0]) ? 1 : 0;
char *zComment;
if( isAdd ){
zComment = mprintf(
"Add attachment [/artifact/%!S|%h] to"
|
| ︙ | |||
2160 2161 2162 2163 2164 2165 2166 | 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 | - + - - + + + + + |
}else{
zComment = mprintf("Delete attachment \"%h\" from wiki page [%h]",
p->zAttachName, p->zAttachTarget);
}
}else if( 'e' == attachToType ){
if( isAdd ){
zComment = mprintf(
|
| ︙ |
Changes to src/wiki.c.
| ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | + + + + + + + + + - - - + + + + + + + + + - - + + |
** Return true if the given pagename is the name of the sandbox
*/
static int is_sandbox(const char *zPagename){
return fossil_stricmp(zPagename,"sandbox")==0 ||
fossil_stricmp(zPagename,"sand box")==0;
}
/*
** Formal, common and short names for the various wiki styles.
*/
static const char *const azStyles[] = {
"text/x-fossil-wiki", "Fossil Wiki", "wiki",
"text/x-markdown", "Markdown", "markdown",
"text/plain", "Plain Text", "plain"
};
/*
** Only allow certain mimetypes through.
** All others become "text/x-fossil-wiki"
*/
const char *wiki_filter_mimetypes(const char *zMimetype){
|
| ︙ | |||
410 411 412 413 414 415 416 | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | - - - - - - - - - - + |
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
manifest_crosslink(nrid, pWiki, MC_NONE);
}
|
| ︙ | |||
1066 1067 1068 1069 1070 1071 1072 | 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | - - + + - - + - - - - - - - - - - - - - - - - - - - - | @ through the matching </verbatim>.</p></li> @ </ol> style_footer(); } /* ** Add a new wiki page to the repository. The page name is |
| ︙ | |||
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 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 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + + + + + + - + + + - - - - - + + + + + + + + + + + + + + + + - - + + - - + + - - - - + + + + + + + + + + + + |
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
db_begin_transaction();
wiki_put(&wiki, 0, wiki_need_moderation(localUser));
db_end_transaction(0);
return 1;
}
/*
** Determine the rid for a tech note given either its id or its
** timestamp. Returns 0 if there is no such item and -1 if the details
** are ambiguous and could refer to multiple items.
*/
int wiki_technote_to_rid(const char *zETime) {
int rid=0; /* Artifact ID of the tech note */
int nETime = strlen(zETime);
Stmt q;
if( nETime>=4 && nETime<=UUID_SIZE && validate16(zETime, nETime) ){
char zUuid[UUID_SIZE+1];
memcpy(zUuid, zETime, nETime+1);
canonical16(zUuid, nETime);
db_prepare(&q,
"SELECT e.objid"
" FROM event e, tag t"
" WHERE e.type='e' AND e.tagid IS NOT NULL AND t.tagid=e.tagid"
" AND t.tagname GLOB 'event-%q*'",
zUuid
);
if( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
if( db_step(&q)==SQLITE_ROW ) rid = -1;
}
db_finalize(&q);
}
if (!rid) {
if (strlen(zETime)>4) {
rid = db_int(0, "SELECT objid"
" FROM event"
" WHERE datetime(mtime)=datetime('%q')"
" AND type='e'"
" AND tagid IS NOT NULL"
" ORDER BY objid DESC LIMIT 1",
zETime);
}
}
return rid;
}
/*
** COMMAND: wiki*
**
** Usage: %fossil wiki (export|create|commit|list) WikiName
**
** Run various subcommands to work with wiki entries or tech notes.
**
|
| ︙ | |||
1211 1212 1213 1214 1215 1216 1217 | 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 | - + - - + + - - + - + - + |
}
if( zBody==0 ){
fossil_fatal("wiki page [%s] not found",zPageName);
}
zFile = (g.argc==4) ? "-" : g.argv[4];
}else{
if( (g.argc!=3) && (g.argc!=4) ){
|
| ︙ | |||
1268 1269 1270 1271 1272 1273 1274 | 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 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 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 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 | - + - - - - + + + + + + + + + + + + + + + + + + + - - + - - - + + + - - + + - - + + - - - - - + + + + + + + + + - - + + + + + + + + + + + |
zPageName
);
if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0
&& (pWiki->zMimetype && *pWiki->zMimetype)){
zMimeType = pWiki->zMimetype;
}
}else{
|
Added test/wiki.test.