| | @@ -386,24 +386,10 @@ |
| 386 | 386 | pNew->isLast = 1; |
| 387 | 387 | while( zPath[i]=='/' ){ i++; } |
| 388 | 388 | pParent = pNew; |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | | - |
| 392 | | -/* |
| 393 | | -** Render parent lines for pNode |
| 394 | | -*/ |
| 395 | | -static void tree_indentation(FileTreeNode *p){ |
| 396 | | - if( p==0 ) return; |
| 397 | | - tree_indentation(p->pParent); |
| 398 | | - if( p->isLast ){ |
| 399 | | - cgi_append_content(" ", 4); |
| 400 | | - }else{ |
| 401 | | - cgi_append_content("│ ", 11); |
| 402 | | - } |
| 403 | | -} |
| 404 | | - |
| 405 | 391 | |
| 406 | 392 | /* |
| 407 | 393 | ** WEBPAGE: tree |
| 408 | 394 | ** |
| 409 | 395 | ** Query parameters: |
| | @@ -422,16 +408,16 @@ |
| 422 | 408 | Manifest *pM = 0; |
| 423 | 409 | int nFile = 0; /* Number of files */ |
| 424 | 410 | int linkTrunk = 1; /* include link to "trunk" */ |
| 425 | 411 | int linkTip = 1; /* include link to "tip" */ |
| 426 | 412 | const char *zRE; /* the value for the re=REGEXP query parameter */ |
| 427 | | - char *zPrefix; /* Prefix on all filenames */ |
| 428 | 413 | char *zREx = ""; /* Extra parameters for path hyperlinks */ |
| 429 | 414 | ReCompiled *pRE = 0; /* Compiled regular expression */ |
| 430 | 415 | FileTreeNode *p; /* One line of the tree */ |
| 431 | 416 | FileTree sTree; /* The complete tree of files */ |
| 432 | 417 | HQuery sURI; /* Hyperlink */ |
| 418 | + char *zProjectName = db_get("project-name", 0); |
| 433 | 419 | |
| 434 | 420 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 435 | 421 | memset(&sTree, 0, sizeof(sTree)); |
| 436 | 422 | login_check_credentials(); |
| 437 | 423 | if( !g.perm.Read ){ login_needed(); return; } |
| | @@ -474,18 +460,16 @@ |
| 474 | 460 | if( zD ){ |
| 475 | 461 | url_add_parameter(&sURI, "name", zD); |
| 476 | 462 | blob_append(&dirname, "within directory ", -1); |
| 477 | 463 | hyperlinked_path(zD, &dirname, zCI, "tree", zREx); |
| 478 | 464 | if( zRE ) blob_appendf(&dirname, " matching \"%s\"", zRE); |
| 479 | | - zPrefix = mprintf("%T/", zD); |
| 480 | 465 | style_submenu_element("Top-Level", "Top-Level", "%s", |
| 481 | 466 | url_render(&sURI, "name", 0, 0, 0)); |
| 482 | 467 | }else{ |
| 483 | 468 | if( zRE ){ |
| 484 | 469 | blob_appendf(&dirname, "matching \"%s\"", zRE); |
| 485 | 470 | } |
| 486 | | - zPrefix = ""; |
| 487 | 471 | } |
| 488 | 472 | if( zCI ){ |
| 489 | 473 | style_submenu_element("All", "All", "%s", |
| 490 | 474 | url_render(&sURI, "ci", 0, 0, 0)); |
| 491 | 475 | } |
| | @@ -521,11 +505,11 @@ |
| 521 | 505 | || pFile->zName[nD-1]!='/') |
| 522 | 506 | ){ |
| 523 | 507 | continue; |
| 524 | 508 | } |
| 525 | 509 | if( pRE && re_match(pRE, (const u8*)pFile->zName, -1)==0 ) continue; |
| 526 | | - db_bind_text(&ins, ":f", &pFile->zName[nD]); |
| 510 | + db_bind_text(&ins, ":f", pFile->zName); |
| 527 | 511 | db_bind_text(&ins, ":u", pFile->zUuid); |
| 528 | 512 | db_step(&ins); |
| 529 | 513 | db_reset(&ins); |
| 530 | 514 | } |
| 531 | 515 | db_finalize(&ins); |
| | @@ -542,11 +526,11 @@ |
| 542 | 526 | const char *z = db_column_text(&q, 0); |
| 543 | 527 | if( nD>0 && (fossil_strncmp(z, zD, nD-1)!=0 || z[nD-1]!='/') ){ |
| 544 | 528 | continue; |
| 545 | 529 | } |
| 546 | 530 | if( pRE && re_match(pRE, (const u8*)z, -1)==0 ) continue; |
| 547 | | - tree_add_node(&sTree, z+nD, 0); |
| 531 | + tree_add_node(&sTree, z, 0); |
| 548 | 532 | nFile++; |
| 549 | 533 | } |
| 550 | 534 | db_finalize(&q); |
| 551 | 535 | } |
| 552 | 536 | |
| | @@ -562,39 +546,52 @@ |
| 562 | 546 | |
| 563 | 547 | |
| 564 | 548 | /* Generate a multi-column table listing the contents of zD[] |
| 565 | 549 | ** directory. |
| 566 | 550 | */ |
| 567 | | - @ <pre> |
| 551 | + @ <div class="filetree"><ul> |
| 568 | 552 | if( nD ){ |
| 569 | | - cgi_printf("%.*h\n", nD, zD); |
| 570 | | - }else{ |
| 571 | | - @ . |
| 572 | | - } |
| 573 | | - for(p=sTree.pFirst; p; p=p->pNext){ |
| 574 | | - tree_indentation(p->pParent); |
| 575 | | - if( p->isLast ){ |
| 576 | | - cgi_append_content("└── ", 25); |
| 577 | | - }else{ |
| 578 | | - cgi_append_content("├── ", 25); |
| 579 | | - } |
| 553 | + char *zLink = href("%s", url_render(&sURI, "name", 0, 0, 0)); |
| 554 | + @ <li class="dir"> |
| 555 | + @ %z(zLink)%h(zProjectName)</a> |
| 556 | + }else{ |
| 557 | + @ <li class="dir subdir"> |
| 558 | + @ <a>%h(zProjectName)</a> |
| 559 | + } |
| 560 | + @ <ul> |
| 561 | + for(p=sTree.pFirst; p; p=p->pNext){ |
| 580 | 562 | if( p->isDir ){ |
| 581 | | - char *zName = mprintf("%s%T", zPrefix, p->zFullName); |
| 582 | | - char *zLink = href("%s", url_render(&sURI, "name", zName, 0, 0)); |
| 583 | | - fossil_free(zName); |
| 584 | | - @ %z(zLink)%h(p->zName)</a> |
| 563 | + if( nD && strlen(p->zFullName)==nD-1 ){ |
| 564 | + @ <li class="dir subdir"> |
| 565 | + }else{ |
| 566 | + @ <li class="dir"> |
| 567 | + } |
| 568 | + if( fossil_strcmp(p->zFullName, zD)==0 ){ |
| 569 | + @ <a>%h(p->zName)</a> |
| 570 | + }else{ |
| 571 | + char *zLink = href("%s", url_render(&sURI, "name", p->zFullName, 0, 0)); |
| 572 | + @ %z(zLink)%h(p->zName)</a> |
| 573 | + } |
| 574 | + @ <ul> |
| 585 | 575 | }else{ |
| 586 | 576 | char *zLink; |
| 587 | 577 | if( zCI ){ |
| 588 | 578 | zLink = href("%R/artifact/%s",p->zUuid); |
| 589 | 579 | }else{ |
| 590 | | - zLink = href("%R/finfo?name=%s%T",zPrefix,p->zFullName); |
| 580 | + zLink = href("%R/finfo?name=%T",p->zFullName); |
| 591 | 581 | } |
| 592 | | - @ %z(zLink)%h(p->zName)</a> |
| 582 | + @ <li class="%z(fileext_class(p->zName))">%z(zLink)%h(p->zName)</a> |
| 583 | + } |
| 584 | + if( p->isLast ){ |
| 585 | + int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0); |
| 586 | + while( nClose-- > 0 ){ |
| 587 | + @ </ul> |
| 588 | + } |
| 593 | 589 | } |
| 594 | 590 | } |
| 595 | | - @ </pre> |
| 591 | + @ </ul> |
| 592 | + @ </ul></div> |
| 596 | 593 | style_footer(); |
| 597 | 594 | |
| 598 | 595 | /* We could free memory used by sTree here if we needed to. But |
| 599 | 596 | ** the process is about to exit, so doing so would not really accomplish |
| 600 | 597 | ** anything useful. */ |
| 601 | 598 | |