Fossil SCM

Add the /docdir page which is an alias for /dir with the "dx" query parameter.

drh 2023-08-27 18:42 trunk
Commit 5d7e153ff7cf87a07973ed17bd6df718821a72f0f708b2dd03a82c87779a20f1
1 file changed +26 -6
+26 -6
--- src/browse.c
+++ src/browse.c
@@ -116,10 +116,30 @@
116116
zSep = "/";
117117
while( zPath[j]=='/' ){ j++; }
118118
}
119119
}
120120
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(); }
121141
122142
/*
123143
** WEBPAGE: dir
124144
**
125145
** Show the files and subdirectories within a single directory of the
@@ -154,11 +174,11 @@
154174
int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */
155175
int isBranchCI = 0; /* True if ci= refers to a branch name */
156176
char *zHeader = 0;
157177
const char *zRegexp; /* The re= query parameter */
158178
char *zMatch; /* Extra title text describing the match */
159
- int bDoc = PB("dx");
179
+ int bDocDir = PB("dx") || strncmp(g.zPath, "docdir", 6)==0;
160180
161181
if( zCI && strlen(zCI)==0 ){ zCI = 0; }
162182
if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; }
163183
login_check_credentials();
164184
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -169,21 +189,21 @@
169189
170190
/* If a specific check-in is requested, fetch and parse it. If the
171191
** specific check-in does not exist, clear zCI. zCI==0 will cause all
172192
** files from all check-ins to be displayed.
173193
*/
174
- if( bDoc && zCI==0 ) zCI = "trunk";
194
+ if( bDocDir && zCI==0 ) zCI = "trunk";
175195
if( zCI ){
176196
pM = manifest_get_by_name(zCI, &rid);
177197
if( pM ){
178198
int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
179199
linkTrunk = trunkRid && rid != trunkRid;
180200
linkTip = rid != symbolic_name_to_rid("tip", "ci");
181201
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
182202
isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
183203
isBranchCI = branch_includes_uuid(zCI, zUuid);
184
- if( bDoc ) zCI = mprintf("%S", zUuid);
204
+ if( bDocDir ) zCI = mprintf("%S", zUuid);
185205
Th_Store("current_checkin", zCI);
186206
}else{
187207
zCI = 0;
188208
}
189209
}
@@ -242,12 +262,12 @@
242262
@ %s(zMatch)</h2>
243263
}else {
244264
@ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a>\
245265
@ %s(zMatch)</h2>
246266
}
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);
249269
}else{
250270
zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix);
251271
}
252272
if( nD==0 ){
253273
style_submenu_element("File Ages", "%R/fileage?name=%T", zCI);
@@ -339,11 +359,11 @@
339359
if( zFN[0]=='/' ){
340360
zFN++;
341361
@ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li>
342362
}else{
343363
const char *zLink;
344
- if( bDoc ){
364
+ if( bDocDir ){
345365
zLink = href("%R/doc/%T/%T%T", zCI, zPrefix, zFN);
346366
}else if( zCI ){
347367
zLink = href("%R/file?name=%T%T&ci=%T",zPrefix,zFN,zCI);
348368
}else{
349369
zLink = href("%R/finfo?name=%T%T",zPrefix,zFN);
350370
--- 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

Keyboard Shortcuts

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