Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Implement a graph of changes in the timeline to replace the older flashing asterisk mechanism. Does not work on IE6. Probably still contains bugs. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
d89fea6a1c0823aa72d8bf5042bf10b0 |
| User & Date: | drh 2010-02-08 16:12:10.000 |
References
|
2014-02-13
| ||
| 11:40 | Remove more legacy javascript: The functions xin() and xout() were already removed in [d89fea6a1c0823aa], so this is no longer necessary. ... (check-in: 438eebcdbc user: jan.nijtmans tags: trunk) | |
Context
|
2010-02-08
| ||
| 16:40 | Fix a bug in the graph display that causes an assertion fault if the timeline contains a node that has no parents. ... (check-in: c5f3e87bb0 user: drh tags: trunk) | |
| 16:12 | Implement a graph of changes in the timeline to replace the older flashing asterisk mechanism. Does not work on IE6. Probably still contains bugs. ... (check-in: d89fea6a1c user: drh tags: trunk) | |
| 16:10 | Alternative implementation to the improved "remove directory" error message. ... (check-in: 8c9f949a3f user: drh tags: trunk) | |
Changes
Changes to src/delta.c.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ** fossil source code base. Nothing in this file depends on anything ** else in fossil. */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <string.h> /* ** Macros for turning debugging printfs on and off */ #if 0 # define DEBUG1(X) X #else | > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ** fossil source code base. Nothing in this file depends on anything ** else in fossil. */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <string.h> #include "delta.h" /* ** Macros for turning debugging printfs on and off */ #if 0 # define DEBUG1(X) X #else |
| ︙ | ︙ | |||
60 61 62 63 64 65 66 | zBuf[i] = 0; return zBuf; } #else # define DEBUG2(X) #endif | | > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | zBuf[i] = 0; return zBuf; } #else # define DEBUG2(X) #endif #if INTERFACE /* ** The "u32" type must be an unsigned 32-bit integer. Adjust this */ typedef unsigned int u32; /* ** Must be a 16-bit value */ typedef short int s16; typedef unsigned short int u16; #endif /* INTERFACE */ /* ** The width of a hash window in bytes. The algorithm only works if this ** is a power of 2. */ #define NHASH 16 |
| ︙ | ︙ |
Added src/graph.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
/*
** Copyright (c) 2010 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains code to compute a revision history graph.
*/
#include "config.h"
#include "graph.h"
#include <assert.h>
#if INTERFACE
#define GR_MAX_PARENT 10
#define GR_MAX_RAIL 32
/* The graph appears vertically beside a timeline. Each row in the
** timeline corresponds to a row in the graph.
*/
struct GraphRow {
int rid; /* The rid for the check-in */
int isLeaf; /* True if the check-in is an open leaf */
int nParent; /* Number of parents */
int aParent[GR_MAX_PARENT]; /* Array of parents. 0 element is primary .*/
char *zBranch; /* Branch name */
GraphRow *pNext; /* Next row down in the list of all rows */
GraphRow *pPrev; /* Previous row */
int idx; /* Row index. First is 1. 0 used for "none" */
int iRail; /* Which rail this check-in appears on. 0-based.*/
int aiRaiser[GR_MAX_RAIL]; /* Raisers from this node to a higher row. */
int bDescender; /* Raiser from bottom of graph to here. */
u32 mergeIn; /* Merge in from other rails */
int mergeOut; /* Merge out to this rail */
int mergeUpto; /* Draw the merge rail up to this level */
u32 railInUse; /* Mask of occupied rails */
};
/* Context while building a graph
*/
struct GraphContext {
int nErr; /* Number of errors encountered */
int mxRail; /* Number of rails required to render the graph */
GraphRow *pFirst; /* First row in the list */
GraphRow *pLast; /* Last row in the list */
int nBranch; /* Number of distinct branches */
char **azBranch; /* Names of the branches */
int railMap[GR_MAX_RAIL]; /* Rail order mapping */
};
#endif
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
void *p = malloc(nByte);
if( p==0 ) fossil_panic("out of memory");
memset(p, 0, nByte);
return p;
}
/*
** Create and initialize a GraphContext
*/
GraphContext *graph_init(void){
return (GraphContext*)safeMalloc( sizeof(GraphContext) );
}
/*
** Destroy a GraphContext;
*/
void graph_free(GraphContext *p){
int i;
GraphRow *pRow;
while( p->pFirst ){
pRow = p->pFirst;
p->pFirst = pRow->pNext;
free(pRow);
}
for(i=0; i<p->nBranch; i++) free(p->azBranch[i]);
free(p->azBranch);
free(p);
}
/*
** Return the canonical pointer for a given branch name.
** Multiple calls to this routine with equivalent strings
** will return the same pointer.
*/
static char *persistBranchName(GraphContext *p, const char *zBranch){
int i;
for(i=0; i<p->nBranch; i++){
if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i];
}
p->nBranch++;
p->azBranch = realloc(p->azBranch, sizeof(char*)*p->nBranch);
if( p->azBranch==0 ) fossil_panic("out of memory");
p->azBranch[p->nBranch-1] = mprintf("%s", zBranch);
return p->azBranch[p->nBranch-1];
}
/*
** Add a new row t the graph context. Rows are added from top to bottom.
*/
void graph_add_row(
GraphContext *p, /* The context to which the row is added */
int rid, /* RID for the check-in */
int isLeaf, /* True if the check-in is an leaf */
int nParent, /* Number of parents */
int *aParent, /* Array of parents */
const char *zBranch /* Branch for this check-in */
){
GraphRow *pRow;
if( p->nErr ) return;
if( nParent>GR_MAX_PARENT ){ p->nErr++; return; }
pRow = (GraphRow*)safeMalloc( sizeof(GraphRow) );
pRow->rid = rid;
pRow->isLeaf = isLeaf;
pRow->nParent = nParent;
pRow->zBranch = persistBranchName(p, zBranch);
memcpy(pRow->aParent, aParent, sizeof(aParent[0])*nParent);
if( p->pFirst==0 ){
p->pFirst = pRow;
}else{
p->pLast->pNext = pRow;
}
p->pLast = pRow;
}
/*
** Return the index of a rail currently not in use for any row between
** top and bottom, inclusive.
*/
static int findFreeRail(GraphContext *p, int top, int btm){
u32 inUseMask = 0;
GraphRow *pRow;
int i;
for(pRow=p->pFirst; pRow && pRow->idx<top; pRow=pRow->pNext){}
while( pRow && pRow->idx<=btm ){
inUseMask |= pRow->railInUse;
pRow = pRow->pNext;
}
for(i=0; i<32; i++){
if( (inUseMask & (1<<i))==0 ) return i;
}
p->nErr++;
return 0;
}
/*
** Compute the complete graph
*/
void graph_finish(GraphContext *p){
GraphRow *pRow, *pDesc;
Bag allRids;
int i;
int nRow;
u32 mask;
if( p==0 || p->pFirst==0 || p->nErr ) return;
/* Initialize all rows */
bag_init(&allRids);
nRow = 0;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->pNext ) pRow->pNext->pPrev = pRow;
pRow->idx = ++nRow;
pRow->iRail = -1;
pRow->mergeOut = -1;
bag_insert(&allRids, pRow->rid);
}
p->mxRail = -1;
/* Purge merge-parents that are out-of-graph
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
for(i=1; i<pRow->nParent; i++){
if( !bag_find(&allRids, pRow->aParent[i]) ){
pRow->aParent[i] = pRow->aParent[--pRow->nParent];
i--;
}
}
}
/* Identify rows where the primary parent is off screen. Assign
** each to a rail and draw descenders to the bottom of the screen.
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->nParent>0 && !bag_find(&allRids,pRow->aParent[0]) ){
pRow->iRail = ++p->mxRail;
pRow->bDescender = 1;
mask = 1<<(pRow->iRail);
for(pDesc=pRow; pDesc; pDesc=pDesc->pNext){
pDesc->railInUse |= mask;
}
}
}
/* Assign rails to all rows that are still unassigned.
** The first primary child of a row goes on the same rail as
** that row.
*/
for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
int parentRid;
if( pRow->iRail>=0 ) continue;
assert( pRow->nParent>0 );
parentRid = pRow->aParent[0];
assert( bag_find(&allRids, parentRid) );
for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid; pDesc=pDesc->pNext){}
assert( pDesc!=0 );
if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
pRow->iRail = pDesc->iRail;
}else{
pRow->iRail = findFreeRail(p, 0, pDesc->idx);
}
pDesc->aiRaiser[pRow->iRail] = pRow->idx;
mask = 1<<pRow->iRail;
for(pDesc = pRow; ; pDesc=pDesc->pNext){
assert( pDesc!=0 );
pDesc->railInUse |= mask;
if( pDesc->rid==parentRid ) break;
}
}
/*
** Insert merge rails and merge arrows
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
for(i=1; i<pRow->nParent; i++){
int parentRid = pRow->aParent[i];
for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid;
pDesc=pDesc->pNext){}
if( pDesc==0 ) continue;
if( pDesc->mergeOut<0 ){
pDesc->mergeOut = findFreeRail(p, pRow->idx, pDesc->idx);
pDesc->mergeUpto = pRow->idx;
}
pRow->mergeIn |= 1<<pDesc->mergeOut;
}
}
/*
** Sort the rail numbers
*/
#if 0
p->mxRail = -1;
mask = 0;
for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
if( (mask & (1<<pRow->iRail))==0 ){
p->railMap[pRow->iRail] = ++p->mxRail;
mask |= 1<<pRow->iRail;
}
if( pRow->mergeOut>=0 && (mask & (1<<pRow->mergeOut))==0 ){
p->railMap[pRow->mergeOut] = ++p->mxRail;
mask |= 1<<pRow->mergeOut;
}
}
#else
for(i=0; i<GR_MAX_RAIL; i++) p->railMap[i] = i;
p->mxRail = 0;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
if( pRow->mergeOut>p->mxRail ) p->mxRail = pRow->mergeOut;
}
#endif
}
|
Changes to src/main.mk.
| ︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | $(SRCDIR)/descendants.c \ $(SRCDIR)/diff.c \ $(SRCDIR)/diffcmd.c \ $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/file.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/http.c \ $(SRCDIR)/http_socket.c \ $(SRCDIR)/http_transport.c \ $(SRCDIR)/info.c \ $(SRCDIR)/login.c \ $(SRCDIR)/main.c \ $(SRCDIR)/manifest.c \ | > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | $(SRCDIR)/descendants.c \ $(SRCDIR)/diff.c \ $(SRCDIR)/diffcmd.c \ $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/file.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/graph.c \ $(SRCDIR)/http.c \ $(SRCDIR)/http_socket.c \ $(SRCDIR)/http_transport.c \ $(SRCDIR)/info.c \ $(SRCDIR)/login.c \ $(SRCDIR)/main.c \ $(SRCDIR)/manifest.c \ |
| ︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | descendants_.c \ diff_.c \ diffcmd_.c \ doc_.c \ encode_.c \ file_.c \ finfo_.c \ http_.c \ http_socket_.c \ http_transport_.c \ info_.c \ login_.c \ main_.c \ manifest_.c \ | > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | descendants_.c \ diff_.c \ diffcmd_.c \ doc_.c \ encode_.c \ file_.c \ finfo_.c \ graph_.c \ http_.c \ http_socket_.c \ http_transport_.c \ info_.c \ login_.c \ main_.c \ manifest_.c \ |
| ︙ | ︙ | |||
177 178 179 180 181 182 183 184 185 186 187 188 189 190 | descendants.o \ diff.o \ diffcmd.o \ doc.o \ encode.o \ file.o \ finfo.o \ http.o \ http_socket.o \ http_transport.o \ info.o \ login.o \ main.o \ manifest.o \ | > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | descendants.o \ diff.o \ diffcmd.o \ doc.o \ encode.o \ file.o \ finfo.o \ graph.o \ http.o \ http_socket.o \ http_transport.o \ info.o \ login.o \ main.o \ manifest.o \ |
| ︙ | ︙ | |||
262 263 264 265 266 267 268 | # $(SRCDIR)/../manifest: # noop clean: rm -f *.o *_.c $(APPNAME) VERSION.h rm -f translate makeheaders mkindex page_index.h headers | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | # $(SRCDIR)/../manifest: # noop clean: rm -f *.o *_.c $(APPNAME) VERSION.h rm -f translate makeheaders mkindex page_index.h headers rm -f add.h allrepo.h bag.h blob.h branch.h browse.h captcha.h cgi.h checkin.h checkout.h clearsign.h clone.h comformat.h configure.h construct.h content.h db.h delta.h deltacmd.h descendants.h diff.h diffcmd.h doc.h encode.h file.h finfo.h graph.h http.h http_socket.h http_transport.h info.h login.h main.h manifest.h md5.h merge.h merge3.h name.h pivot.h pqueue.h printf.h rebuild.h report.h rss.h rstats.h schema.h search.h setup.h sha1.h shun.h skins.h stat.h style.h sync.h tag.h th_main.h timeline.h tkt.h tktsetup.h undo.h update.h url.h user.h verify.h vfile.h wiki.h wikiformat.h winhttp.h xfer.h zip.h page_index.h: $(TRANS_SRC) mkindex ./mkindex $(TRANS_SRC) >$@ headers: page_index.h makeheaders VERSION.h ./makeheaders add_.c:add.h allrepo_.c:allrepo.h bag_.c:bag.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h construct_.c:construct.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h file_.c:file.h finfo_.c:finfo.h graph_.c:graph.h http_.c:http.h http_socket_.c:http_socket.h http_transport_.c:http_transport.h info_.c:info.h login_.c:login.h main_.c:main.h manifest_.c:manifest.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h name_.c:name.h pivot_.c:pivot.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h report_.c:report.h rss_.c:rss.h rstats_.c:rstats.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h update_.c:update.h url_.c:url.h user_.c:user.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winhttp_.c:winhttp.h xfer_.c:xfer.h zip_.c:zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h VERSION.h touch headers headers: Makefile Makefile: add_.c: $(SRCDIR)/add.c translate ./translate $(SRCDIR)/add.c >add_.c add.o: add_.c add.h $(SRCDIR)/config.h |
| ︙ | ︙ | |||
453 454 455 456 457 458 459 460 461 462 463 464 465 466 | finfo_.c: $(SRCDIR)/finfo.c translate ./translate $(SRCDIR)/finfo.c >finfo_.c finfo.o: finfo_.c finfo.h $(SRCDIR)/config.h $(XTCC) -o finfo.o -c finfo_.c finfo.h: headers http_.c: $(SRCDIR)/http.c translate ./translate $(SRCDIR)/http.c >http_.c http.o: http_.c http.h $(SRCDIR)/config.h $(XTCC) -o http.o -c http_.c http.h: headers | > > > > > > > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | finfo_.c: $(SRCDIR)/finfo.c translate ./translate $(SRCDIR)/finfo.c >finfo_.c finfo.o: finfo_.c finfo.h $(SRCDIR)/config.h $(XTCC) -o finfo.o -c finfo_.c finfo.h: headers graph_.c: $(SRCDIR)/graph.c translate ./translate $(SRCDIR)/graph.c >graph_.c graph.o: graph_.c graph.h $(SRCDIR)/config.h $(XTCC) -o graph.o -c graph_.c graph.h: headers http_.c: $(SRCDIR)/http.c translate ./translate $(SRCDIR)/http.c >http_.c http.o: http_.c http.h $(SRCDIR)/config.h $(XTCC) -o http.o -c http_.c http.h: headers |
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | descendants diff diffcmd doc encode file finfo http http_socket http_transport info login main manifest | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | descendants diff diffcmd doc encode file finfo graph http http_socket http_transport info login main manifest |
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /* ** Allowed flags for the tmFlags argument to www_print_timeline */ #if INTERFACE #define TIMELINE_ARTID 0x0001 /* Show artifact IDs on non-check-in lines */ #define TIMELINE_LEAFONLY 0x0002 /* Show "Leaf", but not "Merge", "Fork" etc */ #define TIMELINE_BRIEF 0x0004 /* Combine adjacent elements of same object */ #endif /* ** Output a timeline in the web format given a query. The query ** should return these columns: ** ** 0. rid | > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /* ** Allowed flags for the tmFlags argument to www_print_timeline */ #if INTERFACE #define TIMELINE_ARTID 0x0001 /* Show artifact IDs on non-check-in lines */ #define TIMELINE_LEAFONLY 0x0002 /* Show "Leaf", but not "Merge", "Fork" etc */ #define TIMELINE_BRIEF 0x0004 /* Combine adjacent elements of same object */ #define TIMELINE_GRAPH 0x0008 /* Compute a graph */ #endif /* ** Output a timeline in the web format given a query. The query ** should return these columns: ** ** 0. rid |
| ︙ | ︙ | |||
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
){
int wikiFlags;
int mxWikiLen;
Blob comment;
int prevTagid = 0;
int suppressCnt = 0;
char zPrevDate[20];
zPrevDate[0] = 0;
mxWikiLen = db_get_int("timeline-max-comment", 0);
if( db_get_boolean("timeline-block-markup", 0) ){
wikiFlags = WIKI_INLINE;
}else{
wikiFlags = WIKI_INLINE | WIKI_NOBLOCK;
}
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS seen(rid INTEGER PRIMARY KEY);"
"DELETE FROM seen;"
);
@ <table cellspacing=0 border=0 cellpadding=0>
blob_zero(&comment);
while( db_step(pQuery)==SQLITE_ROW ){
int rid = db_column_int(pQuery, 0);
const char *zUuid = db_column_text(pQuery, 1);
int nPChild = db_column_int(pQuery, 5);
int nParent = db_column_int(pQuery, 6);
int isLeaf = db_column_int(pQuery, 7);
const char *zBgClr = db_column_text(pQuery, 8);
const char *zDate = db_column_text(pQuery, 2);
const char *zType = db_column_text(pQuery, 9);
const char *zUser = db_column_text(pQuery, 4);
const char *zTagList = db_column_text(pQuery, 10);
int tagid = db_column_int(pQuery, 11);
int commentColumn = 3; /* Column containing comment text */
if( tagid ){
if( tagid==prevTagid ){
if( tmFlags & TIMELINE_BRIEF ){
suppressCnt++;
continue;
}else{
commentColumn = 12;
| > > > > > > | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
){
int wikiFlags;
int mxWikiLen;
Blob comment;
int prevTagid = 0;
int suppressCnt = 0;
char zPrevDate[20];
GraphContext *pGraph = 0;
zPrevDate[0] = 0;
mxWikiLen = db_get_int("timeline-max-comment", 0);
if( db_get_boolean("timeline-block-markup", 0) ){
wikiFlags = WIKI_INLINE;
}else{
wikiFlags = WIKI_INLINE | WIKI_NOBLOCK;
}
if( tmFlags & TIMELINE_GRAPH ){
pGraph = graph_init();
@ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
}
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS seen(rid INTEGER PRIMARY KEY);"
"DELETE FROM seen;"
);
@ <table cellspacing=0 border=0 cellpadding=0>
blob_zero(&comment);
while( db_step(pQuery)==SQLITE_ROW ){
int rid = db_column_int(pQuery, 0);
const char *zUuid = db_column_text(pQuery, 1);
int nPChild = db_column_int(pQuery, 5);
int nParent = db_column_int(pQuery, 6);
int isLeaf = db_column_int(pQuery, 7);
const char *zBgClr = db_column_text(pQuery, 8);
const char *zDate = db_column_text(pQuery, 2);
const char *zType = db_column_text(pQuery, 9);
const char *zUser = db_column_text(pQuery, 4);
const char *zTagList = db_column_text(pQuery, 10);
int tagid = db_column_int(pQuery, 11);
int commentColumn = 3; /* Column containing comment text */
char zTime[8];
if( tagid ){
if( tagid==prevTagid ){
if( tmFlags & TIMELINE_BRIEF ){
suppressCnt++;
continue;
}else{
commentColumn = 12;
|
| ︙ | ︙ | |||
234 235 236 237 238 239 240 |
if( strcmp(zType,"div")==0 ){
@ <tr><td colspan=3><hr></td></tr>
continue;
}
db_multi_exec("INSERT OR IGNORE INTO seen VALUES(%d)", rid);
if( memcmp(zDate, zPrevDate, 10) ){
sprintf(zPrevDate, "%.10s", zDate);
| | | > > | | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
if( strcmp(zType,"div")==0 ){
@ <tr><td colspan=3><hr></td></tr>
continue;
}
db_multi_exec("INSERT OR IGNORE INTO seen VALUES(%d)", rid);
if( memcmp(zDate, zPrevDate, 10) ){
sprintf(zPrevDate, "%.10s", zDate);
@ <tr><td>
@ <div class="divider"><nobr>%s(zPrevDate)</nobr></div>
@ </td></tr>
}
memcpy(zTime, &zDate[11], 5);
zTime[5] = 0;
@ <tr>
@ <td valign="top" align="right">%s(zTime)</td>
@ <td width="20" align="center" valign="top">
@ <div id="m%d(rid)"></div>
if( zBgClr && zBgClr[0] ){
@ <td valign="top" align="left" bgcolor="%h(zBgClr)">
}else{
@ <td valign="top" align="left">
}
if( zType[0]=='c' ){
const char *azTag[5];
int nTag = 0;
hyperlink_to_uuid(zUuid);
if( (tmFlags & TIMELINE_LEAFONLY)==0 ){
if( nParent>1 ){
azTag[nTag++] = "Merge";
}
if( nPChild>1 ){
if( count_nonbranch_children(rid)>1 ){
azTag[nTag++] = "Fork";
|
| ︙ | ︙ | |||
278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
}
if( nTag>0 ){
int i;
for(i=0; i<nTag; i++){
@ <b>%s(azTag[i])%s(i==nTag-1?"":",")</b>
}
}
}else if( (tmFlags & TIMELINE_ARTID)!=0 ){
hyperlink_to_uuid(zUuid);
}
db_column_blob(pQuery, commentColumn, &comment);
if( mxWikiLen>0 && blob_size(&comment)>mxWikiLen ){
Blob truncated;
blob_zero(&truncated);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
}
if( nTag>0 ){
int i;
for(i=0; i<nTag; i++){
@ <b>%s(azTag[i])%s(i==nTag-1?"":",")</b>
}
}
if( pGraph ){
int nParent = 0;
int aParent[32];
const char *zBr;
static Stmt qparent;
static Stmt qbranch;
db_static_prepare(&qparent,
"SELECT pid FROM plink WHERE cid=:rid ORDER BY isprim DESC"
);
db_static_prepare(&qbranch,
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
TAG_BRANCH
);
db_bind_int(&qparent, ":rid", rid);
while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){
aParent[nParent++] = db_column_int(&qparent, 0);
}
db_reset(&qparent);
db_bind_int(&qbranch, ":rid", rid);
if( db_step(&qbranch)==SQLITE_ROW ){
zBr = db_column_text(&qbranch, 0);
}else{
zBr = "trunk";
}
graph_add_row(pGraph, rid, isLeaf, nParent, aParent, zBr);
db_reset(&qbranch);
}
}else if( (tmFlags & TIMELINE_ARTID)!=0 ){
hyperlink_to_uuid(zUuid);
}
db_column_blob(pQuery, commentColumn, &comment);
if( mxWikiLen>0 && blob_size(&comment)>mxWikiLen ){
Blob truncated;
blob_zero(&truncated);
|
| ︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
@ </td></tr>
}
if( suppressCnt ){
@ <tr><td><td><td>
@ <small><i>... %d(suppressCnt) similar
@ event%s(suppressCnt>1?"s":"") omitted.</i></small></tr>
suppressCnt = 0;
}
@ </table>
}
/*
** Create a temporary table suitable for storing timeline data.
*/
static void timeline_temp_table(void){
static const char zSql[] =
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
@ </td></tr>
}
if( suppressCnt ){
@ <tr><td><td><td>
@ <small><i>... %d(suppressCnt) similar
@ event%s(suppressCnt>1?"s":"") omitted.</i></small></tr>
suppressCnt = 0;
}
if( pGraph ){
graph_finish(pGraph);
if( pGraph->nErr ){
graph_free(pGraph);
pGraph = 0;
}else{
@ <tr><td><td><div style="width:%d(pGraph->mxRail*20+30)px;"></div>
}
}
@ </table>
if( pGraph && pGraph->nErr==0 ){
GraphRow *pRow;
int i;
char cSep;
@ <script type="text/JavaScript">
cgi_printf("var rowinfo = [\n");
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
cgi_printf("{id:\"m%d\",r:%d,d:%d,mo:%d,mu:%d,u:%d,au:",
pRow->rid,
pRow->iRail,
pRow->bDescender,
pRow->mergeOut,
pRow->mergeUpto,
pRow->aiRaiser[pRow->iRail]
);
cSep = '[';
for(i=0; i<GR_MAX_RAIL; i++){
if( i==pRow->iRail ) continue;
if( pRow->aiRaiser[i]>0 ){
cgi_printf("%c%d,%d", cSep, pGraph->railMap[i], pRow->aiRaiser[i]);
cSep = ',';
}
}
if( cSep=='[' ) cgi_printf("[");
cgi_printf("],mi:");
cSep = '[';
for(i=0; i<GR_MAX_RAIL; i++){
if( pRow->mergeIn & (1<<i) ){
cgi_printf("%c%d", cSep, pGraph->railMap[i]);
cSep = ',';
}
}
if( cSep=='[' ) cgi_printf("[");
cgi_printf("]}%s", pRow->pNext ? ",\n" : "];\n");
}
cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
graph_free(pGraph);
@ var canvasDiv = document.getElementById("canvas");
@ function drawBox(color,x0,y0,x1,y1){
@ var n = document.createElement("div");
@ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
@ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
@ var w = x1-x0+1;
@ var h = y1-y0+1;
@ n.setAttribute("style",
@ "position:absolute;"+
@ "left:"+x0+"px;"+
@ "top:"+y0+"px;"+
@ "width:"+w+"px;"+
@ "height:"+h+"px;"+
@ "background-color:"+color+";"
@ );
@ canvasDiv.appendChild(n);
@ }
@ function absoluteY(id){
@ var obj = document.getElementById(id);
@ if( !obj ) return;
@ var top = 0;
@ if( obj.offsetParent ){
@ do{
@ top += obj.offsetTop;
@ }while( obj = obj.offsetParent );
@ }
@ return top;
@ }
@ function absoluteX(id){
@ var obj = document.getElementById(id);
@ if( !obj ) return;
@ var left = 0;
@ if( obj.offsetParent ){
@ do{
@ left += obj.offsetLeft;
@ }while( obj = obj.offsetParent );
@ }
@ return left;
@ }
@ function drawUpArrow(x,y0,y1){
@ drawBox("black",x,y0,x+1,y1);
@ if( y0+8>=y1 ){
@ drawBox("black",x-1,y0+1,x+2,y0+2);
@ drawBox("black",x-2,y0+3,x+3,y0+4);
@ }else{
@ drawBox("black",x-1,y0+2,x+2,y0+4);
@ drawBox("black",x-2,y0+5,x+3,y0+7);
@ }
@ }
@ function drawThinArrow(y,xFrom,xTo){
@ if( xFrom<xTo ){
@ drawBox("black",xFrom,y,xTo,y);
@ drawBox("black",xTo-4,y-1,xTo-2,y+1);
@ if( xTo>xFrom-8 ) drawBox("black",xTo-6,y-2,xTo-5,y+2);
@ }else{
@ drawBox("black",xTo,y,xFrom,y);
@ drawBox("black",xTo+2,y-1,xTo+4,y+1);
@ if( xTo+8<xFrom ) drawBox("black",xTo+5,y-2,xTo+6,y+2);
@ }
@ }
@ function drawThinLine(x0,y0,x1,y1){
@ drawBox("black",x0,y0,x1,y1);
@ }
@ function drawNode(p, left, btm){
@ drawBox("black",p.x-5,p.y-5,p.x+6,p.y+6);
@ drawBox("white",p.x-4,p.y-4,p.x+5,p.y+5);
@ if( p.u>0 ){
@ var u = rowinfo[p.u-1];
@ drawUpArrow(p.x, u.y+6, p.y-5);
@ }
@ if( p.d ){
@ drawUpArrow(p.x, p.y+6, btm);
@ }
@ if( p.mo>=0 ){
@ var x1 = p.mo*20 + left;
@ var y1 = p.y-3;
@ var x0 = x1>p.x ? p.x+7 : p.x-6;
@ var u = rowinfo[p.mu-1];
@ var y0 = u.y+5;
@ drawThinLine(x0,y1,x1,y1);
@ drawThinLine(x1,y0,x1,y1);
@ }
@ var n = p.au.length;
@ for(var i=0; i<n; i+=2){
@ var x1 = p.au[i]*20 + left;
@ var x0 = x1>p.x ? p.x+7 : p.x-6;
@ drawBox("black",x0,p.y,x1,p.y+1);
@ var u = rowinfo[p.au[i+1]-1];
@ drawUpArrow(x1, u.y+6, p.y);
@ }
@ for(var j in p.mi){
@ var y0 = p.y+5;
@ var mx = p.mi[j]*20 + left;
@ if( mx>p.x ){
@ drawThinArrow(y0,mx,p.x+5);
@ }else{
@ drawThinArrow(y0,mx,p.x-5);
@ }
@ }
@ }
@ function renderGraph(){
@ var canvasY = absoluteY("canvas");
@ var left = absoluteX(rowinfo[0].id) - absoluteX("canvas") + 15;
@ for(var i in rowinfo){
@ rowinfo[i].y = absoluteY(rowinfo[i].id) + 10 - canvasY;
@ rowinfo[i].x = left + rowinfo[i].r*20;
@ }
@ var btm = rowinfo[rowinfo.length-1].y + 20;
@ for(var i in rowinfo){
@ drawNode(rowinfo[i], left, btm);
@ }
@ }
@ renderGraph();
@ </script>
}
}
/*
** Create a temporary table suitable for storing timeline data.
*/
static void timeline_temp_table(void){
static const char zSql[] =
|
| ︙ | ︙ | |||
459 460 461 462 463 464 465 |
if( !g.okRead && !g.okRdTkt && !g.okRdWiki ){ login_needed(); return; }
if( zTagName && g.okRead ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTagName);
}else{
tagid = 0;
}
if( zType[0]=='a' ){
| | | | 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 |
if( !g.okRead && !g.okRdTkt && !g.okRdWiki ){ login_needed(); return; }
if( zTagName && g.okRead ){
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTagName);
}else{
tagid = 0;
}
if( zType[0]=='a' ){
tmFlags = TIMELINE_BRIEF | TIMELINE_GRAPH;
}else{
tmFlags = TIMELINE_GRAPH;
}
style_header("Timeline");
login_anonymous_available();
timeline_temp_table();
blob_zero(&sql);
blob_zero(&desc);
|
| ︙ | ︙ | |||
643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
blob_appendf(&desc, "%d %ss", n, zEType);
}
if( zUser ){
blob_appendf(&desc, " by user %h", zUser);
}
if( tagid>0 ){
blob_appendf(&desc, " tagged with \"%h\"", zTagName);
}
if( zAfter ){
blob_appendf(&desc, " occurring on or after %h.<br>", zAfter);
}else if( zBefore ){
blob_appendf(&desc, " occurring on or before %h.<br>", zBefore);
}else if( zCirca ){
blob_appendf(&desc, " occurring around %h.<br>", zCirca);
| > | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
blob_appendf(&desc, "%d %ss", n, zEType);
}
if( zUser ){
blob_appendf(&desc, " by user %h", zUser);
}
if( tagid>0 ){
blob_appendf(&desc, " tagged with \"%h\"", zTagName);
tmFlags &= ~TIMELINE_GRAPH;
}
if( zAfter ){
blob_appendf(&desc, " occurring on or after %h.<br>", zAfter);
}else if( zBefore ){
blob_appendf(&desc, " occurring on or before %h.<br>", zBefore);
}else if( zCirca ){
blob_appendf(&desc, " occurring around %h.<br>", zCirca);
|
| ︙ | ︙ | |||
689 690 691 692 693 694 695 | } blob_zero(&sql); db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC"); @ <h2>%b(&desc)</h2> blob_reset(&desc); www_print_timeline(&q, tmFlags, 0); db_finalize(&q); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | } blob_zero(&sql); db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC"); @ <h2>%b(&desc)</h2> blob_reset(&desc); www_print_timeline(&q, tmFlags, 0); db_finalize(&q); style_footer(); } /* ** The input query q selects various records. Print a human-readable ** summary of those records. ** |
| ︙ | ︙ |