Fossil SCM

Change timeline hyperlinks to wiki pages to point to the specific version of the wiki page that the timeline entry refers to, not to the latest version of that page.

drh 2018-12-11 21:31 trunk
Commit 606421edc5892a4c353d72110271ea5be6ee864f2e79e90bc0552ab5f2552688
--- src/timeline.c
+++ src/timeline.c
@@ -505,11 +505,13 @@
505505
}
506506
}
507507
if( zType[0]!='c' ){
508508
/* Comments for anything other than a check-in are generated by
509509
** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
510
+ if( zType[0]=='w' ) wiki_hyperlink_override(zUuid);
510511
wiki_convert(&comment, 0, WIKI_INLINE);
512
+ wiki_hyperlink_override(0);
511513
}else{
512514
if( bCommentGitStyle ){
513515
/* Truncate comment at first blank line */
514516
int ii, jj;
515517
int n = blob_size(&comment);
516518
--- src/timeline.c
+++ src/timeline.c
@@ -505,11 +505,13 @@
505 }
506 }
507 if( zType[0]!='c' ){
508 /* Comments for anything other than a check-in are generated by
509 ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
 
510 wiki_convert(&comment, 0, WIKI_INLINE);
 
511 }else{
512 if( bCommentGitStyle ){
513 /* Truncate comment at first blank line */
514 int ii, jj;
515 int n = blob_size(&comment);
516
--- src/timeline.c
+++ src/timeline.c
@@ -505,11 +505,13 @@
505 }
506 }
507 if( zType[0]!='c' ){
508 /* Comments for anything other than a check-in are generated by
509 ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
510 if( zType[0]=='w' ) wiki_hyperlink_override(zUuid);
511 wiki_convert(&comment, 0, WIKI_INLINE);
512 wiki_hyperlink_override(0);
513 }else{
514 if( bCommentGitStyle ){
515 /* Truncate comment at first blank line */
516 int ii, jj;
517 int n = blob_size(&comment);
518
+1
--- src/wiki.c
+++ src/wiki.c
@@ -881,10 +881,11 @@
881881
login_check_credentials();
882882
if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; }
883883
zPageName = PD("name","");
884884
style_header("History Of %s", zPageName);
885885
if( P("showid")!=0 ) tmFlags |= TIMELINE_SHOWRID;
886
+ tmFlags |= timeline_ss_submenu();
886887
887888
db_prepare(&q, "%s AND event.objid IN "
888889
" (SELECT rid FROM tagxref WHERE tagid="
889890
"(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
890891
" UNION SELECT attachid FROM attachment"
891892
--- src/wiki.c
+++ src/wiki.c
@@ -881,10 +881,11 @@
881 login_check_credentials();
882 if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; }
883 zPageName = PD("name","");
884 style_header("History Of %s", zPageName);
885 if( P("showid")!=0 ) tmFlags |= TIMELINE_SHOWRID;
 
886
887 db_prepare(&q, "%s AND event.objid IN "
888 " (SELECT rid FROM tagxref WHERE tagid="
889 "(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
890 " UNION SELECT attachid FROM attachment"
891
--- src/wiki.c
+++ src/wiki.c
@@ -881,10 +881,11 @@
881 login_check_credentials();
882 if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; }
883 zPageName = PD("name","");
884 style_header("History Of %s", zPageName);
885 if( P("showid")!=0 ) tmFlags |= TIMELINE_SHOWRID;
886 tmFlags |= timeline_ss_submenu();
887
888 db_prepare(&q, "%s AND event.objid IN "
889 " (SELECT rid FROM tagxref WHERE tagid="
890 "(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
891 " UNION SELECT attachid FROM attachment"
892
+40 -1
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1159,10 +1159,44 @@
11591159
){
11601160
return zTarget;
11611161
}
11621162
return 0;
11631163
}
1164
+
1165
+static const char *wikiOverrideHash = 0;
1166
+
1167
+/*
1168
+** Fossil-wiki hyperlinks to wiki pages should be overridden to the
1169
+** hash value supplied. If the value is NULL, then override is cancelled
1170
+** and all overwrites operate normally.
1171
+*/
1172
+void wiki_hyperlink_override(const char *zUuid){
1173
+ wikiOverrideHash = zUuid;
1174
+}
1175
+
1176
+
1177
+/*
1178
+** If links to wiki page zTarget should be redirected to some historical
1179
+** version of that page, then return the hash of the historical version.
1180
+** If no override is required, return NULL.
1181
+*/
1182
+static const char *wiki_is_overridden(const char *zTarget){
1183
+ if( wikiOverrideHash==0 ) return 0;
1184
+ /* The override should only happen if the override version is not the
1185
+ ** latest version of the wiki page. */
1186
+ if( !db_exists(
1187
+ "SELECT 1 FROM tag, blob, tagxref AS xA, tagxref AS xB "
1188
+ " WHERE tag.tagname GLOB 'wiki-%q*'"
1189
+ " AND blob.uuid GLOB '%q'"
1190
+ " AND xA.tagid=tag.tagid AND xA.rid=blob.rid"
1191
+ " AND xB.tagid=tag.tagid AND xB.mtime>xA.mtime",
1192
+ zTarget, wikiOverrideHash
1193
+ ) ){
1194
+ return 0;
1195
+ }
1196
+ return wikiOverrideHash;
1197
+}
11641198
11651199
/*
11661200
** Resolve a hyperlink. The zTarget argument is the content of the [...]
11671201
** in the wiki. Append to the output string whatever text is appropriate
11681202
** for opening the hyperlink. Write into zClose[0...nClose-1] text that will
@@ -1259,11 +1293,16 @@
12591293
}
12601294
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
12611295
&& db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
12621296
blob_appendf(p->pOut, "<a href=\"%R/timeline?c=%T\">", zTarget);
12631297
}else if( (z = validWikiPageName(p, zTarget))!=0 ){
1264
- blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
1298
+ const char *zOverride = wiki_is_overridden(zTarget);
1299
+ if( zOverride ){
1300
+ blob_appendf(p->pOut, "<a href=\"%R/info/%S\">", zOverride);
1301
+ }else{
1302
+ blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
1303
+ }
12651304
}else if( zTarget>=&zOrig[2] && !fossil_isspace(zTarget[-2]) ){
12661305
/* Probably an array subscript in code */
12671306
zTerm = "";
12681307
}else if( (p->state & (WIKI_NOBADLINKS|WIKI_LINKSONLY))!=0 ){
12691308
zTerm = "";
12701309
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1159,10 +1159,44 @@
1159 ){
1160 return zTarget;
1161 }
1162 return 0;
1163 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1164
1165 /*
1166 ** Resolve a hyperlink. The zTarget argument is the content of the [...]
1167 ** in the wiki. Append to the output string whatever text is appropriate
1168 ** for opening the hyperlink. Write into zClose[0...nClose-1] text that will
@@ -1259,11 +1293,16 @@
1259 }
1260 }else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
1261 && db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
1262 blob_appendf(p->pOut, "<a href=\"%R/timeline?c=%T\">", zTarget);
1263 }else if( (z = validWikiPageName(p, zTarget))!=0 ){
1264 blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
 
 
 
 
 
1265 }else if( zTarget>=&zOrig[2] && !fossil_isspace(zTarget[-2]) ){
1266 /* Probably an array subscript in code */
1267 zTerm = "";
1268 }else if( (p->state & (WIKI_NOBADLINKS|WIKI_LINKSONLY))!=0 ){
1269 zTerm = "";
1270
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1159,10 +1159,44 @@
1159 ){
1160 return zTarget;
1161 }
1162 return 0;
1163 }
1164
1165 static const char *wikiOverrideHash = 0;
1166
1167 /*
1168 ** Fossil-wiki hyperlinks to wiki pages should be overridden to the
1169 ** hash value supplied. If the value is NULL, then override is cancelled
1170 ** and all overwrites operate normally.
1171 */
1172 void wiki_hyperlink_override(const char *zUuid){
1173 wikiOverrideHash = zUuid;
1174 }
1175
1176
1177 /*
1178 ** If links to wiki page zTarget should be redirected to some historical
1179 ** version of that page, then return the hash of the historical version.
1180 ** If no override is required, return NULL.
1181 */
1182 static const char *wiki_is_overridden(const char *zTarget){
1183 if( wikiOverrideHash==0 ) return 0;
1184 /* The override should only happen if the override version is not the
1185 ** latest version of the wiki page. */
1186 if( !db_exists(
1187 "SELECT 1 FROM tag, blob, tagxref AS xA, tagxref AS xB "
1188 " WHERE tag.tagname GLOB 'wiki-%q*'"
1189 " AND blob.uuid GLOB '%q'"
1190 " AND xA.tagid=tag.tagid AND xA.rid=blob.rid"
1191 " AND xB.tagid=tag.tagid AND xB.mtime>xA.mtime",
1192 zTarget, wikiOverrideHash
1193 ) ){
1194 return 0;
1195 }
1196 return wikiOverrideHash;
1197 }
1198
1199 /*
1200 ** Resolve a hyperlink. The zTarget argument is the content of the [...]
1201 ** in the wiki. Append to the output string whatever text is appropriate
1202 ** for opening the hyperlink. Write into zClose[0...nClose-1] text that will
@@ -1259,11 +1293,16 @@
1293 }
1294 }else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
1295 && db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
1296 blob_appendf(p->pOut, "<a href=\"%R/timeline?c=%T\">", zTarget);
1297 }else if( (z = validWikiPageName(p, zTarget))!=0 ){
1298 const char *zOverride = wiki_is_overridden(zTarget);
1299 if( zOverride ){
1300 blob_appendf(p->pOut, "<a href=\"%R/info/%S\">", zOverride);
1301 }else{
1302 blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
1303 }
1304 }else if( zTarget>=&zOrig[2] && !fossil_isspace(zTarget[-2]) ){
1305 /* Probably an array subscript in code */
1306 zTerm = "";
1307 }else if( (p->state & (WIKI_NOBADLINKS|WIKI_LINKSONLY))!=0 ){
1308 zTerm = "";
1309

Keyboard Shortcuts

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