Fossil SCM
Add the "dx" query parameter to the "dir" page, which if present causes links to file to use /doc instead of /file.
Commit
d4d10c016565837ca99e93b013e854c421606d5067cdbfa8ba4ab8fb07ed8f0a
Parent
2bdd36e4adf88b1…
1 file changed
+12
-2
+12
-2
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -133,10 +133,11 @@ | ||
| 133 | 133 | ** name=PATH Directory to display. Optional. Top-level if missing |
| 134 | 134 | ** re=REGEXP Show only files matching REGEXP |
| 135 | 135 | ** type=TYPE TYPE=flat: use this display |
| 136 | 136 | ** TYPE=tree: use the /tree display instead |
| 137 | 137 | ** noreadme Do not attempt to display the README file. |
| 138 | +** dx File links to go to /doc instead of /file or /finfo. | |
| 138 | 139 | */ |
| 139 | 140 | void page_dir(void){ |
| 140 | 141 | char *zD = fossil_strdup(P("name")); |
| 141 | 142 | int nD = zD ? strlen(zD)+1 : 0; |
| 142 | 143 | int mxLen; |
| @@ -153,10 +154,11 @@ | ||
| 153 | 154 | int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */ |
| 154 | 155 | int isBranchCI = 0; /* True if ci= refers to a branch name */ |
| 155 | 156 | char *zHeader = 0; |
| 156 | 157 | const char *zRegexp; /* The re= query parameter */ |
| 157 | 158 | char *zMatch; /* Extra title text describing the match */ |
| 159 | + int bDoc = PB("dx"); | |
| 158 | 160 | |
| 159 | 161 | if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
| 160 | 162 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 161 | 163 | login_check_credentials(); |
| 162 | 164 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| @@ -167,19 +169,21 @@ | ||
| 167 | 169 | |
| 168 | 170 | /* If a specific check-in is requested, fetch and parse it. If the |
| 169 | 171 | ** specific check-in does not exist, clear zCI. zCI==0 will cause all |
| 170 | 172 | ** files from all check-ins to be displayed. |
| 171 | 173 | */ |
| 174 | + if( bDoc && zCI==0 ) zCI = "trunk"; | |
| 172 | 175 | if( zCI ){ |
| 173 | 176 | pM = manifest_get_by_name(zCI, &rid); |
| 174 | 177 | if( pM ){ |
| 175 | 178 | int trunkRid = symbolic_name_to_rid("tag:trunk", "ci"); |
| 176 | 179 | linkTrunk = trunkRid && rid != trunkRid; |
| 177 | 180 | linkTip = rid != symbolic_name_to_rid("tip", "ci"); |
| 178 | 181 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 179 | 182 | isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0); |
| 180 | 183 | isBranchCI = branch_includes_uuid(zCI, zUuid); |
| 184 | + if( bDoc ) zCI = mprintf("%S", zUuid); | |
| 181 | 185 | Th_Store("current_checkin", zCI); |
| 182 | 186 | }else{ |
| 183 | 187 | zCI = 0; |
| 184 | 188 | } |
| 185 | 189 | } |
| @@ -238,11 +242,15 @@ | ||
| 238 | 242 | @ %s(zMatch)</h2> |
| 239 | 243 | }else { |
| 240 | 244 | @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\ |
| 241 | 245 | @ %s(zMatch)</h2> |
| 242 | 246 | } |
| 243 | - zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); | |
| 247 | + if( bDoc ){ | |
| 248 | + zSubdirLink = mprintf("%R/dir?dx&ci=%T&name=%T", zCI, zPrefix); | |
| 249 | + }else{ | |
| 250 | + zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); | |
| 251 | + } | |
| 244 | 252 | if( nD==0 ){ |
| 245 | 253 | style_submenu_element("File Ages", "%R/fileage?name=%T", zCI); |
| 246 | 254 | } |
| 247 | 255 | }else{ |
| 248 | 256 | @ in any check-in</h2> |
| @@ -331,11 +339,13 @@ | ||
| 331 | 339 | if( zFN[0]=='/' ){ |
| 332 | 340 | zFN++; |
| 333 | 341 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 334 | 342 | }else{ |
| 335 | 343 | const char *zLink; |
| 336 | - if( zCI ){ | |
| 344 | + if( bDoc ){ | |
| 345 | + zLink = href("%R/doc/%T/%T%T", zCI, zPrefix, zFN); | |
| 346 | + }else if( zCI ){ | |
| 337 | 347 | zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI); |
| 338 | 348 | }else{ |
| 339 | 349 | zLink = href("%R/finfo?name=%T%T",zPrefix,zFN); |
| 340 | 350 | } |
| 341 | 351 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 342 | 352 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -133,10 +133,11 @@ | |
| 133 | ** name=PATH Directory to display. Optional. Top-level if missing |
| 134 | ** re=REGEXP Show only files matching REGEXP |
| 135 | ** type=TYPE TYPE=flat: use this display |
| 136 | ** TYPE=tree: use the /tree display instead |
| 137 | ** noreadme Do not attempt to display the README file. |
| 138 | */ |
| 139 | void page_dir(void){ |
| 140 | char *zD = fossil_strdup(P("name")); |
| 141 | int nD = zD ? strlen(zD)+1 : 0; |
| 142 | int mxLen; |
| @@ -153,10 +154,11 @@ | |
| 153 | int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */ |
| 154 | int isBranchCI = 0; /* True if ci= refers to a branch name */ |
| 155 | char *zHeader = 0; |
| 156 | const char *zRegexp; /* The re= query parameter */ |
| 157 | char *zMatch; /* Extra title text describing the match */ |
| 158 | |
| 159 | if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
| 160 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 161 | login_check_credentials(); |
| 162 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| @@ -167,19 +169,21 @@ | |
| 167 | |
| 168 | /* If a specific check-in is requested, fetch and parse it. If the |
| 169 | ** specific check-in does not exist, clear zCI. zCI==0 will cause all |
| 170 | ** files from all check-ins to be displayed. |
| 171 | */ |
| 172 | if( zCI ){ |
| 173 | pM = manifest_get_by_name(zCI, &rid); |
| 174 | if( pM ){ |
| 175 | int trunkRid = symbolic_name_to_rid("tag:trunk", "ci"); |
| 176 | linkTrunk = trunkRid && rid != trunkRid; |
| 177 | linkTip = rid != symbolic_name_to_rid("tip", "ci"); |
| 178 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 179 | isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0); |
| 180 | isBranchCI = branch_includes_uuid(zCI, zUuid); |
| 181 | Th_Store("current_checkin", zCI); |
| 182 | }else{ |
| 183 | zCI = 0; |
| 184 | } |
| 185 | } |
| @@ -238,11 +242,15 @@ | |
| 238 | @ %s(zMatch)</h2> |
| 239 | }else { |
| 240 | @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\ |
| 241 | @ %s(zMatch)</h2> |
| 242 | } |
| 243 | zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); |
| 244 | if( nD==0 ){ |
| 245 | style_submenu_element("File Ages", "%R/fileage?name=%T", zCI); |
| 246 | } |
| 247 | }else{ |
| 248 | @ in any check-in</h2> |
| @@ -331,11 +339,13 @@ | |
| 331 | if( zFN[0]=='/' ){ |
| 332 | zFN++; |
| 333 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 334 | }else{ |
| 335 | const char *zLink; |
| 336 | if( zCI ){ |
| 337 | zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI); |
| 338 | }else{ |
| 339 | zLink = href("%R/finfo?name=%T%T",zPrefix,zFN); |
| 340 | } |
| 341 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 342 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -133,10 +133,11 @@ | |
| 133 | ** name=PATH Directory to display. Optional. Top-level if missing |
| 134 | ** re=REGEXP Show only files matching REGEXP |
| 135 | ** type=TYPE TYPE=flat: use this display |
| 136 | ** TYPE=tree: use the /tree display instead |
| 137 | ** noreadme Do not attempt to display the README file. |
| 138 | ** dx File links to go to /doc instead of /file or /finfo. |
| 139 | */ |
| 140 | void page_dir(void){ |
| 141 | char *zD = fossil_strdup(P("name")); |
| 142 | int nD = zD ? strlen(zD)+1 : 0; |
| 143 | int mxLen; |
| @@ -153,10 +154,11 @@ | |
| 154 | int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */ |
| 155 | int isBranchCI = 0; /* True if ci= refers to a branch name */ |
| 156 | char *zHeader = 0; |
| 157 | const char *zRegexp; /* The re= query parameter */ |
| 158 | char *zMatch; /* Extra title text describing the match */ |
| 159 | int bDoc = PB("dx"); |
| 160 | |
| 161 | if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
| 162 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 163 | login_check_credentials(); |
| 164 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| @@ -167,19 +169,21 @@ | |
| 169 | |
| 170 | /* If a specific check-in is requested, fetch and parse it. If the |
| 171 | ** specific check-in does not exist, clear zCI. zCI==0 will cause all |
| 172 | ** files from all check-ins to be displayed. |
| 173 | */ |
| 174 | if( bDoc && zCI==0 ) zCI = "trunk"; |
| 175 | if( zCI ){ |
| 176 | pM = manifest_get_by_name(zCI, &rid); |
| 177 | if( pM ){ |
| 178 | int trunkRid = symbolic_name_to_rid("tag:trunk", "ci"); |
| 179 | linkTrunk = trunkRid && rid != trunkRid; |
| 180 | linkTip = rid != symbolic_name_to_rid("tip", "ci"); |
| 181 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 182 | isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0); |
| 183 | isBranchCI = branch_includes_uuid(zCI, zUuid); |
| 184 | if( bDoc ) zCI = mprintf("%S", zUuid); |
| 185 | Th_Store("current_checkin", zCI); |
| 186 | }else{ |
| 187 | zCI = 0; |
| 188 | } |
| 189 | } |
| @@ -238,11 +242,15 @@ | |
| 242 | @ %s(zMatch)</h2> |
| 243 | }else { |
| 244 | @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\ |
| 245 | @ %s(zMatch)</h2> |
| 246 | } |
| 247 | if( bDoc ){ |
| 248 | zSubdirLink = mprintf("%R/dir?dx&ci=%T&name=%T", zCI, zPrefix); |
| 249 | }else{ |
| 250 | zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); |
| 251 | } |
| 252 | if( nD==0 ){ |
| 253 | style_submenu_element("File Ages", "%R/fileage?name=%T", zCI); |
| 254 | } |
| 255 | }else{ |
| 256 | @ in any check-in</h2> |
| @@ -331,11 +339,13 @@ | |
| 339 | if( zFN[0]=='/' ){ |
| 340 | zFN++; |
| 341 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 342 | }else{ |
| 343 | const char *zLink; |
| 344 | if( bDoc ){ |
| 345 | zLink = href("%R/doc/%T/%T%T", zCI, zPrefix, zFN); |
| 346 | }else if( zCI ){ |
| 347 | zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI); |
| 348 | }else{ |
| 349 | zLink = href("%R/finfo?name=%T%T",zPrefix,zFN); |
| 350 | } |
| 351 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 352 |