Fossil SCM
Add the /docdir page which is an alias for /dir with the "dx" query parameter.
Commit
5d7e153ff7cf87a07973ed17bd6df718821a72f0f708b2dd03a82c87779a20f1
Parent
d4d10c016565837…
1 file changed
+26
-6
+26
-6
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -116,10 +116,30 @@ | ||
| 116 | 116 | zSep = "/"; |
| 117 | 117 | while( zPath[j]=='/' ){ j++; } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | +/* | |
| 122 | +** WEBPAGE: docdir | |
| 123 | +** | |
| 124 | +** Show the files and subdirectories within a single directory of the | |
| 125 | +** source tree. This works like /dir except that links to files go to | |
| 126 | +** /doc (showing the file content directly, depending on mimetype) | |
| 127 | +** rather than to /file (which always shows the file embedded in a standard | |
| 128 | +** Fossil page frame). /docdir is a shorthand for /dir with the "dx" | |
| 129 | +** query parameter. | |
| 130 | +** | |
| 131 | +** Query parameters: | |
| 132 | +** | |
| 133 | +** ci=LABEL Show only files in this check-in. If omitted, the | |
| 134 | +** "trunk" directory is used. | |
| 135 | +** name=PATH Directory to display. Optional. Top-level if missing | |
| 136 | +** re=REGEXP Show only files matching REGEXP | |
| 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_docdir(void){ page_dir(); } | |
| 121 | 141 | |
| 122 | 142 | /* |
| 123 | 143 | ** WEBPAGE: dir |
| 124 | 144 | ** |
| 125 | 145 | ** Show the files and subdirectories within a single directory of the |
| @@ -154,11 +174,11 @@ | ||
| 154 | 174 | int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */ |
| 155 | 175 | int isBranchCI = 0; /* True if ci= refers to a branch name */ |
| 156 | 176 | char *zHeader = 0; |
| 157 | 177 | const char *zRegexp; /* The re= query parameter */ |
| 158 | 178 | char *zMatch; /* Extra title text describing the match */ |
| 159 | - int bDoc = PB("dx"); | |
| 179 | + int bDocDir = PB("dx") || strncmp(g.zPath, "docdir", 6)==0; | |
| 160 | 180 | |
| 161 | 181 | if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
| 162 | 182 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 163 | 183 | login_check_credentials(); |
| 164 | 184 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| @@ -169,21 +189,21 @@ | ||
| 169 | 189 | |
| 170 | 190 | /* If a specific check-in is requested, fetch and parse it. If the |
| 171 | 191 | ** specific check-in does not exist, clear zCI. zCI==0 will cause all |
| 172 | 192 | ** files from all check-ins to be displayed. |
| 173 | 193 | */ |
| 174 | - if( bDoc && zCI==0 ) zCI = "trunk"; | |
| 194 | + if( bDocDir && zCI==0 ) zCI = "trunk"; | |
| 175 | 195 | if( zCI ){ |
| 176 | 196 | pM = manifest_get_by_name(zCI, &rid); |
| 177 | 197 | if( pM ){ |
| 178 | 198 | int trunkRid = symbolic_name_to_rid("tag:trunk", "ci"); |
| 179 | 199 | linkTrunk = trunkRid && rid != trunkRid; |
| 180 | 200 | linkTip = rid != symbolic_name_to_rid("tip", "ci"); |
| 181 | 201 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 182 | 202 | isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0); |
| 183 | 203 | isBranchCI = branch_includes_uuid(zCI, zUuid); |
| 184 | - if( bDoc ) zCI = mprintf("%S", zUuid); | |
| 204 | + if( bDocDir ) zCI = mprintf("%S", zUuid); | |
| 185 | 205 | Th_Store("current_checkin", zCI); |
| 186 | 206 | }else{ |
| 187 | 207 | zCI = 0; |
| 188 | 208 | } |
| 189 | 209 | } |
| @@ -242,12 +262,12 @@ | ||
| 242 | 262 | @ %s(zMatch)</h2> |
| 243 | 263 | }else { |
| 244 | 264 | @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\ |
| 245 | 265 | @ %s(zMatch)</h2> |
| 246 | 266 | } |
| 247 | - if( bDoc ){ | |
| 248 | - zSubdirLink = mprintf("%R/dir?dx&ci=%T&name=%T", zCI, zPrefix); | |
| 267 | + if( bDocDir ){ | |
| 268 | + zSubdirLink = mprintf("%R/docdir?ci=%T&name=%T", zCI, zPrefix); | |
| 249 | 269 | }else{ |
| 250 | 270 | zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); |
| 251 | 271 | } |
| 252 | 272 | if( nD==0 ){ |
| 253 | 273 | style_submenu_element("File Ages", "%R/fileage?name=%T", zCI); |
| @@ -339,11 +359,11 @@ | ||
| 339 | 359 | if( zFN[0]=='/' ){ |
| 340 | 360 | zFN++; |
| 341 | 361 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 342 | 362 | }else{ |
| 343 | 363 | const char *zLink; |
| 344 | - if( bDoc ){ | |
| 364 | + if( bDocDir ){ | |
| 345 | 365 | zLink = href("%R/doc/%T/%T%T", zCI, zPrefix, zFN); |
| 346 | 366 | }else if( zCI ){ |
| 347 | 367 | zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI); |
| 348 | 368 | }else{ |
| 349 | 369 | zLink = href("%R/finfo?name=%T%T",zPrefix,zFN); |
| 350 | 370 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -116,10 +116,30 @@ | |
| 116 | zSep = "/"; |
| 117 | while( zPath[j]=='/' ){ j++; } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /* |
| 123 | ** WEBPAGE: dir |
| 124 | ** |
| 125 | ** Show the files and subdirectories within a single directory of the |
| @@ -154,11 +174,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; } |
| @@ -169,21 +189,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 | } |
| @@ -242,12 +262,12 @@ | |
| 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); |
| @@ -339,11 +359,11 @@ | |
| 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 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -116,10 +116,30 @@ | |
| 116 | zSep = "/"; |
| 117 | while( zPath[j]=='/' ){ j++; } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | ** WEBPAGE: docdir |
| 123 | ** |
| 124 | ** Show the files and subdirectories within a single directory of the |
| 125 | ** source tree. This works like /dir except that links to files go to |
| 126 | ** /doc (showing the file content directly, depending on mimetype) |
| 127 | ** rather than to /file (which always shows the file embedded in a standard |
| 128 | ** Fossil page frame). /docdir is a shorthand for /dir with the "dx" |
| 129 | ** query parameter. |
| 130 | ** |
| 131 | ** Query parameters: |
| 132 | ** |
| 133 | ** ci=LABEL Show only files in this check-in. If omitted, the |
| 134 | ** "trunk" directory is used. |
| 135 | ** name=PATH Directory to display. Optional. Top-level if missing |
| 136 | ** re=REGEXP Show only files matching REGEXP |
| 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_docdir(void){ page_dir(); } |
| 141 | |
| 142 | /* |
| 143 | ** WEBPAGE: dir |
| 144 | ** |
| 145 | ** Show the files and subdirectories within a single directory of the |
| @@ -154,11 +174,11 @@ | |
| 174 | int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */ |
| 175 | int isBranchCI = 0; /* True if ci= refers to a branch name */ |
| 176 | char *zHeader = 0; |
| 177 | const char *zRegexp; /* The re= query parameter */ |
| 178 | char *zMatch; /* Extra title text describing the match */ |
| 179 | int bDocDir = PB("dx") || strncmp(g.zPath, "docdir", 6)==0; |
| 180 | |
| 181 | if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
| 182 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 183 | login_check_credentials(); |
| 184 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| @@ -169,21 +189,21 @@ | |
| 189 | |
| 190 | /* If a specific check-in is requested, fetch and parse it. If the |
| 191 | ** specific check-in does not exist, clear zCI. zCI==0 will cause all |
| 192 | ** files from all check-ins to be displayed. |
| 193 | */ |
| 194 | if( bDocDir && zCI==0 ) zCI = "trunk"; |
| 195 | if( zCI ){ |
| 196 | pM = manifest_get_by_name(zCI, &rid); |
| 197 | if( pM ){ |
| 198 | int trunkRid = symbolic_name_to_rid("tag:trunk", "ci"); |
| 199 | linkTrunk = trunkRid && rid != trunkRid; |
| 200 | linkTip = rid != symbolic_name_to_rid("tip", "ci"); |
| 201 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 202 | isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0); |
| 203 | isBranchCI = branch_includes_uuid(zCI, zUuid); |
| 204 | if( bDocDir ) zCI = mprintf("%S", zUuid); |
| 205 | Th_Store("current_checkin", zCI); |
| 206 | }else{ |
| 207 | zCI = 0; |
| 208 | } |
| 209 | } |
| @@ -242,12 +262,12 @@ | |
| 262 | @ %s(zMatch)</h2> |
| 263 | }else { |
| 264 | @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\ |
| 265 | @ %s(zMatch)</h2> |
| 266 | } |
| 267 | if( bDocDir ){ |
| 268 | zSubdirLink = mprintf("%R/docdir?ci=%T&name=%T", zCI, zPrefix); |
| 269 | }else{ |
| 270 | zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix); |
| 271 | } |
| 272 | if( nD==0 ){ |
| 273 | style_submenu_element("File Ages", "%R/fileage?name=%T", zCI); |
| @@ -339,11 +359,11 @@ | |
| 359 | if( zFN[0]=='/' ){ |
| 360 | zFN++; |
| 361 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 362 | }else{ |
| 363 | const char *zLink; |
| 364 | if( bDocDir ){ |
| 365 | zLink = href("%R/doc/%T/%T%T", zCI, zPrefix, zFN); |
| 366 | }else if( zCI ){ |
| 367 | zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI); |
| 368 | }else{ |
| 369 | zLink = href("%R/finfo?name=%T%T",zPrefix,zFN); |
| 370 |