Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [e6aa161204] - Work on a new timeline implementation. Currently implemented as "ntimeline" since it is not yet ready to replace the existing timeline. by drh on 2008-02-26 16:48:21. [view]

To:

File src/timeline.c part of check-in [7915bd0665] - Improvements to the text description on the "ntimeline" page. by drh on 2008-02-26 17:32:52. [view]

@@ -345,11 +345,17 @@
     blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>",
                  g.zBaseURL, zUuid, zUuid);
     db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC");
   }else{
+    int n;
+    Blob url;
     const char *zEType = "event";
+    const char *zDate;
+    blob_zero(&url);
+    blob_appendf(&url, "%s/ntimeline?n=%d", g.zBaseURL, nEntry);
     if( zType ){
       blob_appendf(&sql, " AND event.type=%Q", zType);
+      blob_appendf(&url, "&y=%T", zType);
       if( zType[0]=='c' ){
         zEType = "checkin";
       }else if( zType[0]=='w' ){
         zEType = "wiki edit";
@@ -356,35 +362,59 @@
       }else if( zType[0]=='t' ){
         zEType = "ticket change";
       }
     }
-    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);
+      blob_appendf(&url, "&u=%T", zUser);
     }
     if( zAfter ){
       while( isspace(zAfter[0]) ){ zAfter++; }
       if( zAfter[0] ){
         blob_appendf(&sql,
            " AND event.mtime>=(SELECT julianday(%Q, 'utc'))"
            " ORDER BY event.mtime ASC", zAfter);
-        blob_appendf(&desc, " occurring on or after %h", zAfter);
         zBefore = 0;
+      }else{
+        zAfter = 0;
       }
     }else if( zBefore ){
       while( isspace(zBefore[0]) ){ zBefore++; }
       if( zBefore[0] ){
         blob_appendf(&sql,
            " AND event.mtime<=(SELECT julianday(%Q, 'utc'))"
            " ORDER BY event.mtime DESC", zBefore);
-        blob_appendf(&desc, " occurring on or before %h", zBefore);
+       }else{
+        zBefore = 0;
       }
     }else{
       blob_appendf(&sql, " ORDER BY event.mtime DESC");
     }
     blob_appendf(&sql, " LIMIT %d", nEntry);
     db_multi_exec("%s", blob_str(&sql));
+
+    n = db_int(0, "SELECT count(*) FROM timeline");
+    if( zAfter==0 && zBefore==0 ){
+      blob_appendf(&desc, "%d most recent %ss", n, zEType);
+    }else{
+      blob_appendf(&desc, "%d %ss", n, zEType);
+    }
+    if( zUser ){
+      blob_appendf(&desc, " by user %h", zUser);
+    }
+    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);
+    }
+    if( zAfter || n==nEntry ){
+      zDate = db_text(0, "SELECT min(timestamp) FROM timeline");
+      blob_appendf(&desc, " <a href='%b&b=%s'>[older]</a>", &url, zDate);
+    }
+    if( zBefore || (zAfter && n==nEntry) ){
+      zDate = db_text(0, "SELECT max(timestamp) FROM timeline");
+      blob_appendf(&desc, " <a href='%b&a=%s'>[more recent]</a>", &url, zDate);
+    }
   }
   blob_zero(&sql);
   db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC");
   @ <h2>%b(&desc)</h2>