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".

drh 2014-01-07 12:46 trunk
Commit ff9e4e540046a5f2bf1c56978a5284097526179f
2 files changed +40 -9 +1
+40 -9
--- src/browse.c
+++ src/browse.c
@@ -396,41 +396,56 @@
396396
**
397397
** name=PATH Directory to display. Optional
398398
** ci=LABEL Show only files in this check-in. Optional.
399399
** re=REGEXP Show only files matching REGEXP. Optional.
400400
** expand Begin with the tree fully expanded.
401
+** nofiles Show directories (folders) only. Omit files.
401402
*/
402403
void page_tree(void){
403404
char *zD = fossil_strdup(P("name"));
404405
int nD = zD ? strlen(zD)+1 : 0;
405406
const char *zCI = P("ci");
406407
int rid = 0;
407408
char *zUuid = 0;
408409
Blob dirname;
409410
Manifest *pM = 0;
410
- int nFile = 0; /* Number of files */
411
+ int nFile = 0; /* Number of files (or folders with "nofiles") */
411412
int linkTrunk = 1; /* include link to "trunk" */
412413
int linkTip = 1; /* include link to "tip" */
413414
const char *zRE; /* the value for the re=REGEXP query parameter */
415
+ const char *zObjType; /* "files" by default or "folders" for "nofiles" */
414416
char *zREx = ""; /* Extra parameters for path hyperlinks */
415417
ReCompiled *pRE = 0; /* Compiled regular expression */
416418
FileTreeNode *p; /* One line of the tree */
417419
FileTree sTree; /* The complete tree of files */
418420
HQuery sURI; /* Hyperlink */
419421
int startExpanded; /* True to start out with the tree expanded */
422
+ int showDirOnly; /* Show directories only. Omit files */
420423
char *zProjectName = db_get("project-name", 0);
421424
422425
if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; }
423426
memset(&sTree, 0, sizeof(sTree));
424427
login_check_credentials();
425428
if( !g.perm.Read ){ login_needed(); return; }
426429
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
427
- style_header("File List");
428430
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
429431
pathelementFunc, 0, 0);
430432
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
+ }
432447
433448
/* If a regular expression is specified, compile it */
434449
zRE = P("re");
435450
if( zRE ){
436451
re_compile(&pRE, zRE, 0);
@@ -473,11 +488,11 @@
473488
}
474489
}
475490
if( zCI ){
476491
style_submenu_element("All", "All", "%s",
477492
url_render(&sURI, "ci", 0, 0, 0));
478
- if( nD==0 ){
493
+ if( nD==0 && !showDirOnly ){
479494
style_submenu_element("File Ages", "File Ages", "%R/fileage?name=%S",
480495
zUuid);
481496
}
482497
}
483498
if( linkTrunk ){
@@ -486,12 +501,15 @@
486501
}
487502
if ( linkTip ){
488503
style_submenu_element("Tip", "Tip", "%s",
489504
url_render(&sURI, "ci", "tip", 0, 0));
490505
}
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
+
493511
/* Compute the file hierarchy.
494512
*/
495513
if( zCI ){
496514
Stmt ins, q;
497515
ManifestFile *pFile;
@@ -538,20 +556,33 @@
538556
tree_add_node(&sTree, z, 0);
539557
nFile++;
540558
}
541559
db_finalize(&q);
542560
}
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
+ }
543574
544575
if( zCI ){
545
- @ <h2>%d(nFile) files of check-in
576
+ @ <h2>%d(nFile) %s(zObjType) of check-in
546577
if( sqlite3_strnicmp(zCI, zUuid, (int)strlen(zCI))!=0 ){
547578
@ "%h(zCI)"
548579
}
549580
@ [%z(href("vinfo?name=%T",zUuid))%S(zUuid)</a>] %s(blob_str(&dirname))</h2>
550581
}else{
551582
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
553584
@ %s(blob_str(&dirname))</h2>
554585
}
555586
556587
557588
/* Generate tree of lists.
@@ -584,11 +615,11 @@
584615
if( startExpanded || p->nFullName<=nD ){
585616
@ <ul>
586617
}else{
587618
@ <ul style='display:none;'>
588619
}
589
- }else{
620
+ }else if( !showDirOnly ){
590621
char *zLink;
591622
if( zCI ){
592623
zLink = href("%R/artifact/%S",p->zUuid);
593624
}else{
594625
zLink = href("%R/finfo?name=%T",p->zFullName);
595626
--- 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 @@
631631
@ </td></tr>
632632
@ <tr><th>Other&nbsp;Links:</th>
633633
@ <td>
634634
@ %z(href("%R/tree?ci=%S",zUuid))files</a>
635635
@ | %z(href("%R/fileage?name=%S",zUuid))file ages</a>
636
+ @ | %z(href("%R/tree?ci=%S&nofiles",zUuid))folders</a>
636637
@ | %z(href("%R/artifact/%S",zUuid))manifest</a>
637638
if( g.perm.Write ){
638639
@ | %z(href("%R/ci_edit?r=%S",zUuid))edit</a>
639640
}
640641
@ </td>
641642
--- src/info.c
+++ src/info.c
@@ -631,10 +631,11 @@
631 @ </td></tr>
632 @ <tr><th>Other&nbsp;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&nbsp;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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button