Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Show the ages of files in the file tree viewer. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | age-in-file-tree |
| Files: | files | file ages | folders |
| SHA1: |
f8d54372e76ca5d3a8075be4b5d9b02c |
| User & Date: | drh 2014-12-16 16:32:07.139 |
Context
|
2014-12-16
| ||
| 18:43 | An attempt to improve the "age" display in the file tree viewer. ... (check-in: 3bd9e9bf7e user: drh tags: age-in-file-tree) | |
| 16:32 | Show the ages of files in the file tree viewer. ... (check-in: f8d54372e7 user: drh tags: age-in-file-tree) | |
| 14:46 | Enhance the "fileage" webpage so that it shows ages relative to current time rather than relative to the last checkin, so that it shows associated checkin comments, and so that it is styled using CSS. ... (check-in: 31b5dffa76 user: drh tags: trunk) | |
Changes
Changes to src/browse.c.
| ︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
struct FileTreeNode {
FileTreeNode *pNext; /* Next line in sequence */
FileTreeNode *pPrev; /* Previous line */
FileTreeNode *pParent; /* Directory containing this line */
char *zName; /* Name of this entry. The "tail" */
char *zFullName; /* Full pathname of this entry */
char *zUuid; /* SHA1 hash of this file. May be NULL. */
unsigned nFullName; /* Length of zFullName */
unsigned iLevel; /* Levels of parent directories */
u8 isDir; /* True if there are children */
u8 isLast; /* True if this is the last child of its parent */
};
/*
| > | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
struct FileTreeNode {
FileTreeNode *pNext; /* Next line in sequence */
FileTreeNode *pPrev; /* Previous line */
FileTreeNode *pParent; /* Directory containing this line */
char *zName; /* Name of this entry. The "tail" */
char *zFullName; /* Full pathname of this entry */
char *zUuid; /* SHA1 hash of this file. May be NULL. */
double mtime; /* Modification time for this entry */
unsigned nFullName; /* Length of zFullName */
unsigned iLevel; /* Levels of parent directories */
u8 isDir; /* True if there are children */
u8 isLast; /* True if this is the last child of its parent */
};
/*
|
| ︙ | ︙ | |||
329 330 331 332 333 334 335 | /* ** Add one or more new FileTreeNodes to the FileTree object so that the ** leaf object zPathname is at the end of the node list */ static void tree_add_node( FileTree *pTree, /* Tree into which nodes are added */ const char *zPath, /* The full pathname of file to add */ | | > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
/*
** Add one or more new FileTreeNodes to the FileTree object so that the
** leaf object zPathname is at the end of the node list
*/
static void tree_add_node(
FileTree *pTree, /* Tree into which nodes are added */
const char *zPath, /* The full pathname of file to add */
const char *zUuid, /* UUID of the file. Might be NULL. */
double mtime /* Modification time for this entry */
){
int i;
FileTreeNode *pParent;
FileTreeNode *pChild;
pChild = pTree->pLast;
pParent = pChild ? pChild->pParent : 0;
|
| ︙ | ︙ | |||
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
pNew->pPrev = pTree->pLast;
pNew->pNext = 0;
pNew->pParent = pParent;
pTree->pLast = pNew;
pNew->iLevel = pParent ? pParent->iLevel+1 : 0;
pNew->isDir = zPath[i]=='/';
pNew->isLast = 1;
while( zPath[i]=='/' ){ i++; }
pParent = pNew;
}
}
/*
** WEBPAGE: tree
**
** Query parameters:
| > > > > > > > | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
pNew->pPrev = pTree->pLast;
pNew->pNext = 0;
pNew->pParent = pParent;
pTree->pLast = pNew;
pNew->iLevel = pParent ? pParent->iLevel+1 : 0;
pNew->isDir = zPath[i]=='/';
pNew->isLast = 1;
pNew->mtime = mtime;
while( zPath[i]=='/' ){ i++; }
pParent = pNew;
}
while( pParent && pParent->pParent ){
if( pParent->pParent->mtime < pParent->mtime ){
pParent->pParent->mtime = pParent->mtime;
}
pParent = pParent->pParent;
}
}
/*
** WEBPAGE: tree
**
** Query parameters:
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
char *zD = fossil_strdup(P("name"));
int nD = zD ? strlen(zD)+1 : 0;
const char *zCI = P("ci");
int rid = 0;
char *zUuid = 0;
Blob dirname;
Manifest *pM = 0;
int nFile = 0; /* Number of files (or folders with "nofiles") */
int linkTrunk = 1; /* include link to "trunk" */
int linkTip = 1; /* include link to "tip" */
const char *zRE; /* the value for the re=REGEXP query parameter */
const char *zObjType; /* "files" by default or "folders" for "nofiles" */
char *zREx = ""; /* Extra parameters for path hyperlinks */
ReCompiled *pRE = 0; /* Compiled regular expression */
| > | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
char *zD = fossil_strdup(P("name"));
int nD = zD ? strlen(zD)+1 : 0;
const char *zCI = P("ci");
int rid = 0;
char *zUuid = 0;
Blob dirname;
Manifest *pM = 0;
double rNow = db_double(0.0,"SELECT julianday('now')");
int nFile = 0; /* Number of files (or folders with "nofiles") */
int linkTrunk = 1; /* include link to "trunk" */
int linkTip = 1; /* include link to "tip" */
const char *zRE; /* the value for the re=REGEXP query parameter */
const char *zObjType; /* "files" by default or "folders" for "nofiles" */
char *zREx = ""; /* Extra parameters for path hyperlinks */
ReCompiled *pRE = 0; /* Compiled regular expression */
|
| ︙ | ︙ | |||
505 506 507 508 509 510 511 |
style_submenu_element("Flat-View", "Flat-View", "%s",
url_render(&sURI, "type", "flat", 0, 0));
}
/* Compute the file hierarchy.
*/
if( zCI ){
| | < | | > | > > | < < < < < < < < < < < < < < < < < < < > > > > | | | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
style_submenu_element("Flat-View", "Flat-View", "%s",
url_render(&sURI, "type", "flat", 0, 0));
}
/* Compute the file hierarchy.
*/
if( zCI ){
Stmt q;
compute_fileage(rid, 0);
db_prepare(&q,
"SELECT filename.name, blob.uuid, fileage.mtime\n"
" FROM fileage, filename, blob\n"
" WHERE filename.fnid=fileage.fnid\n"
" AND blob.rid=fileage.fid\n"
" ORDER BY filename.name COLLATE nocase;"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zFile = db_column_text(&q,0);
const char *zUuid = db_column_text(&q,1);
double mtime = db_column_double(&q,2);
if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue;
tree_add_node(&sTree, zFile, zUuid, mtime);
nFile++;
}
db_finalize(&q);
}else{
Stmt q;
db_prepare(&q, "SELECT name FROM filename ORDER BY name COLLATE nocase");
while( db_step(&q)==SQLITE_ROW ){
const char *z = db_column_text(&q, 0);
if( nD>0 && (fossil_strncmp(z, zD, nD-1)!=0 || z[nD-1]!='/') ){
continue;
}
if( pRE && re_match(pRE, (const u8*)z, -1)==0 ) continue;
tree_add_node(&sTree, z, 0, 0.0);
nFile++;
}
db_finalize(&q);
}
if( showDirOnly ){
for(nFile=0, p=sTree.pFirst; p; p=p->pNext){
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
@ <ul>
for(p=sTree.pFirst, nDir=0; p; p=p->pNext){
const char *zLastClass = p->isLast ? " last" : "";
if( p->isDir ){
const char *zSubdirClass = p->nFullName==nD-1 ? " subdir" : "";
@ <li class="dir%s(zSubdirClass)%s(zLastClass)">
@ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
if( startExpanded || p->nFullName<=nD ){
@ <ul id="dir%d(nDir)">
}else{
@ <ul id="dir%d(nDir)" class="collapsed">
}
nDir++;
}else if( !showDirOnly ){
const char *zFileClass = fileext_class(p->zName);
char *zLink;
if( zCI ){
zLink = href("%R/artifact/%s",p->zUuid);
}else{
zLink = href("%R/finfo?name=%T",p->zFullName);
}
@ <li class="%z(zFileClass)%s(zLastClass)">%z(zLink)%h(p->zName)</a>
}
if( p->isLast ){
int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0);
while( nClose-- > 0 ){
@ </ul>
}
}
| > > > > > > > > | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
@ <ul>
for(p=sTree.pFirst, nDir=0; p; p=p->pNext){
const char *zLastClass = p->isLast ? " last" : "";
if( p->isDir ){
const char *zSubdirClass = p->nFullName==nD-1 ? " subdir" : "";
@ <li class="dir%s(zSubdirClass)%s(zLastClass)">
@ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
if( p->mtime>0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge) ago</div>
}
if( startExpanded || p->nFullName<=nD ){
@ <ul id="dir%d(nDir)">
}else{
@ <ul id="dir%d(nDir)" class="collapsed">
}
nDir++;
}else if( !showDirOnly ){
const char *zFileClass = fileext_class(p->zName);
char *zLink;
if( zCI ){
zLink = href("%R/artifact/%s",p->zUuid);
}else{
zLink = href("%R/finfo?name=%T",p->zFullName);
}
@ <li class="%z(zFileClass)%s(zLastClass)">%z(zLink)%h(p->zName)</a>
if( p->mtime>0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge) ago</div>
}
}
if( p->isLast ){
int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0);
while( nClose-- > 0 ){
@ </ul>
}
}
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
@ background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP\/\/\/yEhIf\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAIvlIKpxqcfmgOUvoaqDSCxrEEfF14GqFXImJZsu73wepJzVMNxrtNTj3NATMKhpwAAOw==);
@ background-position: center left;
@ background-repeat: no-repeat;
},
{ ".filetree .dir > a",
"tree-view directory links",
@ background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiIv\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo+jUs6b5Z/K4siDu5RPUFADs=);
},
{ "table.login_out",
"table format for login/out label/input table",
@ text-align: left;
@ margin-right: 10px;
@ margin-left: 10px;
@ margin-top: 10px;
| > > > > > | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
@ background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP\/\/\/yEhIf\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAIvlIKpxqcfmgOUvoaqDSCxrEEfF14GqFXImJZsu73wepJzVMNxrtNTj3NATMKhpwAAOw==);
@ background-position: center left;
@ background-repeat: no-repeat;
},
{ ".filetree .dir > a",
"tree-view directory links",
@ background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiIv\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo+jUs6b5Z/K4siDu5RPUFADs=);
},
{ "div.filetreeage",
"Last change floating display on the right",
@ clear: right;
@ float: right;
},
{ "table.login_out",
"table format for login/out label/input table",
@ text-align: left;
@ margin-right: 10px;
@ margin-left: 10px;
@ margin-top: 10px;
|
| ︙ | ︙ |