Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the /juvlist webpage that returns a list of all unversioned files as JSON. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
7d12ba544f7ecc192ed1b4a7fb81b671 |
| User & Date: | drh 2017-03-04 14:29:36.872 |
Context
|
2017-03-05
| ||
| 19:51 | Add support for variable "hash policies". Increase the version number to 2.1. ... (check-in: e92133a548 user: drh tags: trunk) | |
|
2017-03-04
| ||
| 20:04 | Merge enhancements from trunk ... (check-in: acd3b31f75 user: drh tags: fossil-2.1) | |
| 14:29 | Add the /juvlist webpage that returns a list of all unversioned files as JSON. ... (check-in: 7d12ba544f user: drh tags: trunk) | |
|
2017-03-03
| ||
| 19:33 | Improve stash diff commands when using external diff tool to make it behave a little bit more like the "fossil gdiff" command. ... (check-in: 2a47673a9e user: mgagnon tags: trunk) | |
Changes
Changes to src/doc.c.
| ︙ | ︙ | |||
733 734 735 736 737 738 739 |
db_end_transaction(0);
return;
/* Jump here when unable to locate the document */
doc_not_found:
db_end_transaction(0);
if( isUV && P("name")==0 ){
| | | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
db_end_transaction(0);
return;
/* Jump here when unable to locate the document */
doc_not_found:
db_end_transaction(0);
if( isUV && P("name")==0 ){
uvlist_page();
return;
}
cgi_set_status(404, "Not Found");
style_header("Not Found");
@ <p>Document %h(zOrigName) not found
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
}
}
z[j++] = c;
}
if( z[j] ) z[j] = 0;
}
/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
}
}
z[j++] = c;
}
if( z[j] ) z[j] = 0;
}
/*
** The *pz variable points to a UTF8 string. Read the next character
** off of that string and return its codepoint value. Advance *pz to the
** next character
*/
u32 fossil_utf8_read(
const unsigned char **pz /* Pointer to string from which to read char */
){
unsigned int c;
/*
** This lookup table is used to help decode the first byte of
** a multi-byte UTF8 character.
*/
static const unsigned char utf8Trans1[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
};
c = *((*pz)++);
if( c>=0xc0 ){
c = utf8Trans1[c-0xc0];
while( (*(*pz) & 0xc0)==0x80 ){
c = (c<<6) + (0x3f & *((*pz)++));
}
if( c<0x80
|| (c&0xFFFFF800)==0xD800
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; }
}
return c;
}
/*
** Encode a UTF8 string for JSON. All special characters are escaped.
*/
void blob_append_json_string(Blob *pBlob, const char *zStr){
const unsigned char *z;
char *zOut;
u32 c;
int n, i, j;
z = (const unsigned char*)zStr;
n = 0;
while( (c = fossil_utf8_read(&z))!=0 ){
if( c=='\\' || c=='"' ){
n += 2;
}else if( c<' ' || c>=0x7f ){
if( c=='\n' || c=='\r' ){
n += 2;
}else{
n += 6;
}
}else{
n++;
}
}
i = blob_size(pBlob);
blob_resize(pBlob, i+n);
zOut = blob_buffer(pBlob);
z = (const unsigned char*)zStr;
while( (c = fossil_utf8_read(&z))!=0 ){
if( c=='\\' ){
zOut[i++] = '\\';
zOut[i++] = c;
}else if( c<' ' || c>=0x7f ){
zOut[i++] = '\\';
if( c=='\n' ){
zOut[i++] = 'n';
}else if( c=='\r' ){
zOut[i++] = 'r';
}else{
zOut[i++] = 'u';
for(j=3; j>=0; j--){
zOut[i+j] = "0123456789abcdef"[c&0xf];
c >>= 4;
}
i += 4;
}
}else{
zOut[i++] = c;
}
}
zOut[i] = 0;
}
/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
| ︙ | ︙ |
Changes to src/unversioned.c.
| ︙ | ︙ | |||
454 455 456 457 458 459 460 | ** ** Display a list of all unversioned files in the repository. ** Query parameters: ** ** byage=1 Order the initial display be decreasing age ** showdel=0 Show deleted files */ | | | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
**
** Display a list of all unversioned files in the repository.
** Query parameters:
**
** byage=1 Order the initial display be decreasing age
** showdel=0 Show deleted files
*/
void uvlist_page(void){
Stmt q;
sqlite3_int64 iNow;
sqlite3_int64 iTotalSz = 0;
int cnt = 0;
int n = 0;
const char *zOrderBy = "name";
int showDel = 0;
|
| ︙ | ︙ | |||
552 553 554 555 556 557 558 |
@ </table></div>
output_table_sorting_javascript("uvtab","tkKttN",1);
}else{
@ No unversioned files on this server.
}
style_footer();
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
@ </table></div>
output_table_sorting_javascript("uvtab","tkKttN",1);
}else{
@ No unversioned files on this server.
}
style_footer();
}
/*
** WEBPAGE: juvlist
**
** Return a complete list of unversioned files as JSON. The JSON
** looks like this:
**
** [{"name":NAME,
** "mtime":MTIME,
** "hash":HASH,
** "size":SIZE,
* "user":USER}]
*/
void uvlist_json_page(void){
Stmt q;
char *zSep = "[";
Blob json;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
cgi_set_content_type("text/json");
if( !db_table_exists("repository","unversioned") ){
blob_init(&json, "[]", -1);
cgi_set_content(&json);
return;
}
blob_init(&json, 0, 0);
db_prepare(&q,
"SELECT"
" name,"
" mtime,"
" hash,"
" sz,"
" (SELECT login FROM rcvfrom, user"
" WHERE user.uid=rcvfrom.uid AND rcvfrom.rcvid=unversioned.rcvid)"
" FROM unversioned WHERE hash IS NOT NULL"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
sqlite3_int64 mtime = db_column_int(&q, 1);
const char *zHash = db_column_text(&q, 2);
int fullSize = db_column_int(&q, 3);
const char *zLogin = db_column_text(&q, 4);
if( zLogin==0 ) zLogin = "";
blob_appendf(&json, "%s{\"name\":\"", zSep);
zSep = ",\n ";
blob_append_json_string(&json, zName);
blob_appendf(&json, "\",\n \"mtime\":%lld,\n \"hash\":\"", mtime);
blob_append_json_string(&json, zHash);
blob_appendf(&json, "\",\n \"size\":%d,\n \"user\":\"", fullSize);
blob_append_json_string(&json, zLogin);
blob_appendf(&json, "\"}");
}
db_finalize(&q);
blob_appendf(&json,"]\n");
cgi_set_content(&json);
}
|