Fossil SCM

Carry the file browsing UX improvements through into the /dir page.

drh 2020-05-11 20:13 trunk
Commit 4977765e6cc5dcda61ccd5516d4f2f850e45e9d9d2b7e615a22565f626c5cf34
2 files changed +43 -28 +2 -2
+43 -28
--- src/browse.c
+++ src/browse.c
@@ -142,17 +142,17 @@
142142
char *zPrefix;
143143
Stmt q;
144144
const char *zCI = P("ci");
145145
int rid = 0;
146146
char *zUuid = 0;
147
- Blob dirname;
148147
Manifest *pM = 0;
149148
const char *zSubdirLink;
150149
int linkTrunk = 1;
151150
int linkTip = 1;
152151
HQuery sURI;
153152
int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */
153
+ int isBranchCI = 0; /* True if ci= refers to a branch name */
154154
char *zHeader = 0;
155155
156156
if( zCI && strlen(zCI)==0 ){ zCI = 0; }
157157
if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; }
158158
login_check_credentials();
@@ -172,22 +172,35 @@
172172
int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
173173
linkTrunk = trunkRid && rid != trunkRid;
174174
linkTip = rid != symbolic_name_to_rid("tip", "ci");
175175
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176176
isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
177
+ isBranchCI = db_exists(
178
+ "SELECT 1 FROM tagxref, blob"
179
+ " WHERE blob.uuid=%Q AND tagxref.rid=blob.rid"
180
+ " AND tagxref.value=%Q AND tagxref.tagtype>0"
181
+ " AND tagxref.tagid=%d",
182
+ zUuid, zCI, TAG_BRANCH
183
+ );
177184
}else{
178185
zCI = 0;
179186
}
180187
}
181188
182189
assert( isSymbolicCI==0 || (zCI!=0 && zCI[0]!=0) );
183
- if( isSymbolicCI ) {
184
- zHeader = mprintf("%s at %s", (zD ? zD : "Files"), zCI);
185
- }else if( zUuid && strlen(zUuid) ){
186
- zHeader = mprintf("%s at [%S]", (zD ? zD : "Files"), zUuid);
190
+ if( zD==0 ){
191
+ if( zCI ){
192
+ zHeader = mprintf("Top-level Files of %s", zCI);
193
+ }else{
194
+ zHeader = mprintf("All Top-level Files");
195
+ }
187196
}else{
188
- zHeader = mprintf("%s", (zD ? zD : "All Files"));
197
+ if( zCI ){
198
+ zHeader = mprintf("Files in %s/ of %s", zD, zCI);
199
+ }else{
200
+ zHeader = mprintf("All File in %s/", zD);
201
+ }
189202
}
190203
style_header("%s", zHeader);
191204
fossil_free(zHeader);
192205
style_adunit_config(ADUNIT_RIGHT_OK);
193206
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
@@ -194,47 +207,49 @@
194207
pathelementFunc, 0, 0);
195208
url_initialize(&sURI, "dir");
196209
cgi_query_parameters_to_url(&sURI);
197210
198211
/* Compute the title of the page */
199
- blob_zero(&dirname);
200212
if( zD ){
201
- blob_append(&dirname, "in directory ", -1);
213
+ Blob dirname;
214
+ blob_init(&dirname, 0, 0);
202215
hyperlinked_path(zD, &dirname, zCI, "dir", "", 0);
216
+ @ <h2>Files in directory %s(blob_str(&dirname)) \
217
+ blob_reset(&dirname);
203218
zPrefix = mprintf("%s/", zD);
204219
style_submenu_element("Top-Level", "%s",
205220
url_render(&sURI, "name", 0, 0, 0));
206221
}else{
207
- blob_append(&dirname, "in the top-level directory", -1);
222
+ @ <h2>Files in the top-level directory \
208223
zPrefix = "";
209224
}
225
+ if( zCI ){
226
+ if( fossil_strcmp(zCI,"tip")==0 ){
227
+ @ from the %z(href("%R/info?name=%T",zCI))latest check-in</a></h2>
228
+ }else if( isBranchCI ){
229
+ @ from the %z(href("%R/info?name=%T",zCI))latest check-in</a> \
230
+ @ of branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2>
231
+ }else {
232
+ @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a></h2>
233
+ }
234
+ zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix);
235
+ if( nD==0 ){
236
+ style_submenu_element("File Ages", "%R/fileage?name=%!S", zUuid);
237
+ }
238
+ }else{
239
+ @ in any check-in</h2>
240
+ zSubdirLink = mprintf("%R/dir?name=%T", zPrefix);
241
+ }
210242
if( linkTrunk ){
211243
style_submenu_element("Trunk", "%s",
212244
url_render(&sURI, "ci", "trunk", 0, 0));
213245
}
214246
if( linkTip ){
215247
style_submenu_element("Tip", "%s", url_render(&sURI, "ci", "tip", 0, 0));
216248
}
217
- if( zCI ){
218
- @ <h2>Files at check-in [%z(href("vinfo?name=%!S",zUuid))%S(zUuid)</a>]
219
- @ %s(blob_str(&dirname))
220
- if( zD ){
221
- @ &nbsp;&nbsp;%z(href("%R/timeline?chng=%T/*", zD))[history]</a>
222
- }
223
- @ </h2>
224
- zSubdirLink = mprintf("%R/dir?ci=%!S&name=%T", zUuid, zPrefix);
225
- if( nD==0 ){
226
- style_submenu_element("File Ages", "%R/fileage?name=%!S", zUuid);
227
- }
228
- }else{
229
- @ <h2>All files known in the repository
230
- @ %s(blob_str(&dirname))
231
- if( zD ){
232
- @ &nbsp;&nbsp;%z(href("%R/timeline?chng=%T/*", zD))[history]</a>
233
- }
234
- @ </h2>
235
- zSubdirLink = mprintf("%R/dir?name=%T", zPrefix);
249
+ if( zD ){
250
+ style_submenu_element("History","%R/timeline?chng=%T/*", zD);
236251
}
237252
style_submenu_element("All", "%s", url_render(&sURI, "ci", 0, 0, 0));
238253
style_submenu_element("Tree-View", "%s",
239254
url_render(&sURI, "type", "tree", 0, 0));
240255
241256
--- src/browse.c
+++ src/browse.c
@@ -142,17 +142,17 @@
142 char *zPrefix;
143 Stmt q;
144 const char *zCI = P("ci");
145 int rid = 0;
146 char *zUuid = 0;
147 Blob dirname;
148 Manifest *pM = 0;
149 const char *zSubdirLink;
150 int linkTrunk = 1;
151 int linkTip = 1;
152 HQuery sURI;
153 int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */
 
154 char *zHeader = 0;
155
156 if( zCI && strlen(zCI)==0 ){ zCI = 0; }
157 if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; }
158 login_check_credentials();
@@ -172,22 +172,35 @@
172 int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
173 linkTrunk = trunkRid && rid != trunkRid;
174 linkTip = rid != symbolic_name_to_rid("tip", "ci");
175 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
 
 
 
 
 
 
 
177 }else{
178 zCI = 0;
179 }
180 }
181
182 assert( isSymbolicCI==0 || (zCI!=0 && zCI[0]!=0) );
183 if( isSymbolicCI ) {
184 zHeader = mprintf("%s at %s", (zD ? zD : "Files"), zCI);
185 }else if( zUuid && strlen(zUuid) ){
186 zHeader = mprintf("%s at [%S]", (zD ? zD : "Files"), zUuid);
 
 
187 }else{
188 zHeader = mprintf("%s", (zD ? zD : "All Files"));
 
 
 
 
189 }
190 style_header("%s", zHeader);
191 fossil_free(zHeader);
192 style_adunit_config(ADUNIT_RIGHT_OK);
193 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
@@ -194,47 +207,49 @@
194 pathelementFunc, 0, 0);
195 url_initialize(&sURI, "dir");
196 cgi_query_parameters_to_url(&sURI);
197
198 /* Compute the title of the page */
199 blob_zero(&dirname);
200 if( zD ){
201 blob_append(&dirname, "in directory ", -1);
 
202 hyperlinked_path(zD, &dirname, zCI, "dir", "", 0);
 
 
203 zPrefix = mprintf("%s/", zD);
204 style_submenu_element("Top-Level", "%s",
205 url_render(&sURI, "name", 0, 0, 0));
206 }else{
207 blob_append(&dirname, "in the top-level directory", -1);
208 zPrefix = "";
209 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210 if( linkTrunk ){
211 style_submenu_element("Trunk", "%s",
212 url_render(&sURI, "ci", "trunk", 0, 0));
213 }
214 if( linkTip ){
215 style_submenu_element("Tip", "%s", url_render(&sURI, "ci", "tip", 0, 0));
216 }
217 if( zCI ){
218 @ <h2>Files at check-in [%z(href("vinfo?name=%!S",zUuid))%S(zUuid)</a>]
219 @ %s(blob_str(&dirname))
220 if( zD ){
221 @ &nbsp;&nbsp;%z(href("%R/timeline?chng=%T/*", zD))[history]</a>
222 }
223 @ </h2>
224 zSubdirLink = mprintf("%R/dir?ci=%!S&name=%T", zUuid, zPrefix);
225 if( nD==0 ){
226 style_submenu_element("File Ages", "%R/fileage?name=%!S", zUuid);
227 }
228 }else{
229 @ <h2>All files known in the repository
230 @ %s(blob_str(&dirname))
231 if( zD ){
232 @ &nbsp;&nbsp;%z(href("%R/timeline?chng=%T/*", zD))[history]</a>
233 }
234 @ </h2>
235 zSubdirLink = mprintf("%R/dir?name=%T", zPrefix);
236 }
237 style_submenu_element("All", "%s", url_render(&sURI, "ci", 0, 0, 0));
238 style_submenu_element("Tree-View", "%s",
239 url_render(&sURI, "type", "tree", 0, 0));
240
241
--- src/browse.c
+++ src/browse.c
@@ -142,17 +142,17 @@
142 char *zPrefix;
143 Stmt q;
144 const char *zCI = P("ci");
145 int rid = 0;
146 char *zUuid = 0;
 
147 Manifest *pM = 0;
148 const char *zSubdirLink;
149 int linkTrunk = 1;
150 int linkTip = 1;
151 HQuery sURI;
152 int isSymbolicCI = 0; /* ci= is symbolic name, not a hash prefix */
153 int isBranchCI = 0; /* True if ci= refers to a branch name */
154 char *zHeader = 0;
155
156 if( zCI && strlen(zCI)==0 ){ zCI = 0; }
157 if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; }
158 login_check_credentials();
@@ -172,22 +172,35 @@
172 int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
173 linkTrunk = trunkRid && rid != trunkRid;
174 linkTip = rid != symbolic_name_to_rid("tip", "ci");
175 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
177 isBranchCI = db_exists(
178 "SELECT 1 FROM tagxref, blob"
179 " WHERE blob.uuid=%Q AND tagxref.rid=blob.rid"
180 " AND tagxref.value=%Q AND tagxref.tagtype>0"
181 " AND tagxref.tagid=%d",
182 zUuid, zCI, TAG_BRANCH
183 );
184 }else{
185 zCI = 0;
186 }
187 }
188
189 assert( isSymbolicCI==0 || (zCI!=0 && zCI[0]!=0) );
190 if( zD==0 ){
191 if( zCI ){
192 zHeader = mprintf("Top-level Files of %s", zCI);
193 }else{
194 zHeader = mprintf("All Top-level Files");
195 }
196 }else{
197 if( zCI ){
198 zHeader = mprintf("Files in %s/ of %s", zD, zCI);
199 }else{
200 zHeader = mprintf("All File in %s/", zD);
201 }
202 }
203 style_header("%s", zHeader);
204 fossil_free(zHeader);
205 style_adunit_config(ADUNIT_RIGHT_OK);
206 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
@@ -194,47 +207,49 @@
207 pathelementFunc, 0, 0);
208 url_initialize(&sURI, "dir");
209 cgi_query_parameters_to_url(&sURI);
210
211 /* Compute the title of the page */
 
212 if( zD ){
213 Blob dirname;
214 blob_init(&dirname, 0, 0);
215 hyperlinked_path(zD, &dirname, zCI, "dir", "", 0);
216 @ <h2>Files in directory %s(blob_str(&dirname)) \
217 blob_reset(&dirname);
218 zPrefix = mprintf("%s/", zD);
219 style_submenu_element("Top-Level", "%s",
220 url_render(&sURI, "name", 0, 0, 0));
221 }else{
222 @ <h2>Files in the top-level directory \
223 zPrefix = "";
224 }
225 if( zCI ){
226 if( fossil_strcmp(zCI,"tip")==0 ){
227 @ from the %z(href("%R/info?name=%T",zCI))latest check-in</a></h2>
228 }else if( isBranchCI ){
229 @ from the %z(href("%R/info?name=%T",zCI))latest check-in</a> \
230 @ of branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2>
231 }else {
232 @ of check-in %z(href("%R/info?name=%T",zCI))%h(zCI)</a></h2>
233 }
234 zSubdirLink = mprintf("%R/dir?ci=%T&name=%T", zCI, zPrefix);
235 if( nD==0 ){
236 style_submenu_element("File Ages", "%R/fileage?name=%!S", zUuid);
237 }
238 }else{
239 @ in any check-in</h2>
240 zSubdirLink = mprintf("%R/dir?name=%T", zPrefix);
241 }
242 if( linkTrunk ){
243 style_submenu_element("Trunk", "%s",
244 url_render(&sURI, "ci", "trunk", 0, 0));
245 }
246 if( linkTip ){
247 style_submenu_element("Tip", "%s", url_render(&sURI, "ci", "tip", 0, 0));
248 }
249 if( zD ){
250 style_submenu_element("History","%R/timeline?chng=%T/*", zD);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251 }
252 style_submenu_element("All", "%s", url_render(&sURI, "ci", 0, 0, 0));
253 style_submenu_element("Tree-View", "%s",
254 url_render(&sURI, "type", "tree", 0, 0));
255
256
+2 -2
--- src/info.c
+++ src/info.c
@@ -2225,12 +2225,12 @@
22252225
22262226
asText = P("txt")!=0;
22272227
if( isFile ){
22282228
if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
22292229
zCI = "tip";
2230
- @ <h2>Latest version of file \
2231
- @ '%z(href("%R/finfo?name=%T&m=%T",zName,zCI))%h(zName)</a>':</h2>
2230
+ @ <h2>File %z(href("%R/finfo?name=%T&m=tip",zName))%h(zName)</a>
2231
+ @ from the %z(href("%R/info/tip"))latest check-in</a></h2>
22322232
}else{
22332233
const char *zPath;
22342234
Blob path;
22352235
blob_zero(&path);
22362236
hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO);
22372237
--- src/info.c
+++ src/info.c
@@ -2225,12 +2225,12 @@
2225
2226 asText = P("txt")!=0;
2227 if( isFile ){
2228 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2229 zCI = "tip";
2230 @ <h2>Latest version of file \
2231 @ '%z(href("%R/finfo?name=%T&m=%T",zName,zCI))%h(zName)</a>':</h2>
2232 }else{
2233 const char *zPath;
2234 Blob path;
2235 blob_zero(&path);
2236 hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO);
2237
--- src/info.c
+++ src/info.c
@@ -2225,12 +2225,12 @@
2225
2226 asText = P("txt")!=0;
2227 if( isFile ){
2228 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2229 zCI = "tip";
2230 @ <h2>File %z(href("%R/finfo?name=%T&m=tip",zName))%h(zName)</a>
2231 @ from the %z(href("%R/info/tip"))latest check-in</a></h2>
2232 }else{
2233 const char *zPath;
2234 Blob path;
2235 blob_zero(&path);
2236 hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO);
2237

Keyboard Shortcuts

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