1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
|
**
** Or, if no repositories can be located beneath g.zRepositoryName,
** return 0.
*/
static int repo_list_page(void){
Blob base;
int n = 0;
assert( g.db==0 );
if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
/* For the special case of the "repository directory" being "/",
** show all of the repositories named in the ~/.fossil database.
**
** On unix systems, then entries are of the form "repo:/home/..."
** and on Windows systems they are like "repo:C:/Users/...". We want
** to skip the first 6 characters on unix and the first 5 characters
** on Windows.
*/
db_open_config(1, 0);
#ifdef _WIN32
db_multi_exec(
"CREATE TEMP VIEW sfile AS"
" SELECT substr(name,6) AS 'pathname' FROM global_config"
" WHERE name GLOB 'repo:*'"
);
#else
db_multi_exec(
"CREATE TEMP VIEW sfile AS"
" SELECT substr(name,7) AS 'pathname' FROM global_config"
" WHERE name GLOB 'repo:*'"
);
#endif
}else{
/* The default case: All repositories under the g.zRepositoryName
** directory.
*/
blob_init(&base, g.zRepositoryName, -1);
sqlite3_open(":memory:", &g.db);
db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
db_multi_exec("CREATE TABLE vfile(pathname);");
vfile_scan(&base, blob_size(&base), 0, 0, 0);
db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
}
@ <html>
@ <head>
@ <base href="%s(g.zBaseURL)/" />
@ <title>Repository List</title>
@ </head>
@ <body>
n = db_int(0, "SELECT count(*) FROM sfile");
if( n>0 ){
Stmt q;
@ <h1>Available Repositories:</h1>
@ <ol>
db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
" FROM sfile ORDER BY pathname COLLATE nocase;");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zUrl = db_column_text(&q, 1);
@ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
}
@ </ol>
}else{
@ <h1>No Repositories Found</h1>
}
@ </body>
@ </html>
|
>
|
|
|
<
|
<
<
<
<
|
<
<
>
>
>
>
|
>
|
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
|
**
** Or, if no repositories can be located beneath g.zRepositoryName,
** return 0.
*/
static int repo_list_page(void){
Blob base;
int n = 0;
int allRepo;
assert( g.db==0 );
if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
/* For the special case of the "repository directory" being "/",
** show all of the repositories named in the ~/.fossil database.
**
** On unix systems, then entries are of the form "repo:/home/..."
** and on Windows systems they are like on unix, starting with a "/"
** or they can begin with a drive letter: "repo:C:/Users/...". In either
** case, we want returned path to omit any initial "/".
*/
db_open_config(1, 0);
db_multi_exec(
"CREATE TEMP VIEW sfile AS"
" SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config"
" WHERE name GLOB 'repo:*'"
);
allRepo = 1;
}else{
/* The default case: All repositories under the g.zRepositoryName
** directory.
*/
blob_init(&base, g.zRepositoryName, -1);
sqlite3_open(":memory:", &g.db);
db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
db_multi_exec("CREATE TABLE vfile(pathname);");
vfile_scan(&base, blob_size(&base), 0, 0, 0);
db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
allRepo = 0;
}
@ <html>
@ <head>
@ <base href="%s(g.zBaseURL)/" />
@ <title>Repository List</title>
@ </head>
@ <body>
n = db_int(0, "SELECT count(*) FROM sfile");
if( n>0 ){
Stmt q;
@ <h1>Available Repositories:</h1>
@ <ol>
db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
" FROM sfile ORDER BY pathname COLLATE nocase;");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zUrl = db_column_text(&q, 1);
if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){
@ <li><a href="%R/%T(zUrl)" target="_blank">/%h(zName)</a></li>
}else{
@ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
}
}
@ </ol>
}else{
@ <h1>No Repositories Found</h1>
}
@ </body>
@ </html>
|