Fossil SCM
Add the "nofiles" query parameter to the /tree page, causing that page to show only directories. Add a new "folders" link on the check-in information page that jumps to "/tree?nofiles".
Commit
ff9e4e540046a5f2bf1c56978a5284097526179f
Parent
4306ab81437b673…
2 files changed
+40
-9
+1
+40
-9
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -396,41 +396,56 @@ | ||
| 396 | 396 | ** |
| 397 | 397 | ** name=PATH Directory to display. Optional |
| 398 | 398 | ** ci=LABEL Show only files in this check-in. Optional. |
| 399 | 399 | ** re=REGEXP Show only files matching REGEXP. Optional. |
| 400 | 400 | ** expand Begin with the tree fully expanded. |
| 401 | +** nofiles Show directories (folders) only. Omit files. | |
| 401 | 402 | */ |
| 402 | 403 | void page_tree(void){ |
| 403 | 404 | char *zD = fossil_strdup(P("name")); |
| 404 | 405 | int nD = zD ? strlen(zD)+1 : 0; |
| 405 | 406 | const char *zCI = P("ci"); |
| 406 | 407 | int rid = 0; |
| 407 | 408 | char *zUuid = 0; |
| 408 | 409 | Blob dirname; |
| 409 | 410 | Manifest *pM = 0; |
| 410 | - int nFile = 0; /* Number of files */ | |
| 411 | + int nFile = 0; /* Number of files (or folders with "nofiles") */ | |
| 411 | 412 | int linkTrunk = 1; /* include link to "trunk" */ |
| 412 | 413 | int linkTip = 1; /* include link to "tip" */ |
| 413 | 414 | const char *zRE; /* the value for the re=REGEXP query parameter */ |
| 415 | + const char *zObjType; /* "files" by default or "folders" for "nofiles" */ | |
| 414 | 416 | char *zREx = ""; /* Extra parameters for path hyperlinks */ |
| 415 | 417 | ReCompiled *pRE = 0; /* Compiled regular expression */ |
| 416 | 418 | FileTreeNode *p; /* One line of the tree */ |
| 417 | 419 | FileTree sTree; /* The complete tree of files */ |
| 418 | 420 | HQuery sURI; /* Hyperlink */ |
| 419 | 421 | int startExpanded; /* True to start out with the tree expanded */ |
| 422 | + int showDirOnly; /* Show directories only. Omit files */ | |
| 420 | 423 | char *zProjectName = db_get("project-name", 0); |
| 421 | 424 | |
| 422 | 425 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 423 | 426 | memset(&sTree, 0, sizeof(sTree)); |
| 424 | 427 | login_check_credentials(); |
| 425 | 428 | if( !g.perm.Read ){ login_needed(); return; } |
| 426 | 429 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 427 | - style_header("File List"); | |
| 428 | 430 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 429 | 431 | pathelementFunc, 0, 0); |
| 430 | 432 | url_initialize(&sURI, "tree"); |
| 431 | - startExpanded = P("expand")!=0; | |
| 433 | + if( P("nofiles")!=0 ){ | |
| 434 | + showDirOnly = 1; | |
| 435 | + url_add_parameter(&sURI, "nofiles", "1"); | |
| 436 | + style_header("Folder Hierarchy"); | |
| 437 | + }else{ | |
| 438 | + showDirOnly = 0; | |
| 439 | + style_header("File Tree"); | |
| 440 | + } | |
| 441 | + if( P("expand")!=0 ){ | |
| 442 | + startExpanded = 1; | |
| 443 | + url_add_parameter(&sURI, "expand", "1"); | |
| 444 | + }else{ | |
| 445 | + startExpanded = 0; | |
| 446 | + } | |
| 432 | 447 | |
| 433 | 448 | /* If a regular expression is specified, compile it */ |
| 434 | 449 | zRE = P("re"); |
| 435 | 450 | if( zRE ){ |
| 436 | 451 | re_compile(&pRE, zRE, 0); |
| @@ -473,11 +488,11 @@ | ||
| 473 | 488 | } |
| 474 | 489 | } |
| 475 | 490 | if( zCI ){ |
| 476 | 491 | style_submenu_element("All", "All", "%s", |
| 477 | 492 | url_render(&sURI, "ci", 0, 0, 0)); |
| 478 | - if( nD==0 ){ | |
| 493 | + if( nD==0 && !showDirOnly ){ | |
| 479 | 494 | style_submenu_element("File Ages", "File Ages", "%R/fileage?name=%S", |
| 480 | 495 | zUuid); |
| 481 | 496 | } |
| 482 | 497 | } |
| 483 | 498 | if( linkTrunk ){ |
| @@ -486,12 +501,15 @@ | ||
| 486 | 501 | } |
| 487 | 502 | if ( linkTip ){ |
| 488 | 503 | style_submenu_element("Tip", "Tip", "%s", |
| 489 | 504 | url_render(&sURI, "ci", "tip", 0, 0)); |
| 490 | 505 | } |
| 491 | - style_submenu_element("Flat-View", "Flat-View", "%s", | |
| 492 | - url_render(&sURI, "type", "flat", 0, 0)); | |
| 506 | + if( !showDirOnly ){ | |
| 507 | + style_submenu_element("Flat-View", "Flat-View", "%s", | |
| 508 | + url_render(&sURI, "type", "flat", 0, 0)); | |
| 509 | + } | |
| 510 | + | |
| 493 | 511 | /* Compute the file hierarchy. |
| 494 | 512 | */ |
| 495 | 513 | if( zCI ){ |
| 496 | 514 | Stmt ins, q; |
| 497 | 515 | ManifestFile *pFile; |
| @@ -538,20 +556,33 @@ | ||
| 538 | 556 | tree_add_node(&sTree, z, 0); |
| 539 | 557 | nFile++; |
| 540 | 558 | } |
| 541 | 559 | db_finalize(&q); |
| 542 | 560 | } |
| 561 | + | |
| 562 | + if( showDirOnly ){ | |
| 563 | + for(nFile=0, p=sTree.pFirst; p; p=p->pNext){ | |
| 564 | + if( p->isDir && p->nFullName>nD ) nFile++; | |
| 565 | + } | |
| 566 | + zObjType = "folders"; | |
| 567 | + style_submenu_element("Files","Files","%s", | |
| 568 | + url_render(&sURI,"nofiles",0,0,0)); | |
| 569 | + }else{ | |
| 570 | + zObjType = "files"; | |
| 571 | + style_submenu_element("Folders","Folders","%s", | |
| 572 | + url_render(&sURI,"nofiles","1",0,0)); | |
| 573 | + } | |
| 543 | 574 | |
| 544 | 575 | if( zCI ){ |
| 545 | - @ <h2>%d(nFile) files of check-in | |
| 576 | + @ <h2>%d(nFile) %s(zObjType) of check-in | |
| 546 | 577 | if( sqlite3_strnicmp(zCI, zUuid, (int)strlen(zCI))!=0 ){ |
| 547 | 578 | @ "%h(zCI)" |
| 548 | 579 | } |
| 549 | 580 | @ [%z(href("vinfo?name=%T",zUuid))%S(zUuid)</a>] %s(blob_str(&dirname))</h2> |
| 550 | 581 | }else{ |
| 551 | 582 | int n = db_int(0, "SELECT count(*) FROM plink"); |
| 552 | - @ <h2>%d(nFile) files from all %d(n) check-ins | |
| 583 | + @ <h2>%d(nFile) %s(zObjType) from all %d(n) check-ins | |
| 553 | 584 | @ %s(blob_str(&dirname))</h2> |
| 554 | 585 | } |
| 555 | 586 | |
| 556 | 587 | |
| 557 | 588 | /* Generate tree of lists. |
| @@ -584,11 +615,11 @@ | ||
| 584 | 615 | if( startExpanded || p->nFullName<=nD ){ |
| 585 | 616 | @ <ul> |
| 586 | 617 | }else{ |
| 587 | 618 | @ <ul style='display:none;'> |
| 588 | 619 | } |
| 589 | - }else{ | |
| 620 | + }else if( !showDirOnly ){ | |
| 590 | 621 | char *zLink; |
| 591 | 622 | if( zCI ){ |
| 592 | 623 | zLink = href("%R/artifact/%S",p->zUuid); |
| 593 | 624 | }else{ |
| 594 | 625 | zLink = href("%R/finfo?name=%T",p->zFullName); |
| 595 | 626 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -396,41 +396,56 @@ | |
| 396 | ** |
| 397 | ** name=PATH Directory to display. Optional |
| 398 | ** ci=LABEL Show only files in this check-in. Optional. |
| 399 | ** re=REGEXP Show only files matching REGEXP. Optional. |
| 400 | ** expand Begin with the tree fully expanded. |
| 401 | */ |
| 402 | void page_tree(void){ |
| 403 | char *zD = fossil_strdup(P("name")); |
| 404 | int nD = zD ? strlen(zD)+1 : 0; |
| 405 | const char *zCI = P("ci"); |
| 406 | int rid = 0; |
| 407 | char *zUuid = 0; |
| 408 | Blob dirname; |
| 409 | Manifest *pM = 0; |
| 410 | int nFile = 0; /* Number of files */ |
| 411 | int linkTrunk = 1; /* include link to "trunk" */ |
| 412 | int linkTip = 1; /* include link to "tip" */ |
| 413 | const char *zRE; /* the value for the re=REGEXP query parameter */ |
| 414 | char *zREx = ""; /* Extra parameters for path hyperlinks */ |
| 415 | ReCompiled *pRE = 0; /* Compiled regular expression */ |
| 416 | FileTreeNode *p; /* One line of the tree */ |
| 417 | FileTree sTree; /* The complete tree of files */ |
| 418 | HQuery sURI; /* Hyperlink */ |
| 419 | int startExpanded; /* True to start out with the tree expanded */ |
| 420 | char *zProjectName = db_get("project-name", 0); |
| 421 | |
| 422 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 423 | memset(&sTree, 0, sizeof(sTree)); |
| 424 | login_check_credentials(); |
| 425 | if( !g.perm.Read ){ login_needed(); return; } |
| 426 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 427 | style_header("File List"); |
| 428 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 429 | pathelementFunc, 0, 0); |
| 430 | url_initialize(&sURI, "tree"); |
| 431 | startExpanded = P("expand")!=0; |
| 432 | |
| 433 | /* If a regular expression is specified, compile it */ |
| 434 | zRE = P("re"); |
| 435 | if( zRE ){ |
| 436 | re_compile(&pRE, zRE, 0); |
| @@ -473,11 +488,11 @@ | |
| 473 | } |
| 474 | } |
| 475 | if( zCI ){ |
| 476 | style_submenu_element("All", "All", "%s", |
| 477 | url_render(&sURI, "ci", 0, 0, 0)); |
| 478 | if( nD==0 ){ |
| 479 | style_submenu_element("File Ages", "File Ages", "%R/fileage?name=%S", |
| 480 | zUuid); |
| 481 | } |
| 482 | } |
| 483 | if( linkTrunk ){ |
| @@ -486,12 +501,15 @@ | |
| 486 | } |
| 487 | if ( linkTip ){ |
| 488 | style_submenu_element("Tip", "Tip", "%s", |
| 489 | url_render(&sURI, "ci", "tip", 0, 0)); |
| 490 | } |
| 491 | style_submenu_element("Flat-View", "Flat-View", "%s", |
| 492 | url_render(&sURI, "type", "flat", 0, 0)); |
| 493 | /* Compute the file hierarchy. |
| 494 | */ |
| 495 | if( zCI ){ |
| 496 | Stmt ins, q; |
| 497 | ManifestFile *pFile; |
| @@ -538,20 +556,33 @@ | |
| 538 | tree_add_node(&sTree, z, 0); |
| 539 | nFile++; |
| 540 | } |
| 541 | db_finalize(&q); |
| 542 | } |
| 543 | |
| 544 | if( zCI ){ |
| 545 | @ <h2>%d(nFile) files of check-in |
| 546 | if( sqlite3_strnicmp(zCI, zUuid, (int)strlen(zCI))!=0 ){ |
| 547 | @ "%h(zCI)" |
| 548 | } |
| 549 | @ [%z(href("vinfo?name=%T",zUuid))%S(zUuid)</a>] %s(blob_str(&dirname))</h2> |
| 550 | }else{ |
| 551 | int n = db_int(0, "SELECT count(*) FROM plink"); |
| 552 | @ <h2>%d(nFile) files from all %d(n) check-ins |
| 553 | @ %s(blob_str(&dirname))</h2> |
| 554 | } |
| 555 | |
| 556 | |
| 557 | /* Generate tree of lists. |
| @@ -584,11 +615,11 @@ | |
| 584 | if( startExpanded || p->nFullName<=nD ){ |
| 585 | @ <ul> |
| 586 | }else{ |
| 587 | @ <ul style='display:none;'> |
| 588 | } |
| 589 | }else{ |
| 590 | char *zLink; |
| 591 | if( zCI ){ |
| 592 | zLink = href("%R/artifact/%S",p->zUuid); |
| 593 | }else{ |
| 594 | zLink = href("%R/finfo?name=%T",p->zFullName); |
| 595 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -396,41 +396,56 @@ | |
| 396 | ** |
| 397 | ** name=PATH Directory to display. Optional |
| 398 | ** ci=LABEL Show only files in this check-in. Optional. |
| 399 | ** re=REGEXP Show only files matching REGEXP. Optional. |
| 400 | ** expand Begin with the tree fully expanded. |
| 401 | ** nofiles Show directories (folders) only. Omit files. |
| 402 | */ |
| 403 | void page_tree(void){ |
| 404 | char *zD = fossil_strdup(P("name")); |
| 405 | int nD = zD ? strlen(zD)+1 : 0; |
| 406 | const char *zCI = P("ci"); |
| 407 | int rid = 0; |
| 408 | char *zUuid = 0; |
| 409 | Blob dirname; |
| 410 | Manifest *pM = 0; |
| 411 | int nFile = 0; /* Number of files (or folders with "nofiles") */ |
| 412 | int linkTrunk = 1; /* include link to "trunk" */ |
| 413 | int linkTip = 1; /* include link to "tip" */ |
| 414 | const char *zRE; /* the value for the re=REGEXP query parameter */ |
| 415 | const char *zObjType; /* "files" by default or "folders" for "nofiles" */ |
| 416 | char *zREx = ""; /* Extra parameters for path hyperlinks */ |
| 417 | ReCompiled *pRE = 0; /* Compiled regular expression */ |
| 418 | FileTreeNode *p; /* One line of the tree */ |
| 419 | FileTree sTree; /* The complete tree of files */ |
| 420 | HQuery sURI; /* Hyperlink */ |
| 421 | int startExpanded; /* True to start out with the tree expanded */ |
| 422 | int showDirOnly; /* Show directories only. Omit files */ |
| 423 | char *zProjectName = db_get("project-name", 0); |
| 424 | |
| 425 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 426 | memset(&sTree, 0, sizeof(sTree)); |
| 427 | login_check_credentials(); |
| 428 | if( !g.perm.Read ){ login_needed(); return; } |
| 429 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 430 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 431 | pathelementFunc, 0, 0); |
| 432 | url_initialize(&sURI, "tree"); |
| 433 | if( P("nofiles")!=0 ){ |
| 434 | showDirOnly = 1; |
| 435 | url_add_parameter(&sURI, "nofiles", "1"); |
| 436 | style_header("Folder Hierarchy"); |
| 437 | }else{ |
| 438 | showDirOnly = 0; |
| 439 | style_header("File Tree"); |
| 440 | } |
| 441 | if( P("expand")!=0 ){ |
| 442 | startExpanded = 1; |
| 443 | url_add_parameter(&sURI, "expand", "1"); |
| 444 | }else{ |
| 445 | startExpanded = 0; |
| 446 | } |
| 447 | |
| 448 | /* If a regular expression is specified, compile it */ |
| 449 | zRE = P("re"); |
| 450 | if( zRE ){ |
| 451 | re_compile(&pRE, zRE, 0); |
| @@ -473,11 +488,11 @@ | |
| 488 | } |
| 489 | } |
| 490 | if( zCI ){ |
| 491 | style_submenu_element("All", "All", "%s", |
| 492 | url_render(&sURI, "ci", 0, 0, 0)); |
| 493 | if( nD==0 && !showDirOnly ){ |
| 494 | style_submenu_element("File Ages", "File Ages", "%R/fileage?name=%S", |
| 495 | zUuid); |
| 496 | } |
| 497 | } |
| 498 | if( linkTrunk ){ |
| @@ -486,12 +501,15 @@ | |
| 501 | } |
| 502 | if ( linkTip ){ |
| 503 | style_submenu_element("Tip", "Tip", "%s", |
| 504 | url_render(&sURI, "ci", "tip", 0, 0)); |
| 505 | } |
| 506 | if( !showDirOnly ){ |
| 507 | style_submenu_element("Flat-View", "Flat-View", "%s", |
| 508 | url_render(&sURI, "type", "flat", 0, 0)); |
| 509 | } |
| 510 | |
| 511 | /* Compute the file hierarchy. |
| 512 | */ |
| 513 | if( zCI ){ |
| 514 | Stmt ins, q; |
| 515 | ManifestFile *pFile; |
| @@ -538,20 +556,33 @@ | |
| 556 | tree_add_node(&sTree, z, 0); |
| 557 | nFile++; |
| 558 | } |
| 559 | db_finalize(&q); |
| 560 | } |
| 561 | |
| 562 | if( showDirOnly ){ |
| 563 | for(nFile=0, p=sTree.pFirst; p; p=p->pNext){ |
| 564 | if( p->isDir && p->nFullName>nD ) nFile++; |
| 565 | } |
| 566 | zObjType = "folders"; |
| 567 | style_submenu_element("Files","Files","%s", |
| 568 | url_render(&sURI,"nofiles",0,0,0)); |
| 569 | }else{ |
| 570 | zObjType = "files"; |
| 571 | style_submenu_element("Folders","Folders","%s", |
| 572 | url_render(&sURI,"nofiles","1",0,0)); |
| 573 | } |
| 574 | |
| 575 | if( zCI ){ |
| 576 | @ <h2>%d(nFile) %s(zObjType) of check-in |
| 577 | if( sqlite3_strnicmp(zCI, zUuid, (int)strlen(zCI))!=0 ){ |
| 578 | @ "%h(zCI)" |
| 579 | } |
| 580 | @ [%z(href("vinfo?name=%T",zUuid))%S(zUuid)</a>] %s(blob_str(&dirname))</h2> |
| 581 | }else{ |
| 582 | int n = db_int(0, "SELECT count(*) FROM plink"); |
| 583 | @ <h2>%d(nFile) %s(zObjType) from all %d(n) check-ins |
| 584 | @ %s(blob_str(&dirname))</h2> |
| 585 | } |
| 586 | |
| 587 | |
| 588 | /* Generate tree of lists. |
| @@ -584,11 +615,11 @@ | |
| 615 | if( startExpanded || p->nFullName<=nD ){ |
| 616 | @ <ul> |
| 617 | }else{ |
| 618 | @ <ul style='display:none;'> |
| 619 | } |
| 620 | }else if( !showDirOnly ){ |
| 621 | char *zLink; |
| 622 | if( zCI ){ |
| 623 | zLink = href("%R/artifact/%S",p->zUuid); |
| 624 | }else{ |
| 625 | zLink = href("%R/finfo?name=%T",p->zFullName); |
| 626 |
+1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -631,10 +631,11 @@ | ||
| 631 | 631 | @ </td></tr> |
| 632 | 632 | @ <tr><th>Other Links:</th> |
| 633 | 633 | @ <td> |
| 634 | 634 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 635 | 635 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 636 | + @ | %z(href("%R/tree?ci=%S&nofiles",zUuid))folders</a> | |
| 636 | 637 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 637 | 638 | if( g.perm.Write ){ |
| 638 | 639 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 639 | 640 | } |
| 640 | 641 | @ </td> |
| 641 | 642 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -631,10 +631,11 @@ | |
| 631 | @ </td></tr> |
| 632 | @ <tr><th>Other Links:</th> |
| 633 | @ <td> |
| 634 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 635 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 636 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 637 | if( g.perm.Write ){ |
| 638 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 639 | } |
| 640 | @ </td> |
| 641 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -631,10 +631,11 @@ | |
| 631 | @ </td></tr> |
| 632 | @ <tr><th>Other Links:</th> |
| 633 | @ <td> |
| 634 | @ %z(href("%R/tree?ci=%S",zUuid))files</a> |
| 635 | @ | %z(href("%R/fileage?name=%S",zUuid))file ages</a> |
| 636 | @ | %z(href("%R/tree?ci=%S&nofiles",zUuid))folders</a> |
| 637 | @ | %z(href("%R/artifact/%S",zUuid))manifest</a> |
| 638 | if( g.perm.Write ){ |
| 639 | @ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a> |
| 640 | } |
| 641 | @ </td> |
| 642 |