Fossil

Check-in [e38c89130f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a human-readable description on each timeline. Add the "ancestors" and "decendents" links on the baseline information pages, making it easier to understand the context of a baseline.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e38c89130f8ee98be86a3a22c60bf65666487477
User & Date: drh 2008-02-24 21:51:57.000
Context
2008-02-25
00:18
Fix a bug in the "info" webpage. ... (check-in: 16e765bac5 user: drh tags: trunk)
2008-02-24
21:51
Add a human-readable description on each timeline. Add the "ancestors" and "decendents" links on the baseline information pages, making it easier to understand the context of a baseline. ... (check-in: e38c89130f user: drh tags: trunk)
18:50
Merged to [ed26056bb5]. ... (check-in: 588bb7cd73 user: aku tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/info.c.
329
330
331
332
333
334
335




336
337
338
339
340
341
342
    @ <tr><th>Date:</th><td>%s(db_column_text(&q, 1))</td></tr>
    if( g.okSetup ){
      @ <tr><th>Record ID:</th><td>%d(rid)</td></tr>
    }
    @ <tr><th>Original&nbsp;User:</th><td>%h(db_column_text(&q, 2))</td></tr>
    @ <tr><th>Original&nbsp;Comment:</th><td>%w(db_column_text(&q,3))</td></tr>
    @ </td></tr>




    @ <tr><th>Commands:</th>
    @   <td>
    @     <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a>
    @     | <a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a>
    @     | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
    @   </td>
    @ </tr>







>
>
>
>







329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
    @ <tr><th>Date:</th><td>%s(db_column_text(&q, 1))</td></tr>
    if( g.okSetup ){
      @ <tr><th>Record ID:</th><td>%d(rid)</td></tr>
    }
    @ <tr><th>Original&nbsp;User:</th><td>%h(db_column_text(&q, 2))</td></tr>
    @ <tr><th>Original&nbsp;Comment:</th><td>%w(db_column_text(&q,3))</td></tr>
    @ </td></tr>
    @ <tr><th>Timelines:</th><td>
    @    <a href="%s(g.zBaseURL)/timeline?e=%d(rid)&r">ancestors</a>
    @    | <a href="%s(g.zBaseURL)/timeline?e=%d(rid)&r&a">descendents</a>
    @ </td></tr>
    @ <tr><th>Commands:</th>
    @   <td>
    @     <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a>
    @     | <a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a>
    @     | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
    @   </td>
    @ </tr>
Changes to src/timeline.c.
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
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
328
329
330
331
332


333
334
335
336
337
338
339
**    u=NAME         show only events from user.        dflt: nil
**    a              show events after and including.   dflt: false
**    r              show only related events.          dflt: false
**    y=TYPE         show only TYPE ('ci' or 'w')       dflt: nil
**    s              show the SQL                       dflt: nil
*/
void page_timeline(void){
  Stmt q;
  Blob sql;
  char *zSQL;
  Blob scriptInit;
  char zDate[100];
  const char *zStart = P("d");
  int nEntry = atoi(PD("n","20"));
  const char *zUser = P("u");
  int objid = atoi(PD("e","0"));
  int relatedEvents = P("r")!=0;
  int afterFlag = P("a")!=0;
  const char *zType = P("y");
  int firstEvent;
  int lastEvent;



  /* To view the timeline, must have permission to read project data.
  */
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }

  style_header("Timeline");
  if( !g.okHistory &&
      db_exists("SELECT 1 FROM user"
                " WHERE login='anonymous'"
                "   AND cap LIKE '%%h%%'") ){
    @ <p><b>Note:</b> You will be able to access <u>much</u> more
    @ historical information if you <a href="%s(g.zTop)/login">login</a>.</p>
  }
  blob_zero(&sql);

  blob_append(&sql, timeline_query_for_www(), -1);

  if( zType ){
    blob_appendf(&sql, " AND event.type=%Q", zType);




  }


  if( zUser ){
    blob_appendf(&sql, " AND event.user=%Q", zUser);

  }
  if( objid ){
    char *z = db_text(0, "SELECT datetime(event.mtime, 'localtime') FROM event"
                         " WHERE objid=%d", objid);
    if( z ){
      zStart = z;
    }
  }
  if( zStart ){
    while( isspace(zStart[0]) ){ zStart++; }
    if( zStart[0] ){
      blob_appendf(&sql, 
         " AND event.mtime %s (SELECT julianday(%Q, 'utc'))",
                          afterFlag ? ">=" : "<=", zStart);



    }
  }
  if( relatedEvents && objid ){

    db_multi_exec(
       "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
    );

    if( afterFlag ){
      compute_descendents(objid, nEntry);



    }else{
      compute_ancestors(objid, nEntry);



    }
    blob_append(&sql, " AND event.objid IN ok", -1);
  }
  if( afterFlag ){
    blob_appendf(&sql, " ORDER BY event.mtime ASC LIMIT %d",
                 nEntry);
  }else{
    blob_appendf(&sql, " ORDER BY event.mtime DESC LIMIT %d",
                 nEntry);
  }
  zSQL = blob_str(&sql);
  if( afterFlag ){
    zSQL = mprintf("SELECT * FROM (%s) ORDER BY timestamp DESC", zSQL);
  }
  db_prepare(&q, zSQL);
  if( P("s")!=0 ){
    @ <hr><p>%h(zSQL)</p><hr>
  }


  blob_zero(&sql);
  if( afterFlag ){
    free(zSQL);
  }
  zDate[0] = 0;
  blob_zero(&scriptInit);
  zDate[0] = 0;







|
|
|


|
|
|
|
|
|
|
|
|
>
>















>

>


>
>
>
>
|
>
>


>














>
>
>



>



>


>
>
>


>
>
>


















>
>







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
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
**    u=NAME         show only events from user.        dflt: nil
**    a              show events after and including.   dflt: false
**    r              show only related events.          dflt: false
**    y=TYPE         show only TYPE ('ci' or 'w')       dflt: nil
**    s              show the SQL                       dflt: nil
*/
void page_timeline(void){
  Stmt q;           
  Blob sql;                    /* text of SQL used to generate timeline */
  char *zSQL;                  /* Rendered copy of sql */
  Blob scriptInit;
  char zDate[100];
  const char *zStart = P("d");       /* Starting date */
  int nEntry = atoi(PD("n","20"));   /* Max number of entries on timeline */
  const char *zUser = P("u");        /* All entries by this user if not NULL */
  int objid = atoi(PD("e","0"));     /* Entries related to this event */
  int relatedEvents = P("r")!=0;     /* Must be directly related to of objid */
  int afterFlag = P("a")!=0;         /* After objid if true */
  const char *zType = P("y");        /* Type of events.  All if NULL */
  int firstEvent;              /* First event displayed */
  int lastEvent;               /* Last event displayed */
  Blob desc;                   /* Human readable description of the timeline */
  const char *zEType;          /* Human readable event type */

  /* To view the timeline, must have permission to read project data.
  */
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }

  style_header("Timeline");
  if( !g.okHistory &&
      db_exists("SELECT 1 FROM user"
                " WHERE login='anonymous'"
                "   AND cap LIKE '%%h%%'") ){
    @ <p><b>Note:</b> You will be able to access <u>much</u> more
    @ historical information if you <a href="%s(g.zTop)/login">login</a>.</p>
  }
  blob_zero(&sql);
  blob_zero(&desc);
  blob_append(&sql, timeline_query_for_www(), -1);
  zEType = "events";
  if( zType ){
    blob_appendf(&sql, " AND event.type=%Q", zType);
    if( zType[0]=='c' ){
      zEType = "checkins";
    }else if( zType[0]=='w' ){
      zEType = "wiki edits";
    }
  }
  blob_appendf(&desc, "Timeline of up to %d %s", nEntry, zEType);
  if( zUser ){
    blob_appendf(&sql, " AND event.user=%Q", zUser);
    blob_appendf(&desc, " by user %h", zUser);
  }
  if( objid ){
    char *z = db_text(0, "SELECT datetime(event.mtime, 'localtime') FROM event"
                         " WHERE objid=%d", objid);
    if( z ){
      zStart = z;
    }
  }
  if( zStart ){
    while( isspace(zStart[0]) ){ zStart++; }
    if( zStart[0] ){
      blob_appendf(&sql, 
         " AND event.mtime %s (SELECT julianday(%Q, 'utc'))",
                          afterFlag ? ">=" : "<=", zStart);
      blob_appendf(&desc, " occurring on or %s %h",
          afterFlag ? "after": "before",
          zStart);
    }
  }
  if( relatedEvents && objid ){
    char *zUuid;
    db_multi_exec(
       "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
    );
    zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", objid);
    if( afterFlag ){
      compute_descendents(objid, nEntry);
      blob_appendf(&desc,
         " and decended from <a href='%s/vinfo/%d'>[%.10s]</a>",
         g.zBaseURL, objid, zUuid);
    }else{
      compute_ancestors(objid, nEntry);
      blob_appendf(&desc,
         " and a ancestor of <a href='%s/vinfo/%d'>[%.10s]</a>",
         g.zBaseURL, objid, zUuid);
    }
    blob_append(&sql, " AND event.objid IN ok", -1);
  }
  if( afterFlag ){
    blob_appendf(&sql, " ORDER BY event.mtime ASC LIMIT %d",
                 nEntry);
  }else{
    blob_appendf(&sql, " ORDER BY event.mtime DESC LIMIT %d",
                 nEntry);
  }
  zSQL = blob_str(&sql);
  if( afterFlag ){
    zSQL = mprintf("SELECT * FROM (%s) ORDER BY timestamp DESC", zSQL);
  }
  db_prepare(&q, zSQL);
  if( P("s")!=0 ){
    @ <hr><p>%h(zSQL)</p><hr>
  }
  @ <h2>%b(&desc)</h2>
  blob_reset(&desc);
  blob_zero(&sql);
  if( afterFlag ){
    free(zSQL);
  }
  zDate[0] = 0;
  blob_zero(&scriptInit);
  zDate[0] = 0;