Overview
SHA1 Hash: | a20dcb5c26addae8473d1eb93f44f00c7dbe2c37 |
---|---|
Date: | 2008-02-04 19:08:55 |
User: | drh |
Comment: | Hyperlinks to directory browser pages on the pathname in the title of the file history viewer, finfo. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/browse.c from [6e4217591a] to [079928a8a6].
@@ -65,10 +65,39 @@ zOut = sqlite3_mprintf("/%.*s", i-n, &z[n]); sqlite3_result_text(context, zOut, i-n+1, sqlite3_free); } } +/* +** Given a pathname which is a relative path from the root of +** the repository to a file or directory, compute a string which +** is an HTML rendering of that path with hyperlinks on each +** directory component of the path where the hyperlink redirects +** to the "dir" page for the directory. +** +** There is no hyperlink on the file element of the path. +** +** The computed string is appended to the pOut blob. pOut should +** have already been initialized. +*/ +void hyperlinked_path(const char *zPath, Blob *pOut){ + int i, j; + char *zSep = ""; + + for(i=0; zPath[i]; i=j){ + for(j=i; zPath[j] && zPath[j]!='/'; j++){} + if( zPath[j] ){ + blob_appendf(pOut, "%s<a href=\"%s/dir?name=%#T\">%#h</a>", + zSep, g.zBaseURL, j, zPath, j-i, &zPath[i]); + }else{ + blob_appendf(pOut, "%s%h", zSep, &zPath[i]); + } + zSep = "/"; + while( zPath[j]=='/' ){ j++; } + } +} + /* ** WEBPAGE: dir ** ** Query parameters: @@ -92,35 +121,18 @@ /* If the name= parameter is an empty string, make it a NULL pointer */ if( zD && strlen(zD)==0 ){ zD = 0; } /* Compute the title of the page */ if( zD ){ - int i, j; - char *zCopy; Blob title; blob_zero(&title); - zCopy = sqlite3_mprintf("%s/", zD); - blob_appendf(&title, - "Files in directory <a href=\"%s/dir\"><i>root</i></a>", - g.zBaseURL - ); - for(i=0; zD[i]; i=j){ - for(j=i; zD[j] && zD[j]!='/'; j++){} - if( zD[j] ){ - zCopy[j] = 0; - blob_appendf(&title, "/<a href=\"%s/dir?name=%T\">%h</a>", - g.zBaseURL, zCopy, &zCopy[i]); - zCopy[j] = '/'; - }else{ - blob_appendf(&title, "/%h", &zCopy[i]); - } - while( zD[j]=='/' ){ j++; } - } + blob_appendf(&title, "Files in directory "); + hyperlinked_path(zD, &title); @ <h2>%s(blob_str(&title))</h2> blob_reset(&title); - zPrefix = zCopy; + zPrefix = mprintf("%h/", zD); }else{ @ <h2>Files in the top-level directory</h2> zPrefix = ""; }
Modified src/info.c from [4b91516559] to [33d2efae51].
@@ -445,10 +445,12 @@ */ void finfo_page(void){ Stmt q; const char *zFilename; char zPrevDate[20]; + Blob title; + login_check_credentials(); if( !g.okHistory ){ login_needed(); return; } style_header("File History"); zPrevDate[0] = 0; @@ -464,11 +466,15 @@ " AND b.rid=mlink.fid" " AND event.objid=mlink.mid" " ORDER BY event.mtime DESC", zFilename ); - @ <h2>History of %h(zFilename)</h2> + blob_zero(&title); + blob_appendf(&title, "History of "); + hyperlinked_path(zFilename, &title); + @ <h2>%b(&title)</h2> + blob_reset(&title); @ <table cellspacing=0 border=0 cellpadding=0> while( db_step(&q)==SQLITE_ROW ){ const char *zVers = db_column_text(&q, 0); const char *zUuid = db_column_text(&q, 1); const char *zDate = db_column_text(&q, 2);