Check-in [dfea940da8]
Not logged in
Overview

SHA1 Hash:dfea940da850d6844c2b13f2b4515e4463773230
Date: 2007-10-09 02:35:22
User: drh
Comment:Refinements to the timeline for giving better information about wiki pages.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/info.c from [15b63940c8] to [ee44c7829b].

@@ -375,10 +375,70 @@
   showAncestors(rid, 2, "Ancestors");
   style_footer();
 }
 
 /*
+** WEBPAGE: winfo
+**
+** Return information about a wiki page.  The version number is contained
+** in g.zExtra.
+*/
+void winfo_page(void){
+  Stmt q;
+  int rid;
+
+  login_check_credentials();
+  if( !g.okHistory ){ login_needed(); return; }
+  rid = name_to_rid(g.zExtra);
+  if( rid==0 ){
+    style_header("Wiki Page Information Error");
+    @ No such object: %h(g.argv[2])
+    style_footer();
+    return;
+  }
+  db_prepare(&q,
+     "SELECT substr(tagname, 6, 1000), uuid,"
+     "       datetime(event.mtime, 'localtime'), user"
+     "  FROM tagxref, tag, blob, event"
+     " WHERE tagxref.rid=%d"
+     "   AND tag.tagid=tagxref.tagid"
+     "   AND tag.tagname LIKE 'wiki-%%'"
+     "   AND blob.rid=%d"
+     "   AND event.objid=%d",
+     rid, rid, rid
+  );
+  if( db_step(&q)==SQLITE_ROW ){
+    const char *zName = db_column_text(&q, 0);
+    const char *zUuid = db_column_text(&q, 1);
+    char *zTitle = mprintf("Wiki Page %s", zName);
+    style_header(zTitle);
+    free(zTitle);
+    @ <div class="section-title">Overview</div>
+    @ <p><table class="label-value">
+    @ <tr><th>Version:</th><td>%s(zUuid)</td></tr>
+    @ <tr><th>Date:</th><td>%s(db_column_text(&q, 2))</td></tr>
+    if( g.okSetup ){
+      @ <tr><th>Record ID:</th><td>%d(rid)</td></tr>
+    }
+    @ <tr><th>Original&nbsp;User:</th><td>%s(db_column_text(&q, 3))</td></tr>
+    @ <tr><th>Commands:</th>
+    @   <td>
+/*    @     <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
+    @     <a href="%s(g.zBaseURL)/wlist/%t(zName)">history</a>
+    @     | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
+    @   </td>
+    @ </tr>
+    @ </table></p>
+  }else{
+    style_header("Wiki Information");
+  }
+  db_finalize(&q);
+  showTags(rid);
+  style_footer();
+}
+
+/*
 ** WEBPAGE: finfo
 **
 ** Show the complete change history for a single file.  The name
 ** of the file is in g.zExtra
 */
@@ -515,10 +575,11 @@
 **     * Comment & user
 */
 static void object_description(int rid, int linkToView){
   Stmt q;
   int cnt = 0;
+  int nWiki = 0;
   db_prepare(&q,
     "SELECT filename.name, datetime(event.mtime), substr(a.uuid,1,10),"
     "       coalesce(event.comment,event.ecomment),"
     "       coalesce(event.euser,event.user),"
     "       b.uuid"
@@ -543,27 +604,51 @@
     @ %s(zCom) by %s(zUser) on %s(zDate).
     cnt++;
   }
   db_finalize(&q);
   db_prepare(&q,
-    "SELECT datetime(mtime), user, comment, uuid"
-    "  FROM event, blob"
-    " WHERE event.objid=%d"
-    "   AND blob.rid=%d",
-    rid, rid
+    "SELECT substr(tagname, 6, 10000), datetime(event.mtime),"
+    "       coalesce(event.euser, event.user), uuid"
+    "  FROM tagxref, tag, event, blob"
+    " WHERE tagxref.rid=%d"
+    "   AND tag.tagid=tagxref.tagid"
+    "   AND tag.tagname LIKE 'wiki-%%'"
+    "   AND event.objid=tagxref.rid"
+    "   AND blob.rid=tagxref.rid",
+    rid
   );
   while( db_step(&q)==SQLITE_ROW ){
-    const char *zDate = db_column_text(&q, 0);
+    const char *zPagename = db_column_text(&q, 0);
+    const char *zDate = db_column_text(&q, 1);
+    const char *zUser = db_column_text(&q, 2);
     const char *zUuid = db_column_text(&q, 3);
-    const char *zCom = db_column_text(&q, 2);
-    const char *zUser = db_column_text(&q, 1);
-    @ Manifest of version
-    hyperlink_to_uuid(zUuid);
-    @ %s(zCom) by %s(zUser) on %s(zDate).
+    @ Wiki page [<a href="%s(g.zBaseURL)/wiki/%t(zPagename)">%h(zPagename)</a>]
+    @ uuid %s(zUuid) by %h(zUser) on %s(zDate)
+    nWiki++;
     cnt++;
   }
   db_finalize(&q);
+  if( nWiki==0 ){
+    db_prepare(&q,
+      "SELECT datetime(mtime), user, comment, uuid"
+      "  FROM event, blob"
+      " WHERE event.objid=%d"
+      "   AND blob.rid=%d",
+      rid, rid
+    );
+    while( db_step(&q)==SQLITE_ROW ){
+      const char *zDate = db_column_text(&q, 0);
+      const char *zUuid = db_column_text(&q, 3);
+      const char *zCom = db_column_text(&q, 2);
+      const char *zUser = db_column_text(&q, 1);
+      @ Manifest of version
+      hyperlink_to_uuid(zUuid);
+      @ %s(zCom) by %s(zUser) on %s(zDate).
+      cnt++;
+    }
+    db_finalize(&q);
+  }
   if( cnt==0 ){
     char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
     @ Control file %s(zUuid).
   }else if( linkToView ){
     @ <a href="%s(g.zBaseURL)/fview/%d(rid)">[view]</a>
@@ -619,14 +704,20 @@
   Blob content;
 
   rid = name_to_rid(g.zExtra);
   login_check_credentials();
   if( !g.okHistory ){ login_needed(); return; }
-  if( g.zPath[0]=='i' &&
-      db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){
-    vinfo_page();
-    return;
+  if( g.zPath[0]=='i' ){
+    if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
+                  " WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){
+      winfo_page();
+      return;
+    }
+    if( db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){
+      vinfo_page();
+      return;
+    }
   }
   style_header("File Content");
   @ <h2>Content Of:</h2>
   @ <blockquote>
   object_description(rid, 0);

Modified src/timeline.c from [bffeb82d75] to [dc6941a79a].

@@ -86,10 +86,11 @@
 **    4.  User
 **    5.  Number of non-merge children
 **    6.  Number of parents
 **    7.  True if is a leaf
 **    8.  background color
+**    9.  type ("ci", "w")
 */
 void www_print_timeline(
   Stmt *pQuery,
   int *pFirstEvent,
   int *pLastEvent,
@@ -113,10 +114,12 @@
     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);
     if( cnt==0 && pFirstEvent ){
       *pFirstEvent = rid;
     }
     if( pLastEvent ){
       *pLastEvent = rid;
@@ -143,24 +146,28 @@
     if( zBgClr && zBgClr[0] ){
       @ <td valign="top" align="left" bgcolor="%h(zBgClr)">
     }else{
       @ <td valign="top" align="left">
     }
-    hyperlink_to_uuid_with_mouseover(zUuid, "xin", "xout", rid);
-    if( nParent>1 ){
-      @ <b>Merge</b>
-    }
-    if( nPChild>1 ){
-      @ <b>Fork</b>
-    }
-    if( isLeaf ){
-      @ <b>Leaf</b>
+    if( zType[0]=='c' ){
+      hyperlink_to_uuid_with_mouseover(zUuid, "xin", "xout", rid);
+      if( nParent>1 ){
+        @ <b>Merge</b>
+      }
+      if( nPChild>1 ){
+        @ <b>Fork</b>
+      }
+      if( isLeaf ){
+        @ <b>Leaf</b>
+      }
+    }else{
+      hyperlink_to_uuid(zUuid);
     }
     db_column_blob(pQuery, 3, &comment);
     wiki_convert(&comment, 0);
     blob_reset(&comment);
-    @ (by %h(db_column_text(pQuery,4)))</td></tr>
+    @ (by %h(zUser))</td></tr>
   }
   @ </table>
 }
 
 /*
@@ -207,11 +214,12 @@
     @   coalesce(ecomment, comment),
     @   coalesce(euser, user),
     @   (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim=1),
     @   (SELECT count(*) FROM plink WHERE cid=blob.rid),
     @   NOT EXISTS (SELECT 1 FROM plink WHERE pid=blob.rid),
-    @   coalesce(bgcolor, brbgcolor)
+    @   coalesce(bgcolor, brbgcolor),
+    @   event.type
     @  FROM event JOIN blob
     @ WHERE blob.rid=event.objid
   ;
   return zBaseSql;
 }
@@ -381,10 +389,38 @@
   @ <input type="submit" value="Previous %d(nEntry) Rows">
   @ </form>
   style_footer();
 }
 
+
+/*
+** WEBPAGE: wlist
+**
+** Show the complete change history for a single wiki page.  The name
+** of the wiki is in g.zExtra
+*/
+void wlist_page(void){
+  Stmt q;
+  char *zTitle;
+  char *zSQL;
+  login_check_credentials();
+  if( !g.okHistory ){ login_needed(); return; }
+  zTitle = mprintf("History Of %h", g.zExtra);
+  style_header(zTitle);
+  free(zTitle);
+
+  zSQL = mprintf("%s AND event.objid IN "
+                 "  (SELECT rid FROM tagxref WHERE tagid="
+                       "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))",
+                 timeline_query_for_www(), g.zExtra);
+  db_prepare(&q, zSQL);
+  free(zSQL);
+  www_print_timeline(&q, 0, 0, 0, 0);
+  db_finalize(&q);
+  style_footer();
+}
+
 /*
 ** The input query q selects various records.  Print a human-readable
 ** summary of those records.
 **
 ** Limit the number of entries printed to nLine.
@@ -469,11 +505,10 @@
     @ FROM event, blob
     @ WHERE blob.rid=event.objid
   ;
   return zBaseSql;
 }
-
 
 /*
 ** COMMAND: timeline
 **
 ** Usage: %fossil timeline ?WHEN? ?UUID|DATETIME? ?-n|--count N?