Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add preliminary support for URL aliasing. Create aliases by visiting the "URL Aliases" subscreen under the Setup menu. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
8131f1c5d9079af90532cd2d901b923f |
| User & Date: | drh 2017-09-20 03:27:18.120 |
Context
|
2017-09-20
| ||
| 04:05 | Correct comment typos ... (check-in: b1191c1ee0 user: andygoth tags: trunk) | |
| 03:27 | Add preliminary support for URL aliasing. Create aliases by visiting the "URL Aliases" subscreen under the Setup menu. ... (check-in: 8131f1c5d9 user: drh tags: trunk) | |
|
2017-09-19
| ||
| 20:09 | Add the ability to temporarily disable all ads. ... (check-in: 48d8af20b7 user: drh tags: trunk) | |
Changes
Changes to src/dispatch.c.
| ︙ | ︙ | |||
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
}else{
*ppCmd = &aCommand[lwr];
return 0; /* Prefix match */
}
}
return 1; /* Not found */
}
/*
** Fill Blob with a space-separated list of all command names that
** match the prefix zPrefix.
*/
void dispatch_matching_names(const char *zPrefix, Blob *pList){
int i;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 121 122 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 201 |
}else{
*ppCmd = &aCommand[lwr];
return 0; /* Prefix match */
}
}
return 1; /* Not found */
}
/*
** zName is the name of a webpage (eType==CMDFLAGS_WEBPAGE) that does not
** exist in the dispatch table. Check to see if this webpage name exists
** as an alias in the CONFIG table of the repository. If it is, then make
** appropriate changes to the CGI environment and set *ppCmd to point to the
** alised command.
**
** Return 0 if the command is successfully aliased. Return 1 if there
** is not alias for zName. Any kind of error in the alias value causes a
** error to be thrown.
**
** Alias entries in the CONFIG table have a "name" value of "walise:NAME"
** where NAME is the input page name. The value is a string of the form
** "NEWNAME?QUERYPARAMS". The ?QUERYPARAMS is optional. If present (and it
** usually is, then all query parameters are added to the CGI environment.
** Except, query parameters of the form "X!" cause any CGI X variable to be
** removed.
*/
int dispatch_alias(const char *zName, const CmdOrPage **ppCmd){
char *z;
char *zQ;
int i, j;
char c;
z = db_text(0, "SELECT value FROM config WHERE name='walias:%q'",zName);
if( z==0 ) return 1;
for(i=0; z[i] && z[i]!='?'; i++){}
if( z[i]=='?' ){
z[i] = 0;
zQ = &z[i+1];
}else{
zQ = &z[i];
}
if( dispatch_name_search(z, CMDFLAG_WEBPAGE, ppCmd) ){
fossil_fatal("\"%s\" aliased to \"%s\" but \"%s\" does not exist",
zName, z, z);
}
z = zQ;
while( *z ){
char *zName = z;
char *zValue;
while( *z && *z!='=' && *z!='&' && *z!='!' ){ z++; }
if( *z=='=' ){
*z = 0;
z++;
zValue = z;
while( *z && *z!='&' ){ z++; }
if( *z ){
*z = 0;
z++;
}
dehttpize(zValue);
}else if( *z=='!' ){
*(z++) = 0;
cgi_delete_query_parameter(zName);
zName = "";
}else{
if( *z ){ *z++ = 0; }
zValue = "";
}
if( fossil_islower(zName[0]) ){
cgi_replace_query_parameter(zName, zValue);
}
}
return 0;
}
/*
** Fill Blob with a space-separated list of all command names that
** match the prefix zPrefix.
*/
void dispatch_matching_names(const char *zPrefix, Blob *pList){
int i;
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
1614 1615 1616 1617 1618 1619 1620 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
| | > > | 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
if( dispatch_name_search(g.zPath-1, CMDFLAG_WEBPAGE, &pCmd)
&& dispatch_alias(g.zPath-1, &pCmd)
){
#ifdef FOSSIL_ENABLE_JSON
if(g.json.isJsonMode){
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
}else
#endif
{
#ifdef FOSSIL_ENABLE_TH1_HOOKS
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("Transfers", "xfersetup",
"Configure the transfer system for this repository");
setup_menu_entry("Skins", "setup_skin",
"Select and/or modify the web interface \"skins\"");
setup_menu_entry("Moderation", "setup_modreq",
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
" changes and attachments.");
| > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("URL Aliases", "waliassetup",
"Configure URL aliases");
setup_menu_entry("Transfers", "xfersetup",
"Configure the transfer system for this repository");
setup_menu_entry("Skins", "setup_skin",
"Select and/or modify the web interface \"skins\"");
setup_menu_entry("Moderation", "setup_modreq",
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
" changes and attachments.");
|
| ︙ | ︙ | |||
2305 2306 2307 2308 2309 2310 2311 |
@ larger repositories.</p>
onoff_attribute("Use Porter Stemmer","search-stemmer","ss",0,0);
@ <p><input type="submit" name="fts1" value="Create A Full-Text Index">
}
@ </div></form>
style_footer();
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 |
@ larger repositories.</p>
onoff_attribute("Use Porter Stemmer","search-stemmer","ss",0,0);
@ <p><input type="submit" name="fts1" value="Create A Full-Text Index">
}
@ </div></form>
style_footer();
}
/*
** A URL Alias originally called zOldName is now zNewName/zValue.
** Write SQL to make this change into pSql.
**
** If zNewName or zValue is an empty string, then delete the entry.
**
** If zOldName is an empty string, create a new entry.
*/
static void setup_update_url_alias(
Blob *pSql,
const char *zOldName,
const char *zNewName,
const char *zValue
){
if( zNewName[0]==0 || zValue[0]==0 ){
if( zOldName[0] ){
blob_append_sql(pSql,
"DELETE FROM config WHERE name='walias:%q';\n",
zOldName);
}
return;
}
if( zOldName[0]==0 ){
blob_append_sql(pSql,
"INSERT INTO config(name,value,mtime) VALUES('walias:%q',%Q,now());\n",
zNewName, zValue);
return;
}
if( strcmp(zOldName, zNewName)!=0 ){
blob_append_sql(pSql,
"UPDATE config SET name='walias:%q', value=%Q, mtime=now()"
" WHERE name='walias:%q';\n",
zNewName, zValue, zOldName);
}else{
blob_append_sql(pSql,
"UPDATE config SET value=%Q, mtime=now()"
" WHERE name='walias:%q' AND value<>%Q;\n",
zValue, zOldName, zValue);
}
}
/*
** WEBPAGE: waliassetup
**
** Configure the URL aliases
*/
void page_waliassetup(){
Stmt q;
int cnt = 0;
Blob namelist;
login_check_credentials();
if( !g.perm.Setup && !g.perm.Admin ){
login_needed(0);
return;
}
style_header("URL ALias Configuration");
if( P("submit")!=0 ){
Blob token;
Blob sql;
const char *zNewName;
const char *zValue;
char zCnt[10];
login_verify_csrf_secret();
blob_init(&namelist, PD("namelist",""), -1);
blob_init(&sql, 0, 0);
while( blob_token(&namelist, &token) ){
const char *zOldName = blob_str(&token);
sqlite3_snprintf(sizeof(zCnt), zCnt, "n%d", cnt);
zNewName = PD(zCnt, "");
sqlite3_snprintf(sizeof(zCnt), zCnt, "v%d", cnt);
zValue = PD(zCnt, "");
setup_update_url_alias(&sql, zOldName, zNewName, zValue);
cnt++;
blob_reset(&token);
}
sqlite3_snprintf(sizeof(zCnt), zCnt, "n%d", cnt);
zNewName = PD(zCnt,"");
sqlite3_snprintf(sizeof(zCnt), zCnt, "v%d", cnt);
zValue = PD(zCnt,"");
setup_update_url_alias(&sql, "", zNewName, zValue);
db_multi_exec("%s", blob_sql_text(&sql));
blob_reset(&sql);
blob_reset(&namelist);
cnt = 0;
}
db_prepare(&q,
"SELECT substr(name,8), value FROM config WHERE name GLOB 'walias:/*'"
" UNION ALL SELECT '', ''"
);
@ <form action="%s(g.zTop)/waliassetup" method="post"><div>
login_insert_csrf_secret();
@ <table border=0 cellpadding=5>
@ <tr><th>Alias<th>URI That The Alias Maps Into
blob_init(&namelist, 0, 0);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zValue = db_column_text(&q, 1);
@ <tr><td>
@ <input type='text' size='20' value='%h(zName)' name='n%d(cnt)'>
@ </td><td>
@ <input type='text' size='80' value='%h(zValue)' name='v%d(cnt)'>
@ </td></tr>
cnt++;
if( blob_size(&namelist)>0 ) blob_append(&namelist, " ", 1);
blob_append(&namelist, zName, -1);
}
db_finalize(&q);
@ <tr><td>
@ <input type='hidden' name='namelist' value='%h(blob_str(&namelist))'>
@ <input type='submit' name='submit' value="Apply Changes">
@ </td><td></td></tr>
@ </table></form>
style_footer();
}
|