Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enhance the repository list page so that it shows the name of project for each repository, and so that the "Last Modified" time is based on the most recent event in the repository, not the repository file mtime. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cdea59dc5c832837e9012c6a29aef8b3 |
User & Date: | drh 2018-11-02 13:48:52.874 |
Context
2018-11-02
| ||
15:21 | Enhance makeheaders so that it is able to deal with static_assert() statements. (These do not come up in Fossil itself. This check-in is in response to use of Makeheaders by external projects.) ... (check-in: 8cecc544 user: drh tags: trunk) | |
13:48 | Enhance the repository list page so that it shows the name of project for each repository, and so that the "Last Modified" time is based on the most recent event in the repository, not the repository file mtime. ... (check-in: cdea59dc user: drh tags: trunk) | |
13:08 | Split out the repo_list_page() routine, used to generate the repository list for "fossil all ui" and similar, into a separate source file "repolist.c" to make it easier to enhance and maintain. ... (check-in: 45a71349 user: drh tags: trunk) | |
Changes
Changes to src/repolist.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 | ******************************************************************************* ** ** This module contains code to implement the repository list page when ** "fossil server" or "fossil ui" is serving a directory full of repositories. */ #include "config.h" #include "repolist.h" /* ** Generate a web-page that lists all repositories located under the ** g.zRepositoryName directory and return non-zero. ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ******************************************************************************* ** ** This module contains code to implement the repository list page when ** "fossil server" or "fossil ui" is serving a directory full of repositories. */ #include "config.h" #include "repolist.h" #if INTERFACE /* ** Return value from the remote_repo_info() command. zRepoName is the ** input. All other fields are outputs. */ struct RepoInfo { char *zRepoName; /* Name of the repository file */ int isValid; /* True if zRepoName is a valid Fossil repository */ char *zProjName; /* Project Name. Memory from fossil_malloc() */ double rMTime; /* Last update. Julian day number */ }; #endif /* ** Discover information about the repository given by ** pRepo->zRepoName. */ void remote_repo_info(RepoInfo *pRepo){ sqlite3 *db; sqlite3_stmt *pStmt; int rc; pRepo->isValid = 0; pRepo->zProjName = 0; pRepo->rMTime = 0.0; rc = sqlite3_open(pRepo->zRepoName, &db); if( rc ) return; rc = sqlite3_prepare_v2(db, "SELECT value FROM config" " WHERE name='project-name'", -1, &pStmt, 0); if( rc ) return; if( sqlite3_step(pStmt)==SQLITE_ROW ){ pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0)); } sqlite3_finalize(pStmt); rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0); if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ pRepo->rMTime = sqlite3_column_double(pStmt,0); } sqlite3_finalize(pStmt); sqlite3_close(db); pRepo->isValid = 1; } /* ** Generate a web-page that lists all repositories located under the ** g.zRepositoryName directory and return non-zero. ** ** For the special case when g.zRepositoryName is a non-chroot-jail "/", ** compose the list using the "repo:" entries in the global_config ** table of the configuration database. These entries comprise all ** of the repositories known to the "all" command. The special case ** processing is disallowed for chroot jails because g.zRepositoryName ** is always "/" inside a chroot jail and so it cannot be used as a flag ** to signal the special processing in that case. The special case ** processing is intended for the "fossil all ui" command which never |
︙ | ︙ | |||
78 79 80 81 82 83 84 | @ <meta name="viewport" content="width=device-width, initial-scale=1.0"> @ <title>Repository List</title> @ </head> @ <body> n = db_int(0, "SELECT count(*) FROM sfile"); if( n>0 ){ Stmt q; | | | | > > | > > | > | > > > | > | | | | > > > > > > | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | @ <meta name="viewport" content="width=device-width, initial-scale=1.0"> @ <title>Repository List</title> @ </head> @ <body> n = db_int(0, "SELECT count(*) FROM sfile"); if( n>0 ){ Stmt q; double rNow; @ <h1 align="center">Fossil Repositories</h1> @ <table border="0" class="sortable" data-init-sort="1" \ @ data-column-types="tntnk"><thead> @ <tr><th>Filename<th width="20">\ @ <th>Project Name<th width="20">\ @ <th>Last Modified</tr> @ </thead><tbody> db_prepare(&q, "SELECT pathname" " FROM sfile ORDER BY pathname COLLATE nocase;"); rNow = db_double(0, "SELECT julianday('now')"); while( db_step(&q)==SQLITE_ROW ){ const char *zName = db_column_text(&q, 0); int nName = (int)strlen(zName); char *zUrl; char *zAge; char *zFull; RepoInfo x; int iAge; if( nName<7 ) continue; zUrl = sqlite3_mprintf("%.*s", nName-7, zName); if( zName[0]=='/' #ifdef _WIN32 || sqlite3_strglob("[a-zA-Z]:/*", zName)==0 #endif ){ zFull = mprintf("%s", zName); }else if ( allRepo ){ zFull = mprintf("/%s", zName); }else{ zFull = mprintf("%s/%s", g.zRepositoryName, zName); } x.zRepoName = zFull; remote_repo_info(&x); fossil_free(zFull); if( !x.isValid ){ zAge = mprintf("..."); iAge = 0; }else{ iAge = (rNow - x.rMTime)*86400; if( iAge<0 ) x.rMTime = rNow; zAge = human_readable_age(rNow - x.rMTime); } @ <tr><td valign="top">\ if( sqlite3_strglob("*.fossil", zName)!=0 ){ /* The "fossil server DIRECTORY" and "fossil ui DIRECTORY" commands ** do not work for repositories whose names do not end in ".fossil". ** So do not hyperlink those cases. */ @ %h(zName) } else if( sqlite3_strglob("*/.*", zName)==0 ){ /* Do not show hidden repos */ @ %h(zName) (hidden) } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ @ <a href="%R/%T(zUrl)/home" target="_blank">/%h(zName)</a> }else{ @ <a href="%R/%T(zUrl)/home" target="_blank">%h(zName)</a> } if( x.zProjName ){ @ <td></td><td>%h(x.zProjName)</td> fossil_free(x.zProjName); }else{ @ <td></td><td></td> } @ <td></td><td data-sortkey='%08x(iAge)'>%h(zAge)</tr> fossil_free(zAge); sqlite3_free(zUrl); } @ </tbody></table> }else{ @ <h1>No Repositories Found</h1> } |
︙ | ︙ |