Fossil SCM

In File Browser the file entries link to /file URLs corresp. to the given check-in; on File page provide back-links to the file's path directories.

ashepilko 2020-05-06 22:04 trunk
Commit 5c60071800e851f2433118ae0e21d37e62edba6376b95f46e74f868e83ec4a9e
3 files changed +1 -2 +35 -7 +3 -3
+1 -2
--- src/browse.c
+++ src/browse.c
@@ -282,12 +282,11 @@
282282
zFN++;
283283
@ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li>
284284
}else{
285285
const char *zLink;
286286
if( zCI ){
287
- const char *zUuid = db_column_text(&q, 1);
288
- zLink = href("%R/artifact/%!S",zUuid);
287
+ zLink = href("%R/file/%T%T?ci=%!S",zPrefix,zFN,zCI);
289288
}else{
290289
zLink = href("%R/finfo?name=%T%T",zPrefix,zFN);
291290
}
292291
@ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li>
293292
}
294293
--- src/browse.c
+++ src/browse.c
@@ -282,12 +282,11 @@
282 zFN++;
283 @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li>
284 }else{
285 const char *zLink;
286 if( zCI ){
287 const char *zUuid = db_column_text(&q, 1);
288 zLink = href("%R/artifact/%!S",zUuid);
289 }else{
290 zLink = href("%R/finfo?name=%T%T",zPrefix,zFN);
291 }
292 @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li>
293 }
294
--- src/browse.c
+++ src/browse.c
@@ -282,12 +282,11 @@
282 zFN++;
283 @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li>
284 }else{
285 const char *zLink;
286 if( zCI ){
287 zLink = href("%R/file/%T%T?ci=%!S",zPrefix,zFN,zCI);
 
288 }else{
289 zLink = href("%R/finfo?name=%T%T",zPrefix,zFN);
290 }
291 @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li>
292 }
293
+35 -7
--- src/info.c
+++ src/info.c
@@ -1362,10 +1362,11 @@
13621362
** * Comment & user
13631363
*/
13641364
int object_description(
13651365
int rid, /* The artifact ID */
13661366
u32 objdescFlags, /* Flags to control display */
1367
+ const char *zFileName, /* Explicit file name or 0 */
13671368
Blob *pDownloadName /* Fill with an appropriate download name */
13681369
){
13691370
Stmt q;
13701371
int cnt = 0;
13711372
int nWiki = 0;
@@ -1401,10 +1402,11 @@
14011402
const char *zVers = db_column_text(&q, 4);
14021403
int mPerm = db_column_int(&q, 5);
14031404
const char *zBr = db_column_text(&q, 6);
14041405
int szFile = db_column_int(&q,7);
14051406
int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0;
1407
+ if( zFileName && fossil_strcmp(zName,zFileName)!=0 ) continue;
14061408
if( sameFilename && !showDetail ){
14071409
if( cnt==1 ){
14081410
@ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
14091411
}
14101412
cnt++;
@@ -1747,13 +1749,13 @@
17471749
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
17481750
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
17491751
}else{
17501752
@ <h2>Differences From
17511753
@ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2>
1752
- object_description(v1, objdescFlags, 0);
1754
+ object_description(v1, objdescFlags,0, 0);
17531755
@ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2>
1754
- object_description(v2, objdescFlags, 0);
1756
+ object_description(v2, objdescFlags,0, 0);
17551757
}
17561758
if( pRe ){
17571759
@ <b>Only differences that match regular expression "%h(zRe)"
17581760
@ are shown.</b>
17591761
}
@@ -1937,11 +1939,11 @@
19371939
}else{
19381940
@ :</h2>
19391941
}
19401942
blob_zero(&downloadName);
19411943
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1942
- object_description(rid, objdescFlags, &downloadName);
1944
+ object_description(rid, objdescFlags, 0, &downloadName);
19431945
style_submenu_element("Download", "%s/raw/%T?name=%s",
19441946
g.zTop, blob_str(&downloadName), zUuid);
19451947
@ <hr />
19461948
content_get(rid, &content);
19471949
@ <blockquote><pre>
@@ -2127,20 +2129,34 @@
21272129
Blob downloadName;
21282130
int renderAsWiki = 0;
21292131
int renderAsHtml = 0;
21302132
int objType;
21312133
int asText;
2132
- const char *zUuid;
2134
+ const char *zUuid = 0;
21332135
u32 objdescFlags = OBJDESC_BASE;
21342136
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
21352137
int isFile = fossil_strcmp(g.zPath,"file")==0;
21362138
const char *zLn = P("ln");
21372139
const char *zName = P("name");
2140
+ const char *zCI = P("ci");
21382141
HQuery url;
2142
+ Blob dirname;
2143
+
2144
+ if( zCI ){
2145
+ login_check_credentials();
2146
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
21392147
2148
+ blob_zero(&dirname);
2149
+ hyperlinked_path(zName, &dirname, zCI, "dir", "");
2150
+ blob_reset(&dirname);
2151
+ }
21402152
url_initialize(&url, g.zPath);
2141
- rid = artifact_from_ci_and_filename(&url, 0);
2153
+ if( isFile&&zName ) {
2154
+ rid = artifact_from_ci_and_filename(0, "name");
2155
+ }else{
2156
+ rid = artifact_from_ci_and_filename(&url, 0);
2157
+ }
21422158
if( rid==0 ){
21432159
url_add_parameter(&url, "name", zName);
21442160
if( isFile ){
21452161
/* Do a top-level directory listing in /file mode if no argument
21462162
** specified */
@@ -2196,12 +2212,24 @@
21962212
if( descOnly || P("verbose")!=0 ){
21972213
url_add_parameter(&url, "verbose", "1");
21982214
objdescFlags |= OBJDESC_DETAIL;
21992215
}
22002216
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2217
+
22012218
if( isFile ){
2202
- @ <h2>Latest version of file '%h(zName)':</h2>
2219
+ if( zCI ){
2220
+ const char *zPath;
2221
+ Blob path;
2222
+ blob_zero(&path);
2223
+ hyperlinked_path(zName, &path, zCI, "dir", "");
2224
+ zPath = blob_str(&path);
2225
+ @ <h2>File %s(zPath) of check-in [%z(href("/info/%!S",zCI))%S(zCI)</a>]
2226
+ @ </h2>
2227
+ blob_reset(&path);
2228
+ }else{
2229
+ @ <h2>Latest version of file '%h(zName)':</h2>
2230
+ }
22032231
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
22042232
}else{
22052233
@ <h2>Artifact
22062234
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
22072235
if( g.perm.Setup ){
@@ -2211,11 +2239,11 @@
22112239
}
22122240
}
22132241
blob_zero(&downloadName);
22142242
asText = P("txt")!=0;
22152243
if( asText ) objdescFlags &= ~OBJDESC_BASE;
2216
- objType = object_description(rid, objdescFlags, &downloadName);
2244
+ objType = object_description(rid, objdescFlags, (isFile ? zName : 0),&downloadName);
22172245
if( !descOnly && P("download")!=0 ){
22182246
cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
22192247
db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
22202248
/*NOTREACHED*/
22212249
}
22222250
--- src/info.c
+++ src/info.c
@@ -1362,10 +1362,11 @@
1362 ** * Comment & user
1363 */
1364 int object_description(
1365 int rid, /* The artifact ID */
1366 u32 objdescFlags, /* Flags to control display */
 
1367 Blob *pDownloadName /* Fill with an appropriate download name */
1368 ){
1369 Stmt q;
1370 int cnt = 0;
1371 int nWiki = 0;
@@ -1401,10 +1402,11 @@
1401 const char *zVers = db_column_text(&q, 4);
1402 int mPerm = db_column_int(&q, 5);
1403 const char *zBr = db_column_text(&q, 6);
1404 int szFile = db_column_int(&q,7);
1405 int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0;
 
1406 if( sameFilename && !showDetail ){
1407 if( cnt==1 ){
1408 @ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
1409 }
1410 cnt++;
@@ -1747,13 +1749,13 @@
1747 @ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
1748 @ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
1749 }else{
1750 @ <h2>Differences From
1751 @ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2>
1752 object_description(v1, objdescFlags, 0);
1753 @ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2>
1754 object_description(v2, objdescFlags, 0);
1755 }
1756 if( pRe ){
1757 @ <b>Only differences that match regular expression "%h(zRe)"
1758 @ are shown.</b>
1759 }
@@ -1937,11 +1939,11 @@
1937 }else{
1938 @ :</h2>
1939 }
1940 blob_zero(&downloadName);
1941 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1942 object_description(rid, objdescFlags, &downloadName);
1943 style_submenu_element("Download", "%s/raw/%T?name=%s",
1944 g.zTop, blob_str(&downloadName), zUuid);
1945 @ <hr />
1946 content_get(rid, &content);
1947 @ <blockquote><pre>
@@ -2127,20 +2129,34 @@
2127 Blob downloadName;
2128 int renderAsWiki = 0;
2129 int renderAsHtml = 0;
2130 int objType;
2131 int asText;
2132 const char *zUuid;
2133 u32 objdescFlags = OBJDESC_BASE;
2134 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2135 int isFile = fossil_strcmp(g.zPath,"file")==0;
2136 const char *zLn = P("ln");
2137 const char *zName = P("name");
 
2138 HQuery url;
 
 
 
 
 
2139
 
 
 
 
2140 url_initialize(&url, g.zPath);
2141 rid = artifact_from_ci_and_filename(&url, 0);
 
 
 
 
2142 if( rid==0 ){
2143 url_add_parameter(&url, "name", zName);
2144 if( isFile ){
2145 /* Do a top-level directory listing in /file mode if no argument
2146 ** specified */
@@ -2196,12 +2212,24 @@
2196 if( descOnly || P("verbose")!=0 ){
2197 url_add_parameter(&url, "verbose", "1");
2198 objdescFlags |= OBJDESC_DETAIL;
2199 }
2200 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
 
2201 if( isFile ){
2202 @ <h2>Latest version of file '%h(zName)':</h2>
 
 
 
 
 
 
 
 
 
 
 
2203 style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
2204 }else{
2205 @ <h2>Artifact
2206 style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
2207 if( g.perm.Setup ){
@@ -2211,11 +2239,11 @@
2211 }
2212 }
2213 blob_zero(&downloadName);
2214 asText = P("txt")!=0;
2215 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2216 objType = object_description(rid, objdescFlags, &downloadName);
2217 if( !descOnly && P("download")!=0 ){
2218 cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
2219 db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
2220 /*NOTREACHED*/
2221 }
2222
--- src/info.c
+++ src/info.c
@@ -1362,10 +1362,11 @@
1362 ** * Comment & user
1363 */
1364 int object_description(
1365 int rid, /* The artifact ID */
1366 u32 objdescFlags, /* Flags to control display */
1367 const char *zFileName, /* Explicit file name or 0 */
1368 Blob *pDownloadName /* Fill with an appropriate download name */
1369 ){
1370 Stmt q;
1371 int cnt = 0;
1372 int nWiki = 0;
@@ -1401,10 +1402,11 @@
1402 const char *zVers = db_column_text(&q, 4);
1403 int mPerm = db_column_int(&q, 5);
1404 const char *zBr = db_column_text(&q, 6);
1405 int szFile = db_column_int(&q,7);
1406 int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0;
1407 if( zFileName && fossil_strcmp(zName,zFileName)!=0 ) continue;
1408 if( sameFilename && !showDetail ){
1409 if( cnt==1 ){
1410 @ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
1411 }
1412 cnt++;
@@ -1747,13 +1749,13 @@
1749 @ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
1750 @ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
1751 }else{
1752 @ <h2>Differences From
1753 @ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2>
1754 object_description(v1, objdescFlags,0, 0);
1755 @ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2>
1756 object_description(v2, objdescFlags,0, 0);
1757 }
1758 if( pRe ){
1759 @ <b>Only differences that match regular expression "%h(zRe)"
1760 @ are shown.</b>
1761 }
@@ -1937,11 +1939,11 @@
1939 }else{
1940 @ :</h2>
1941 }
1942 blob_zero(&downloadName);
1943 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1944 object_description(rid, objdescFlags, 0, &downloadName);
1945 style_submenu_element("Download", "%s/raw/%T?name=%s",
1946 g.zTop, blob_str(&downloadName), zUuid);
1947 @ <hr />
1948 content_get(rid, &content);
1949 @ <blockquote><pre>
@@ -2127,20 +2129,34 @@
2129 Blob downloadName;
2130 int renderAsWiki = 0;
2131 int renderAsHtml = 0;
2132 int objType;
2133 int asText;
2134 const char *zUuid = 0;
2135 u32 objdescFlags = OBJDESC_BASE;
2136 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2137 int isFile = fossil_strcmp(g.zPath,"file")==0;
2138 const char *zLn = P("ln");
2139 const char *zName = P("name");
2140 const char *zCI = P("ci");
2141 HQuery url;
2142 Blob dirname;
2143
2144 if( zCI ){
2145 login_check_credentials();
2146 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2147
2148 blob_zero(&dirname);
2149 hyperlinked_path(zName, &dirname, zCI, "dir", "");
2150 blob_reset(&dirname);
2151 }
2152 url_initialize(&url, g.zPath);
2153 if( isFile&&zName ) {
2154 rid = artifact_from_ci_and_filename(0, "name");
2155 }else{
2156 rid = artifact_from_ci_and_filename(&url, 0);
2157 }
2158 if( rid==0 ){
2159 url_add_parameter(&url, "name", zName);
2160 if( isFile ){
2161 /* Do a top-level directory listing in /file mode if no argument
2162 ** specified */
@@ -2196,12 +2212,24 @@
2212 if( descOnly || P("verbose")!=0 ){
2213 url_add_parameter(&url, "verbose", "1");
2214 objdescFlags |= OBJDESC_DETAIL;
2215 }
2216 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2217
2218 if( isFile ){
2219 if( zCI ){
2220 const char *zPath;
2221 Blob path;
2222 blob_zero(&path);
2223 hyperlinked_path(zName, &path, zCI, "dir", "");
2224 zPath = blob_str(&path);
2225 @ <h2>File %s(zPath) of check-in [%z(href("/info/%!S",zCI))%S(zCI)</a>]
2226 @ </h2>
2227 blob_reset(&path);
2228 }else{
2229 @ <h2>Latest version of file '%h(zName)':</h2>
2230 }
2231 style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
2232 }else{
2233 @ <h2>Artifact
2234 style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
2235 if( g.perm.Setup ){
@@ -2211,11 +2239,11 @@
2239 }
2240 }
2241 blob_zero(&downloadName);
2242 asText = P("txt")!=0;
2243 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2244 objType = object_description(rid, objdescFlags, (isFile ? zName : 0),&downloadName);
2245 if( !descOnly && P("download")!=0 ){
2246 cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
2247 db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
2248 /*NOTREACHED*/
2249 }
2250
+3 -3
--- src/name.c
+++ src/name.c
@@ -614,11 +614,11 @@
614614
while( db_step(&q)==SQLITE_ROW ){
615615
const char *zUuid = db_column_text(&q, 0);
616616
int rid = db_column_int(&q, 1);
617617
@ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
618618
@ %s(zUuid)</a> -
619
- object_description(rid, 0, 0);
619
+ object_description(rid, 0, 0, 0);
620620
@ </p></li>
621621
}
622622
db_finalize(&q);
623623
db_prepare(&q,
624624
" SELECT tkt_rid, tkt_uuid, title"
@@ -636,11 +636,11 @@
636636
@ <ul></ul>
637637
@ Ticket
638638
hyperlink_to_uuid(zUuid);
639639
@ - %h(zTitle).
640640
@ <ul><li>
641
- object_description(rid, 0, 0);
641
+ object_description(rid, 0, 0, 0);
642642
@ </li></ul>
643643
@ </p></li>
644644
}
645645
db_finalize(&q);
646646
db_prepare(&q,
@@ -652,11 +652,11 @@
652652
int rid = db_column_int(&q, 0);
653653
const char* zUuid = db_column_text(&q, 1);
654654
@ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
655655
@ %s(zUuid)</a> -
656656
@ <ul><li>
657
- object_description(rid, 0, 0);
657
+ object_description(rid, 0, 0, 0);
658658
@ </li></ul>
659659
@ </p></li>
660660
}
661661
@ </ol>
662662
db_finalize(&q);
663663
--- src/name.c
+++ src/name.c
@@ -614,11 +614,11 @@
614 while( db_step(&q)==SQLITE_ROW ){
615 const char *zUuid = db_column_text(&q, 0);
616 int rid = db_column_int(&q, 1);
617 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
618 @ %s(zUuid)</a> -
619 object_description(rid, 0, 0);
620 @ </p></li>
621 }
622 db_finalize(&q);
623 db_prepare(&q,
624 " SELECT tkt_rid, tkt_uuid, title"
@@ -636,11 +636,11 @@
636 @ <ul></ul>
637 @ Ticket
638 hyperlink_to_uuid(zUuid);
639 @ - %h(zTitle).
640 @ <ul><li>
641 object_description(rid, 0, 0);
642 @ </li></ul>
643 @ </p></li>
644 }
645 db_finalize(&q);
646 db_prepare(&q,
@@ -652,11 +652,11 @@
652 int rid = db_column_int(&q, 0);
653 const char* zUuid = db_column_text(&q, 1);
654 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
655 @ %s(zUuid)</a> -
656 @ <ul><li>
657 object_description(rid, 0, 0);
658 @ </li></ul>
659 @ </p></li>
660 }
661 @ </ol>
662 db_finalize(&q);
663
--- src/name.c
+++ src/name.c
@@ -614,11 +614,11 @@
614 while( db_step(&q)==SQLITE_ROW ){
615 const char *zUuid = db_column_text(&q, 0);
616 int rid = db_column_int(&q, 1);
617 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
618 @ %s(zUuid)</a> -
619 object_description(rid, 0, 0, 0);
620 @ </p></li>
621 }
622 db_finalize(&q);
623 db_prepare(&q,
624 " SELECT tkt_rid, tkt_uuid, title"
@@ -636,11 +636,11 @@
636 @ <ul></ul>
637 @ Ticket
638 hyperlink_to_uuid(zUuid);
639 @ - %h(zTitle).
640 @ <ul><li>
641 object_description(rid, 0, 0, 0);
642 @ </li></ul>
643 @ </p></li>
644 }
645 db_finalize(&q);
646 db_prepare(&q,
@@ -652,11 +652,11 @@
652 int rid = db_column_int(&q, 0);
653 const char* zUuid = db_column_text(&q, 1);
654 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
655 @ %s(zUuid)</a> -
656 @ <ul><li>
657 object_description(rid, 0, 0, 0);
658 @ </li></ul>
659 @ </p></li>
660 }
661 @ </ol>
662 db_finalize(&q);
663

Keyboard Shortcuts

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