Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the cgi_query_parameters_to_url() routine and use it to cause all query parameters on timeline to be exported. (Need to make this same changes for all other uses of url_render()). Make "context" timelines 11 entries by default. Other cleanups. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | form-submenu |
| Files: | files | file ages | folders |
| SHA1: |
b6e1f61aaaefdef8e632574dcb72cffa |
| User & Date: | drh 2015-02-06 03:00:25.793 |
Context
|
2015-02-06
| ||
| 03:28 | Do not let the "Lines:" box go below one on the /timeline. If it does, automatically revert to 10 lines. Also, arrange for the default number of lines to be 50 in most cases, but only 11 if the c= (circa) query parameter is used. Use n=all to see the entire history of the graph. ... (Closed-Leaf check-in: 99e081efe5 user: drh tags: form-submenu) | |
| 03:00 | Add the cgi_query_parameters_to_url() routine and use it to cause all query parameters on timeline to be exported. (Need to make this same changes for all other uses of url_render()). Make "context" timelines 11 entries by default. Other cleanups. ... (check-in: b6e1f61aaa user: drh tags: form-submenu) | |
| 01:44 | Add the "searchable" TH1 command that tests to see if search is enabled on the repository. Intended use: Conditionally display a "Search" button on the menu bar. ... (check-in: b8f8f69eee user: drh tags: form-submenu) | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
1083 1084 1085 1086 1087 1088 1089 |
/*
** Return true if the CGI parameter zName exists and is not equal to 0,
** or "no" or "off".
*/
int cgi_parameter_boolean(const char *zName){
const char *zIn = cgi_parameter(zName, 0);
if( zIn==0 ) return 0;
| | | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
/*
** Return true if the CGI parameter zName exists and is not equal to 0,
** or "no" or "off".
*/
int cgi_parameter_boolean(const char *zName){
const char *zIn = cgi_parameter(zName, 0);
if( zIn==0 ) return 0;
return zIn[0]==0 || is_truth(zIn);
}
/*
** Return the name of the i-th CGI parameter. Return NULL if there
** are fewer than i registered CGI parameters.
*/
const char *cgi_parameter_name(int i){
|
| ︙ | ︙ | |||
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
for(i=0; i<nUsedQP; i++){
if( aParamQP[i].isQP==0 || aParamQP[i].cTag ) continue;
zN = aParamQP[i].zName;
zV = aParamQP[i].zValue;
@ <input type="hidden" name="%h(zN)" value="%h(zV)">
}
}
/*
** Tag query parameter zName so that it is not exported by
** cgi_query_parameters_to_hidden(). Or if zName==0, then
** untag all query parameters.
*/
void cgi_tag_query_parameter(const char *zName){
| > > > > > > > > > > > > | 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
for(i=0; i<nUsedQP; i++){
if( aParamQP[i].isQP==0 || aParamQP[i].cTag ) continue;
zN = aParamQP[i].zName;
zV = aParamQP[i].zValue;
@ <input type="hidden" name="%h(zN)" value="%h(zV)">
}
}
/*
** Export all untagged query parameters (but not cookies or environment
** variables) to the HQuery object.
*/
void cgi_query_parameters_to_url(HQuery *p){
int i;
for(i=0; i<nUsedQP; i++){
if( aParamQP[i].isQP==0 || aParamQP[i].cTag ) continue;
url_add_parameter(p, aParamQP[i].zName, aParamQP[i].zValue);
}
}
/*
** Tag query parameter zName so that it is not exported by
** cgi_query_parameters_to_hidden(). Or if zName==0, then
** untag all query parameters.
*/
void cgi_tag_query_parameter(const char *zName){
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
127 128 129 130 131 132 133 |
tail = fullbody;
}
if( g.perm.WrWiki && g.perm.Write && nextRid==0 ){
style_submenu_element("Edit", "Edit", "%s/eventedit?name=%s",
g.zTop, zEventId);
}
zETime = db_text(0, "SELECT datetime(%.17g)", pEvent->rEventDate);
| | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
tail = fullbody;
}
if( g.perm.WrWiki && g.perm.Write && nextRid==0 ){
style_submenu_element("Edit", "Edit", "%s/eventedit?name=%s",
g.zTop, zEventId);
}
zETime = db_text(0, "SELECT datetime(%.17g)", pEvent->rEventDate);
style_submenu_element("Context", 0, "%R/timeline?c=%.20s&n=11", zEventId);
if( g.perm.Hyperlink ){
if( verboseFlag ){
style_submenu_element("Plain", 0, "%R/event?name=%.20s&aid=%s",
zEventId, zUuid);
if( nextRid ){
char *zNext;
zNext = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nextRid);
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
915 916 917 918 919 920 921 |
const char *z = zTagList;
Blob links;
blob_zero(&links);
while( z && z[0] ){
for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
blob_appendf(&links,
"%z%#h</a>%.2s",
| | | 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 |
const char *z = zTagList;
Blob links;
blob_zero(&links);
while( z && z[0] ){
for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
blob_appendf(&links,
"%z%#h</a>%.2s",
href("%R/timeline?r=%#t&nd&c=%t&n=11",i,z,zDate), i,z, &z[i]
);
if( z[i]==0 ) break;
z += i+2;
}
@ tags: %s(blob_str(&links)),
blob_reset(&links);
}else{
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
1320 1321 1322 1323 1324 1325 1326 |
" SELECT rowid, stext('c',rid,NULL) FROM ftsdocs"
" WHERE type='c' AND NOT idxed;"
);
db_multi_exec(
"REPLACE INTO ftsdocs(rowid,idxed,type,rid,name,label,url,mtime)"
" SELECT ftsdocs.rowid, 1, 'c', ftsdocs.rid, NULL,"
" printf('Check-in [%%.16s] on %%s',blob.uuid,datetime(event.mtime)),"
| | | 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 |
" SELECT rowid, stext('c',rid,NULL) FROM ftsdocs"
" WHERE type='c' AND NOT idxed;"
);
db_multi_exec(
"REPLACE INTO ftsdocs(rowid,idxed,type,rid,name,label,url,mtime)"
" SELECT ftsdocs.rowid, 1, 'c', ftsdocs.rid, NULL,"
" printf('Check-in [%%.16s] on %%s',blob.uuid,datetime(event.mtime)),"
" printf('/timeline?y=ci&n=11&c=%%.20s',blob.uuid),"
" event.mtime"
" FROM ftsdocs, event, blob"
" WHERE ftsdocs.type='c' AND NOT ftsdocs.idxed"
" AND event.objid=ftsdocs.rid"
" AND blob.rid=ftsdocs.rid"
);
}
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
/*
** Generate a hyperlink to a date & time.
*/
void hyperlink_to_date(const char *zDate, const char *zSuffix){
if( zSuffix==0 ) zSuffix = "";
if( g.perm.Hyperlink ){
| | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
/*
** Generate a hyperlink to a date & time.
*/
void hyperlink_to_date(const char *zDate, const char *zSuffix){
if( zSuffix==0 ) zSuffix = "";
if( g.perm.Hyperlink ){
@ %z(href("%R/timeline?n=11&c=%T",zDate))%s(zDate)</a>%s(zSuffix)
}else{
@ %s(zDate)%s(zSuffix)
}
}
/*
** Generate a hyperlink to a user. This will link to a timeline showing
|
| ︙ | ︙ | |||
492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
" (SELECT uuid FROM blob WHERE rid=fid),"
" (SELECT uuid FROM blob WHERE rid=pid),"
" (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
" FROM mlink"
" WHERE mid=:mid AND (pid!=fid OR pfnid>0)"
" AND (fid>0 OR"
" fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=:mid))"
" ORDER BY 3 /*sort*/"
);
fchngQueryInit = 1;
}
db_bind_int(&fchngQuery, ":mid", rid);
while( db_step(&fchngQuery)==SQLITE_ROW ){
const char *zFilename = db_column_text(&fchngQuery, 2);
| > | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
" (SELECT uuid FROM blob WHERE rid=fid),"
" (SELECT uuid FROM blob WHERE rid=pid),"
" (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
" FROM mlink"
" WHERE mid=:mid AND (pid!=fid OR pfnid>0)"
" AND (fid>0 OR"
" fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=:mid))"
" AND NOT mlink.isaux"
" ORDER BY 3 /*sort*/"
);
fchngQueryInit = 1;
}
db_bind_int(&fchngQuery, ":mid", rid);
while( db_step(&fchngQuery)==SQLITE_ROW ){
const char *zFilename = db_column_text(&fchngQuery, 2);
|
| ︙ | ︙ | |||
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 |
}
login_check_credentials();
if( !g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki ){
login_needed();
return;
}
url_initialize(&url, "timeline");
if( zTagName && g.perm.Read ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTagName);
zThisTag = zTagName;
}else if( zBrName && g.perm.Read ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",zBrName);
zThisTag = zBrName;
}else{
tagid = 0;
}
if( tagid>0
&& db_int(0,"SELECT count(*) FROM tagxref WHERE tagid=%d",tagid)<=nEntry
){
zCirca = zBefore = zAfter = 0;
nEntry = -1;
}
if( zType[0]=='a' ){
tmFlags |= TIMELINE_BRIEF | TIMELINE_GRAPH;
}else{
tmFlags |= TIMELINE_GRAPH;
}
| > < | < | < | < | < < | 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
}
login_check_credentials();
if( !g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki ){
login_needed();
return;
}
url_initialize(&url, "timeline");
cgi_query_parameters_to_url(&url);
if( zTagName && g.perm.Read ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTagName);
zThisTag = zTagName;
}else if( zBrName && g.perm.Read ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",zBrName);
zThisTag = zBrName;
}else{
tagid = 0;
}
if( tagid>0
&& db_int(0,"SELECT count(*) FROM tagxref WHERE tagid=%d",tagid)<=nEntry
){
zCirca = zBefore = zAfter = 0;
nEntry = -1;
}
if( zType[0]=='a' ){
tmFlags |= TIMELINE_BRIEF | TIMELINE_GRAPH;
}else{
tmFlags |= TIMELINE_GRAPH;
}
if( PB("ng") || zSearch!=0 ){
tmFlags &= ~TIMELINE_GRAPH;
}
if( PB("brbg") ){
tmFlags |= TIMELINE_BRCOLOR;
}
if( PB("unhide") ){
tmFlags |= TIMELINE_UNHIDE;
}
if( PB("ubg") ){
tmFlags |= TIMELINE_UCOLOR;
}
if( zUses!=0 ){
int ufid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUses);
if( ufid ){
zUses = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ufid);
db_multi_exec("CREATE TEMP TABLE usesfile(rid INTEGER PRIMARY KEY)");
compute_uses_file("usesfile", ufid, 0);
zType = "ci";
}else{
zUses = 0;
}
}
|
| ︙ | ︙ | |||
1218 1219 1220 1221 1222 1223 1224 |
timeline_temp_table();
blob_zero(&sql);
blob_zero(&desc);
blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1);
blob_append(&sql, timeline_query_for_www(), -1);
if( PB("fc") || PB("v") || PB("detail") ){
tmFlags |= TIMELINE_FCHANGES;
| < < | 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 |
timeline_temp_table();
blob_zero(&sql);
blob_zero(&desc);
blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1);
blob_append(&sql, timeline_query_for_www(), -1);
if( PB("fc") || PB("v") || PB("detail") ){
tmFlags |= TIMELINE_FCHANGES;
}
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)",
TAG_HIDDEN
);
}
if( ((from_rid && to_rid) || (me_rid && you_rid)) && g.perm.Read ){
/* If from= and to= are present, display all nodes on a path connecting
** the two */
PathNode *p = 0;
const char *zFrom = 0;
const char *zTo = 0;
|
| ︙ | ︙ | |||
1296 1297 1298 1299 1300 1301 1302 |
blob_appendf(&desc, "%d ancestors", np);
db_multi_exec("%s", blob_sql_text(&sql));
}
if( d_rid==0 && useDividers ) timeline_add_dividers(0, p_rid);
}
blob_appendf(&desc, " of %z[%S]</a>",
href("%R/info/%s", zUuid), zUuid);
| < < < < | 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 |
blob_appendf(&desc, "%d ancestors", np);
db_multi_exec("%s", blob_sql_text(&sql));
}
if( d_rid==0 && useDividers ) timeline_add_dividers(0, p_rid);
}
blob_appendf(&desc, " of %z[%S]</a>",
href("%R/info/%s", zUuid), zUuid);
if( d_rid ){
if( p_rid ){
/* If both p= and d= are set, we don't have the uuid of d yet. */
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
}
}
style_submenu_binary("v","With Files","Without Files");
style_submenu_entry("n","Lines",1);
timeline_y_submenu();
}else if( f_rid && g.perm.Read ){
/* If f= is present, ignore all other parameters other than n= */
char *zUuid;
|
| ︙ | ︙ | |||
1326 1327 1328 1329 1330 1331 1332 |
blob_append_sql(&sql, " AND event.objid IN ok");
db_multi_exec("%s", blob_sql_text(&sql));
if( useDividers ) timeline_add_dividers(0, f_rid);
blob_appendf(&desc, "Parents and children of check-in ");
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", f_rid);
blob_appendf(&desc, "%z[%S]</a>", href("%R/info/%s", zUuid), zUuid);
tmFlags |= TIMELINE_DISJOINT;
| < < | < < < | 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
blob_append_sql(&sql, " AND event.objid IN ok");
db_multi_exec("%s", blob_sql_text(&sql));
if( useDividers ) timeline_add_dividers(0, f_rid);
blob_appendf(&desc, "Parents and children of check-in ");
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", f_rid);
blob_appendf(&desc, "%z[%S]</a>", href("%R/info/%s", zUuid), zUuid);
tmFlags |= TIMELINE_DISJOINT;
style_submenu_binary("v","With Files","Without Files");
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
timeline_submenu(&url, "Unhide", "unhide", "", 0);
}
}else{
/* Otherwise, a timeline based on a span of time */
int n;
const char *zEType = "timeline item";
|
| ︙ | ︙ | |||
1360 1361 1362 1363 1364 1365 1366 |
}
if( tagid>0 ){
blob_append_sql(&sql,
"AND (EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid);
if( zBrName ){
| < | 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
}
if( tagid>0 ){
blob_append_sql(&sql,
"AND (EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid);
if( zBrName ){
/* The next two blob_appendf() calls add SQL that causes checkins that
** are not part of the branch which are parents or children of the
** branch to be included in the report. This related check-ins are
** useful in helping to visualize what has happened on a quiescent
** branch that is infrequently merged with a much more activate branch.
*/
blob_append_sql(&sql,
|
| ︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 |
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
" WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
TAG_HIDDEN
);
}
| < < < < | 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 |
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
" WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
TAG_HIDDEN
);
}
}
}
blob_append_sql(&sql, ")");
}
if( (zType[0]=='w' && !g.perm.RdWiki)
|| (zType[0]=='t' && !g.perm.RdTkt)
|| (zType[0]=='e' && !g.perm.RdWiki)
|| (zType[0]=='c' && !g.perm.Read)
|
| ︙ | ︙ | |||
1428 1429 1430 1431 1432 1433 1434 |
blob_append_sql(&sql, "%c't'", cSep);
cSep = ',';
}
blob_append_sql(&sql, ")");
}
}else{ /* zType!="all" */
blob_append_sql(&sql, " AND event.type=%Q", zType);
| < | 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
blob_append_sql(&sql, "%c't'", cSep);
cSep = ',';
}
blob_append_sql(&sql, ")");
}
}else{ /* zType!="all" */
blob_append_sql(&sql, " AND event.type=%Q", zType);
if( zType[0]=='c' ){
zEType = "checkin";
}else if( zType[0]=='w' ){
zEType = "wiki edit";
}else if( zType[0]=='t' ){
zEType = "ticket change";
}else if( zType[0]=='e' ){
|
| ︙ | ︙ | |||
1450 1451 1452 1453 1454 1455 1456 |
" WHERE user=%Q OR euser=%Q", zUser, zUser);
if( n<=nEntry ){
zCirca = zBefore = zAfter = 0;
nEntry = -1;
}
blob_append_sql(&sql, " AND (event.user=%Q OR event.euser=%Q)",
zUser, zUser);
| < < < < < < < | 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 |
" WHERE user=%Q OR euser=%Q", zUser, zUser);
if( n<=nEntry ){
zCirca = zBefore = zAfter = 0;
nEntry = -1;
}
blob_append_sql(&sql, " AND (event.user=%Q OR event.euser=%Q)",
zUser, zUser);
zThisUser = zUser;
}
if( zSearch ){
blob_append_sql(&sql,
" AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
zSearch, zSearch);
}
rBefore = symbolic_name_to_mtime(zBefore);
rAfter = symbolic_name_to_mtime(zAfter);
rCirca = symbolic_name_to_mtime(zCirca);
if( rAfter>0.0 ){
if( rBefore>0.0 ){
blob_append_sql(&sql,
" AND event.mtime>=%.17g AND event.mtime<=%.17g"
" ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
nEntry = -1;
}else{
blob_append_sql(&sql,
" AND event.mtime>=%.17g ORDER BY event.mtime ASC",
rAfter-ONE_SECOND);
}
}else if( rBefore>0.0 ){
blob_append_sql(&sql,
" AND event.mtime<=%.17g ORDER BY event.mtime DESC",
rBefore+ONE_SECOND);
}else if( rCirca>0.0 ){
Blob sql2;
blob_init(&sql2, blob_sql_text(&sql), -1);
blob_append_sql(&sql2,
" AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
rCirca, (nEntry+1)/2
);
db_multi_exec("%s", blob_sql_text(&sql2));
blob_reset(&sql2);
blob_append_sql(&sql,
" AND event.mtime>=%f ORDER BY event.mtime ASC",
rCirca
);
nEntry -= (nEntry+1)/2;
if( useDividers ) timeline_add_dividers(rCirca, 0);
}else{
blob_append_sql(&sql, " ORDER BY event.mtime DESC");
}
if( nEntry>0 ) blob_append_sql(&sql, " LIMIT %d", nEntry);
db_multi_exec("%s", blob_sql_text(&sql));
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
|
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
430 431 432 433 434 435 436 |
#if INTERFACE
/*
** An instance of this object is used to build a URL with query parameters.
*/
struct HQuery {
Blob url; /* The URL */
const char *zBase; /* The base URL */
| | > | | > < > > > | > | > > > > > > > > > | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
#if INTERFACE
/*
** An instance of this object is used to build a URL with query parameters.
*/
struct HQuery {
Blob url; /* The URL */
const char *zBase; /* The base URL */
int nParam; /* Number of parameters. */
int nAlloc; /* Number of allocated slots */
const char **azName; /* Parameter names */
const char **azValue; /* Parameter values */
};
#endif
/*
** Initialize the URL object.
*/
void url_initialize(HQuery *p, const char *zBase){
memset(p, 0, sizeof(*p));
blob_zero(&p->url);
p->zBase = zBase;
}
/*
** Resets the given URL object, deallocating any memory
** it uses.
*/
void url_reset(HQuery *p){
blob_reset(&p->url);
fossil_free(p->azName);
fossil_free(p->azValue);
url_initialize(p, p->zBase);
}
/*
** Add a fixed parameter to an HQuery.
*/
void url_add_parameter(HQuery *p, const char *zName, const char *zValue){
int i;
for(i=0; i<p->nParam; i++){
if( fossil_strcmp(p->azName[i],zName)==0 ){
p->azValue[i] = zValue;
return;
}
}
assert( i==p->nParam );
if( i>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + 10;
p->azName = fossil_realloc(p->azName, sizeof(p->azName[0])*p->nAlloc);
p->azValue = fossil_realloc(p->azValue, sizeof(p->azValue[0])*p->nAlloc);
}
p->azName[i] = zName;
p->azValue[i] = zValue;
p->nParam++;
}
/*
** Render the URL with a parameter override.
**
** Returned memory is transient and is overwritten on the next call to this
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
1250 1251 1252 1253 1254 1255 1256 |
}
}else if( g.perm.Hyperlink ){
blob_appendf(p->pOut, "%z[",href("%R/info/%s", zTarget));
zTerm = "]</a>";
}
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
&& db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
| | | 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
}
}else if( g.perm.Hyperlink ){
blob_appendf(p->pOut, "%z[",href("%R/info/%s", zTarget));
zTerm = "]</a>";
}
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
&& db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
blob_appendf(p->pOut, "<a href=\"%R/timeline?n=11&c=%T\">", zTarget);
}else if( (z = validWikiPageName(p, zTarget))!=0 ){
blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
}else if( zTarget>=&zOrig[2] && !fossil_isspace(zTarget[-2]) ){
/* Probably an array subscript in code */
zTerm = "";
}else if( (p->state & (WIKI_NOBADLINKS|WIKI_LINKSONLY))!=0 ){
zTerm = "";
|
| ︙ | ︙ |