Hex Artifact Content
Not logged in

Artifact 346b9fb48c45b1daa9a78cab1934425d81c22c2e:

File src/timeline.c part of check-in [afcdc7ec97] - Add the "leaves" webpage and the "branches" CLI command. We need to work on the nomenclature. by drh on 2007-08-01 12:49:41.

0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20  /*.** Copyright 
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68  (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54  ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66  his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f  ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75  u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20  te it and/or.** 
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20  modify it under 
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65  the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76  lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c  ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65  ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69  ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73  s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20  tributed in the 
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c  hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20  l be useful,.** 
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20  but WITHOUT ANY 
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75  WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69  t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a  ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54  * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52  Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55   A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20  RPOSE.  See the 
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50  GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f  ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a  r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c  ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20  d have received 
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e  a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63  U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e  .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72  g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69  ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65  te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20  ation, Inc., 59 
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53  Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73  uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31  ton, MA  02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20  307, USA..**.** 
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69  Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20  nformation:.**  
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a   drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  *   http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a  waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65  .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 74   contains code t
0380: 6f 20 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 20  o implement the 
0390: 74 69 6d 65 6c 69 6e 65 20 77 65 62 20 70 61 67  timeline web pag
03a0: 65 0a 2a 2a 0a 2a 2f 0a 23 69 6e 63 6c 75 64 65  e.**.*/.#include
03b0: 20 22 63 6f 6e 66 69 67 2e 68 22 0a 23 69 6e 63   "config.h".#inc
03c0: 6c 75 64 65 20 22 74 69 6d 65 6c 69 6e 65 2e 68  lude "timeline.h
03d0: 22 0a 0a 2f 2a 0a 2a 2a 20 47 65 6e 65 72 61 74  "../*.** Generat
03e0: 65 20 61 20 68 79 70 65 72 6c 69 6e 6b 20 74 6f  e a hyperlink to
03f0: 20 61 20 76 65 72 73 69 6f 6e 2e 0a 2a 2f 0a 76   a version..*/.v
0400: 6f 69 64 20 68 79 70 65 72 6c 69 6e 6b 5f 74 6f  oid hyperlink_to
0410: 5f 75 75 69 64 28 63 6f 6e 73 74 20 63 68 61 72  _uuid(const char
0420: 20 2a 7a 55 75 69 64 29 7b 0a 20 20 63 68 61 72   *zUuid){.  char
0430: 20 7a 53 68 6f 72 74 55 75 69 64 5b 55 55 49 44   zShortUuid[UUID
0440: 5f 53 49 5a 45 2b 31 5d 3b 0a 20 20 73 70 72 69  _SIZE+1];.  spri
0450: 6e 74 66 28 7a 53 68 6f 72 74 55 75 69 64 2c 20  ntf(zShortUuid, 
0460: 22 25 2e 31 30 73 22 2c 20 7a 55 75 69 64 29 3b  "%.10s", zUuid);
0470: 0a 20 20 69 66 28 20 67 2e 6f 6b 48 69 73 74 6f  .  if( g.okHisto
0480: 72 79 20 29 7b 0a 20 20 20 20 40 20 3c 61 20 68  ry ){.    @ <a h
0490: 72 65 66 3d 22 25 73 28 67 2e 7a 42 61 73 65 55  ref="%s(g.zBaseU
04a0: 52 4c 29 2f 76 69 6e 66 6f 2f 25 73 28 7a 55 75  RL)/vinfo/%s(zUu
04b0: 69 64 29 22 3e 5b 25 73 28 7a 53 68 6f 72 74 55  id)">[%s(zShortU
04c0: 75 69 64 29 5d 3c 2f 61 3e 0a 20 20 7d 65 6c 73  uid)]</a>.  }els
04d0: 65 7b 0a 20 20 20 20 40 20 3c 62 3e 5b 25 73 28  e{.    @ <b>[%s(
04e0: 7a 53 68 6f 72 74 55 75 69 64 29 5d 3c 2f 62 3e  zShortUuid)]</b>
04f0: 0a 20 20 7d 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 47 65  .  }.}../*.** Ge
0500: 6e 65 72 61 74 65 20 61 20 68 79 70 65 72 6c 69  nerate a hyperli
0510: 6e 6b 20 74 6f 20 61 20 64 69 66 66 20 62 65 74  nk to a diff bet
0520: 77 65 65 6e 20 74 77 6f 20 76 65 72 73 69 6f 6e  ween two version
0530: 73 2e 0a 2a 2f 0a 76 6f 69 64 20 68 79 70 65 72  s..*/.void hyper
0540: 6c 69 6e 6b 5f 74 6f 5f 64 69 66 66 28 63 6f 6e  link_to_diff(con
0550: 73 74 20 63 68 61 72 20 2a 7a 56 31 2c 20 63 6f  st char *zV1, co
0560: 6e 73 74 20 63 68 61 72 20 2a 7a 56 32 29 7b 0a  nst char *zV2){.
0570: 20 20 69 66 28 20 67 2e 6f 6b 48 69 73 74 6f 72    if( g.okHistor
0580: 79 20 29 7b 0a 20 20 20 20 69 66 28 20 7a 56 32  y ){.    if( zV2
0590: 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 40 20 3c  ==0 ){.      @ <
05a0: 61 20 68 72 65 66 3d 22 25 73 28 67 2e 7a 42 61  a href="%s(g.zBa
05b0: 73 65 55 52 4c 29 2f 64 69 66 66 3f 76 32 3d 25  seURL)/diff?v2=%
05c0: 73 28 7a 56 31 29 22 3e 5b 64 69 66 66 5d 3c 2f  s(zV1)">[diff]</
05d0: 61 3e 0a 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20  a>.    }else{.  
05e0: 20 20 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25      @ <a href="%
05f0: 73 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 64 69  s(g.zBaseURL)/di
0600: 66 66 3f 76 31 3d 25 73 28 7a 56 31 29 26 76 32  ff?v1=%s(zV1)&v2
0610: 3d 25 73 28 7a 56 32 29 22 3e 5b 64 69 66 66 5d  =%s(zV2)">[diff]
0620: 3c 2f 61 3e 0a 20 20 20 20 7d 0a 20 20 7d 0a 7d  </a>.    }.  }.}
0630: 0a 0a 2f 2a 0a 2a 2a 20 4f 75 74 70 75 74 20 61  ../*.** Output a
0640: 20 74 69 6d 65 6c 69 6e 65 20 69 6e 20 74 68 65   timeline in the
0650: 20 77 65 62 20 66 6f 72 6d 61 74 20 67 69 76 65   web format give
0660: 6e 20 61 20 71 75 65 72 79 2e 20 20 54 68 65 20  n a query.  The 
0670: 71 75 65 72 79 0a 2a 2a 20 73 68 6f 75 6c 64 20  query.** should 
0680: 72 65 74 75 72 6e 20 34 20 63 6f 6c 75 6d 6e 73  return 4 columns
0690: 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 30 2e 20 20 55  :.**.**    0.  U
06a0: 55 49 44 0a 2a 2a 20 20 20 20 31 2e 20 20 44 61  UID.**    1.  Da
06b0: 74 65 2f 54 69 6d 65 0a 2a 2a 20 20 20 20 32 2e  te/Time.**    2.
06c0: 20 20 43 6f 6d 6d 65 6e 74 20 73 74 72 69 6e 67    Comment string
06d0: 0a 2a 2a 20 20 20 20 33 2e 20 20 55 73 65 72 0a  .**    3.  User.
06e0: 2a 2f 0a 76 6f 69 64 20 77 77 77 5f 70 72 69 6e  */.void www_prin
06f0: 74 5f 74 69 6d 65 6c 69 6e 65 28 53 74 6d 74 20  t_timeline(Stmt 
0700: 2a 70 51 75 65 72 79 29 7b 0a 20 20 63 68 61 72  *pQuery){.  char
0710: 20 7a 50 72 65 76 44 61 74 65 5b 32 30 5d 3b 0a   zPrevDate[20];.
0720: 20 20 7a 50 72 65 76 44 61 74 65 5b 30 5d 20 3d    zPrevDate[0] =
0730: 20 30 3b 0a 20 20 40 20 3c 74 61 62 6c 65 20 63   0;.  @ <table c
0740: 65 6c 6c 73 70 61 63 69 6e 67 3d 30 20 62 6f 72  ellspacing=0 bor
0750: 64 65 72 3d 30 20 63 65 6c 6c 70 61 64 64 69 6e  der=0 cellpaddin
0760: 67 3d 30 3e 0a 20 20 77 68 69 6c 65 28 20 64 62  g=0>.  while( db
0770: 5f 73 74 65 70 28 70 51 75 65 72 79 29 3d 3d 53  _step(pQuery)==S
0780: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20  QLITE_ROW ){.   
0790: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 44 61   const char *zDa
07a0: 74 65 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74  te = db_column_t
07b0: 65 78 74 28 70 51 75 65 72 79 2c 20 31 29 3b 0a  ext(pQuery, 1);.
07c0: 20 20 20 20 69 66 28 20 6d 65 6d 63 6d 70 28 7a      if( memcmp(z
07d0: 44 61 74 65 2c 20 7a 50 72 65 76 44 61 74 65 2c  Date, zPrevDate,
07e0: 20 31 30 29 20 29 7b 0a 20 20 20 20 20 20 73 70   10) ){.      sp
07f0: 72 69 6e 74 66 28 7a 50 72 65 76 44 61 74 65 2c  rintf(zPrevDate,
0800: 20 22 25 2e 31 30 73 22 2c 20 7a 44 61 74 65 29   "%.10s", zDate)
0810: 3b 0a 20 20 20 20 20 20 40 20 3c 74 72 3e 3c 74  ;.      @ <tr><t
0820: 64 20 63 6f 6c 73 70 61 6e 3d 33 3e 0a 20 20 20  d colspan=3>.   
0830: 20 20 20 40 20 3c 74 61 62 6c 65 20 63 65 6c 6c     @ <table cell
0840: 70 61 64 64 69 6e 67 3d 32 20 62 6f 72 64 65 72  padding=2 border
0850: 3d 30 3e 0a 20 20 20 20 20 20 40 20 3c 74 72 3e  =0>.      @ <tr>
0860: 3c 74 64 20 62 67 63 6f 6c 6f 72 3d 22 23 61 30  <td bgcolor="#a0
0870: 62 35 66 34 22 20 63 6c 61 73 73 3d 22 62 6f 72  b5f4" class="bor
0880: 64 65 72 31 22 3e 0a 20 20 20 20 20 20 40 20 3c  der1">.      @ <
0890: 74 61 62 6c 65 20 63 65 6c 6c 70 61 64 64 69 6e  table cellpaddin
08a0: 67 3d 32 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d  g=2 cellspacing=
08b0: 30 20 62 6f 72 64 65 72 3d 30 3e 3c 74 72 3e 0a  0 border=0><tr>.
08c0: 20 20 20 20 20 20 40 20 3c 74 64 20 62 67 63 6f        @ <td bgco
08d0: 6c 6f 72 3d 22 23 64 30 64 39 66 34 22 20 63 6c  lor="#d0d9f4" cl
08e0: 61 73 73 3d 22 62 6b 67 6e 64 31 22 3e 25 73 28  ass="bkgnd1">%s(
08f0: 7a 50 72 65 76 44 61 74 65 29 3c 2f 74 64 3e 0a  zPrevDate)</td>.
0900: 20 20 20 20 20 20 40 20 3c 2f 74 72 3e 3c 2f 74        @ </tr></t
0910: 61 62 6c 65 3e 0a 20 20 20 20 20 20 40 20 3c 2f  able>.      @ </
0920: 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e  td></tr></table>
0930: 0a 20 20 20 20 20 20 40 20 3c 2f 74 64 3e 3c 2f  .      @ </td></
0940: 74 72 3e 0a 20 20 20 20 7d 0a 20 20 20 20 40 20  tr>.    }.    @ 
0950: 3c 74 72 3e 3c 74 64 20 76 61 6c 69 67 6e 3d 22  <tr><td valign="
0960: 74 6f 70 22 3e 25 73 28 26 7a 44 61 74 65 5b 31  top">%s(&zDate[1
0970: 31 5d 29 3c 2f 74 64 3e 0a 20 20 20 20 40 20 3c  1])</td>.    @ <
0980: 74 64 20 77 69 64 74 68 3d 22 32 30 22 3e 3c 2f  td width="20"></
0990: 74 64 3e 0a 20 20 20 20 40 20 3c 74 64 20 76 61  td>.    @ <td va
09a0: 6c 69 67 6e 3d 22 74 6f 70 22 20 61 6c 69 67 6e  lign="top" align
09b0: 3d 22 6c 65 66 74 22 3e 0a 20 20 20 20 68 79 70  ="left">.    hyp
09c0: 65 72 6c 69 6e 6b 5f 74 6f 5f 75 75 69 64 28 64  erlink_to_uuid(d
09d0: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 70 51  b_column_text(pQ
09e0: 75 65 72 79 2c 30 29 29 3b 0a 20 20 20 20 40 20  uery,0));.    @ 
09f0: 25 68 28 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78  %h(db_column_tex
0a00: 74 28 70 51 75 65 72 79 2c 32 29 29 20 28 62 79  t(pQuery,2)) (by
0a10: 20 25 68 28 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65   %h(db_column_te
0a20: 78 74 28 70 51 75 65 72 79 2c 33 29 29 29 3c 2f  xt(pQuery,3)))</
0a30: 74 64 3e 0a 20 20 7d 0a 20 20 40 20 3c 2f 74 61  td>.  }.  @ </ta
0a40: 62 6c 65 3e 0a 7d 0a 0a 0a 0a 2f 2a 0a 2a 2a 20  ble>.}..../*.** 
0a50: 57 45 42 50 41 47 45 3a 20 74 69 6d 65 6c 69 6e  WEBPAGE: timelin
0a60: 65 0a 2a 2f 0a 76 6f 69 64 20 70 61 67 65 5f 74  e.*/.void page_t
0a70: 69 6d 65 6c 69 6e 65 28 76 6f 69 64 29 7b 0a 20  imeline(void){. 
0a80: 20 53 74 6d 74 20 71 3b 0a 0a 20 20 2f 2a 20 54   Stmt q;..  /* T
0a90: 6f 20 76 69 65 77 20 74 68 65 20 74 69 6d 65 6c  o view the timel
0aa0: 69 6e 65 2c 20 6d 75 73 74 20 68 61 76 65 20 70  ine, must have p
0ab0: 65 72 6d 69 73 73 69 6f 6e 20 74 6f 20 72 65 61  ermission to rea
0ac0: 64 20 70 72 6f 6a 65 63 74 20 64 61 74 61 2e 0a  d project data..
0ad0: 20 20 2a 2f 0a 20 20 6c 6f 67 69 6e 5f 63 68 65    */.  login_che
0ae0: 63 6b 5f 63 72 65 64 65 6e 74 69 61 6c 73 28 29  ck_credentials()
0af0: 3b 0a 20 20 69 66 28 20 21 67 2e 6f 6b 52 65 61  ;.  if( !g.okRea
0b00: 64 20 29 7b 20 6c 6f 67 69 6e 5f 6e 65 65 64 65  d ){ login_neede
0b10: 64 28 29 3b 20 72 65 74 75 72 6e 3b 20 7d 0a 0a  d(); return; }..
0b20: 20 20 73 74 79 6c 65 5f 68 65 61 64 65 72 28 22    style_header("
0b30: 54 69 6d 65 6c 69 6e 65 22 29 3b 0a 20 20 64 62  Timeline");.  db
0b40: 5f 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20 20  _prepare(&q,.   
0b50: 20 22 53 45 4c 45 43 54 20 75 75 69 64 2c 20 64   "SELECT uuid, d
0b60: 61 74 65 74 69 6d 65 28 65 76 65 6e 74 2e 6d 74  atetime(event.mt
0b70: 69 6d 65 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29  ime,'localtime')
0b80: 2c 20 63 6f 6d 6d 65 6e 74 2c 20 75 73 65 72 22  , comment, user"
0b90: 0a 20 20 20 20 22 20 20 46 52 4f 4d 20 65 76 65  .    "  FROM eve
0ba0: 6e 74 2c 20 62 6c 6f 62 22 0a 20 20 20 20 22 20  nt, blob".    " 
0bb0: 57 48 45 52 45 20 65 76 65 6e 74 2e 74 79 70 65  WHERE event.type
0bc0: 3d 27 63 69 27 20 41 4e 44 20 62 6c 6f 62 2e 72  ='ci' AND blob.r
0bd0: 69 64 3d 65 76 65 6e 74 2e 6f 62 6a 69 64 22 0a  id=event.objid".
0be0: 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20 65      " ORDER BY e
0bf0: 76 65 6e 74 2e 6d 74 69 6d 65 20 44 45 53 43 22  vent.mtime DESC"
0c00: 0a 20 20 29 3b 0a 20 20 77 77 77 5f 70 72 69 6e  .  );.  www_prin
0c10: 74 5f 74 69 6d 65 6c 69 6e 65 28 26 71 29 3b 0a  t_timeline(&q);.
0c20: 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71    db_finalize(&q
0c30: 29 3b 0a 20 20 73 74 79 6c 65 5f 66 6f 6f 74 65  );.  style_foote
0c40: 72 28 29 3b 0a 7d 0a 2f 2a 0a 2a 2a 20 54 68 65  r();.}./*.** The
0c50: 20 69 6e 70 75 74 20 71 75 65 72 79 20 71 20 73   input query q s
0c60: 65 6c 65 63 74 73 20 76 61 72 69 6f 75 73 20 72  elects various r
0c70: 65 63 6f 72 64 73 2e 20 20 50 72 69 6e 74 20 61  ecords.  Print a
0c80: 20 68 75 6d 61 6e 2d 72 65 61 64 61 62 6c 65 0a   human-readable.
0c90: 2a 2a 20 73 75 6d 6d 61 72 79 20 6f 66 20 74 68  ** summary of th
0ca0: 6f 73 65 20 72 65 63 6f 72 64 73 2e 0a 2a 2a 0a  ose records..**.
0cb0: 2a 2a 20 4c 69 6d 69 74 20 74 68 65 20 6e 75 6d  ** Limit the num
0cc0: 62 65 72 20 6f 66 20 65 6e 74 72 69 65 73 20 70  ber of entries p
0cd0: 72 69 6e 74 65 64 20 74 6f 20 6e 4c 69 6e 65 2e  rinted to nLine.
0ce0: 0a 2a 2f 0a 76 6f 69 64 20 70 72 69 6e 74 5f 74  .*/.void print_t
0cf0: 69 6d 65 6c 69 6e 65 28 53 74 6d 74 20 2a 71 2c  imeline(Stmt *q,
0d00: 20 69 6e 74 20 6d 78 4c 69 6e 65 29 7b 0a 20 20   int mxLine){.  
0d10: 69 6e 74 20 6e 4c 69 6e 65 20 3d 20 30 3b 0a 20  int nLine = 0;. 
0d20: 20 63 68 61 72 20 7a 50 72 65 76 44 61 74 65 5b   char zPrevDate[
0d30: 32 30 5d 3b 0a 20 20 7a 50 72 65 76 44 61 74 65  20];.  zPrevDate
0d40: 5b 30 5d 20 3d 20 30 3b 0a 0a 20 20 77 68 69 6c  [0] = 0;..  whil
0d50: 65 28 20 64 62 5f 73 74 65 70 28 71 29 3d 3d 53  e( db_step(q)==S
0d60: 51 4c 49 54 45 5f 52 4f 57 20 26 26 20 6e 4c 69  QLITE_ROW && nLi
0d70: 6e 65 3c 3d 6d 78 4c 69 6e 65 20 29 7b 0a 20 20  ne<=mxLine ){.  
0d80: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 49    const char *zI
0d90: 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65  d = db_column_te
0da0: 78 74 28 71 2c 20 30 29 3b 0a 20 20 20 20 63 6f  xt(q, 0);.    co
0db0: 6e 73 74 20 63 68 61 72 20 2a 7a 44 61 74 65 20  nst char *zDate 
0dc0: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74  = db_column_text
0dd0: 28 71 2c 20 31 29 3b 0a 20 20 20 20 63 6f 6e 73  (q, 1);.    cons
0de0: 74 20 63 68 61 72 20 2a 7a 43 6f 6d 20 3d 20 64  t char *zCom = d
0df0: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 71 2c  b_column_text(q,
0e00: 20 32 29 3b 0a 20 20 20 20 63 68 61 72 20 7a 55   2);.    char zU
0e10: 75 69 64 5b 55 55 49 44 5f 53 49 5a 45 2b 31 5d  uid[UUID_SIZE+1]
0e20: 3b 0a 0a 20 20 20 20 73 70 72 69 6e 74 66 28 7a  ;..    sprintf(z
0e30: 55 75 69 64 2c 20 22 25 2e 31 30 73 22 2c 20 7a  Uuid, "%.10s", z
0e40: 49 64 29 3b 0a 20 20 20 20 69 66 28 20 6d 65 6d  Id);.    if( mem
0e50: 63 6d 70 28 7a 44 61 74 65 2c 20 7a 50 72 65 76  cmp(zDate, zPrev
0e60: 44 61 74 65 2c 20 31 30 29 20 29 7b 0a 20 20 20  Date, 10) ){.   
0e70: 20 20 20 70 72 69 6e 74 66 28 22 3d 3d 3d 20 25     printf("=== %
0e80: 2e 31 30 73 20 3d 3d 3d 5c 6e 22 2c 20 7a 44 61  .10s ===\n", zDa
0e90: 74 65 29 3b 0a 20 20 20 20 20 20 6d 65 6d 63 70  te);.      memcp
0ea0: 79 28 7a 50 72 65 76 44 61 74 65 2c 20 7a 44 61  y(zPrevDate, zDa
0eb0: 74 65 2c 20 31 30 29 3b 0a 20 20 20 20 20 20 6e  te, 10);.      n
0ec0: 4c 69 6e 65 2b 2b 3b 0a 20 20 20 20 7d 0a 20 20  Line++;.    }.  
0ed0: 20 20 69 66 28 20 7a 43 6f 6d 3d 3d 30 20 29 20    if( zCom==0 ) 
0ee0: 7a 43 6f 6d 20 3d 20 22 22 3b 0a 20 20 20 20 70  zCom = "";.    p
0ef0: 72 69 6e 74 66 28 22 25 2e 35 73 20 5b 25 2e 31  rintf("%.5s [%.1
0f00: 30 73 5d 20 22 2c 20 26 7a 44 61 74 65 5b 31 31  0s] ", &zDate[11
0f10: 5d 2c 20 7a 55 75 69 64 29 3b 0a 20 20 20 20 6e  ], zUuid);.    n
0f20: 4c 69 6e 65 20 2b 3d 20 63 6f 6d 6d 65 6e 74 5f  Line += comment_
0f30: 70 72 69 6e 74 28 7a 43 6f 6d 2c 20 31 39 2c 20  print(zCom, 19, 
0f40: 37 39 29 3b 0a 20 20 7d 0a 7d 0a 0a 0a 2f 2a 0a  79);.  }.}.../*.
0f50: 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 74 69 6d 65  ** COMMAND: time
0f60: 6c 69 6e 65 0a 2a 2a 0a 2a 2a 20 54 68 65 20 74  line.**.** The t
0f70: 69 6d 65 6c 69 6e 65 20 63 6f 6d 6d 61 6e 64 20  imeline command 
0f80: 77 6f 72 6b 73 20 76 65 72 79 20 6d 75 63 68 20  works very much 
0f90: 6c 69 6b 65 20 74 68 65 20 74 69 6d 65 6c 69 6e  like the timelin
0fa0: 65 20 77 65 62 70 61 67 65 2c 20 62 75 74 0a 2a  e webpage, but.*
0fb0: 2a 20 73 68 6f 77 73 20 6d 75 63 68 20 6c 65 73  * shows much les
0fc0: 73 20 64 61 74 61 20 61 6e 64 20 68 61 73 20 66  s data and has f
0fd0: 65 77 65 72 20 63 6f 6e 66 69 67 75 72 61 74 69  ewer configurati
0fe0: 6f 6e 20 6f 70 74 69 6f 6e 73 2e 20 20 49 74 20  on options.  It 
0ff0: 69 73 0a 2a 2a 20 69 6e 74 65 6e 64 65 64 20 61  is.** intended a
1000: 73 20 61 20 63 6f 6e 76 65 6e 69 65 6e 74 20 73  s a convenient s
1010: 68 6f 72 74 63 75 74 20 66 6f 72 20 74 68 65 20  hortcut for the 
1020: 63 6f 6d 6d 6f 6e 20 63 61 73 65 20 6f 66 20 73  common case of s
1030: 65 65 69 6e 67 0a 2a 2a 20 72 65 63 65 6e 74 20  eeing.** recent 
1040: 63 68 61 6e 67 65 73 2e 0a 2a 2f 0a 76 6f 69 64  changes..*/.void
1050: 20 74 69 6d 65 6c 69 6e 65 5f 63 6d 64 28 76 6f   timeline_cmd(vo
1060: 69 64 29 7b 0a 20 20 53 74 6d 74 20 71 3b 0a 20  id){.  Stmt q;. 
1070: 20 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68   db_must_be_with
1080: 69 6e 5f 74 72 65 65 28 29 3b 0a 20 20 64 62 5f  in_tree();.  db_
1090: 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20 20 20  prepare(&q,.    
10a0: 22 53 45 4c 45 43 54 20 75 75 69 64 2c 20 64 61  "SELECT uuid, da
10b0: 74 65 74 69 6d 65 28 65 76 65 6e 74 2e 6d 74 69  tetime(event.mti
10c0: 6d 65 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 2c  me,'localtime'),
10d0: 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 63 6f  ".    "       co
10e0: 6d 6d 65 6e 74 20 7c 7c 20 27 20 28 62 79 20 27  mment || ' (by '
10f0: 20 7c 7c 20 75 73 65 72 20 7c 7c 20 27 29 27 22   || user || ')'"
1100: 0a 20 20 20 20 22 20 20 46 52 4f 4d 20 65 76 65  .    "  FROM eve
1110: 6e 74 2c 20 62 6c 6f 62 22 0a 20 20 20 20 22 20  nt, blob".    " 
1120: 57 48 45 52 45 20 65 76 65 6e 74 2e 74 79 70 65  WHERE event.type
1130: 3d 27 63 69 27 20 41 4e 44 20 62 6c 6f 62 2e 72  ='ci' AND blob.r
1140: 69 64 3d 65 76 65 6e 74 2e 6f 62 6a 69 64 22 0a  id=event.objid".
1150: 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20 65      " ORDER BY e
1160: 76 65 6e 74 2e 6d 74 69 6d 65 20 44 45 53 43 22  vent.mtime DESC"
1170: 0a 20 20 29 3b 0a 20 20 70 72 69 6e 74 5f 74 69  .  );.  print_ti
1180: 6d 65 6c 69 6e 65 28 26 71 2c 20 32 30 29 3b 0a  meline(&q, 20);.
1190: 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71    db_finalize(&q
11a0: 29 3b 0a 7d 0a                                   );.}.