Diff
Not logged in

Differences From:

File src/tagview.c part of check-in [02a7c850b4] - Refactored to use a shared query-rendering routine. by stephan on 2008-02-03 16:32:28. [view]

To:

File src/tagview.c part of check-in [b81e93f576] - Corrected incorrect access rights check (did require Setup rights). Documentation corrections/additions. A few style conformance formatting changes. by stephan on 2008-02-03 17:22:58. [view]

@@ -29,19 +29,17 @@
 #include "config.h"
 #include "tagview.h"
 
 /**
-tagview_strxform_f is a typedef for funcs with
-the following policy:
-
-The accept a string which they then transform into
-some other form. They return a transformed copy,
-which the caller is responsible for freeing.
-
-The intention of this is to provide a way for
-a generic query routine to format specific column
-data (e.g. transform an object ID into a link to
-that object).
+tagview_strxform_f is a typedef for funcs with the following policy:
+
+They accept a const string which they then transform into some other
+form. They return a transformed copy, which the caller is responsible
+for freeing.
+
+The intention of this is to provide a way for a generic query routine
+to format specific column data (e.g. transform an object ID into a
+link to that object).
 */
 typedef char * (*tagview_strxform_f)( char const * );
 
 #if 0
@@ -58,28 +56,28 @@
 
 /** Returns a hyperlink to uuid. */
 static char * tagview_xf_link_to_uuid( char const * uuid )
 {
-    const int offset = 10;
-    char shortname[offset+1];
-    shortname[offset] = '\0';
-    memcpy( shortname, uuid, offset );
-    return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
-      g.zBaseURL, uuid, shortname, uuid+offset );
+  const int offset = 10;
+  char shortname[offset+1];
+  shortname[offset] = '\0';
+  memcpy( shortname, uuid, offset );
+  return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
+                  g.zBaseURL, uuid, shortname, uuid+offset );
 }
 
 /** Returns a hyperlink to the given tag. */
 static char * tagview_xf_link_to_tagid( char const * tagid )
 {
   return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>",
-        g.zBaseURL, tagid, tagid );
+                  g.zBaseURL, tagid, tagid );
 }
 
 /** Returns a hyperlink to the named tag. */
 static char * tagview_xf_link_to_tagname( char const * tagid )
 {
   return mprintf( "<a href='%s/tagview/%s'>%s</a>",
-        g.zBaseURL, tagid, tagid );
+                  g.zBaseURL, tagid, tagid );
 }
 
 
 
@@ -91,9 +89,9 @@
 *
 * The sql parameter should be a single, complete SQL statement.
 *
 * The coln parameter is optional (it may be 0). If it is 0 then the
-* column names using in the output will be taken directly from the
+* column names used in the output will be taken directly from the
 * SQL. If it is not null then it must have as many entries as the SQL
 * result has columns. Each entry is a column name for the SQL result
 * column of the same index. Any given entry may be 0, in which case
 * the column name from the SQL is used.
@@ -101,9 +99,9 @@
 * The xform argument is an array of transformation functions (type
 * tagview_strxform_f). The array, or any single entry, may be 0, but
 * if the array is non-0 then it must have at least as many entries as
 * colnames does. Each index corresponds directly to an entry in
-* colnames and the SQL results.  Any given entry may be 0 If it has
+* colnames and the SQL results.  Any given entry may be 0. If it has
 * fewer, undefined behaviour results.  If a column has an entry in
 * xform, then the xform function will be called to transform the
 * column data before rendering it. This function takes care of freeing
 * the strings created by the xform functions.
@@ -155,9 +153,8 @@
     }
   }
   @ </tr>
 
-
   while( SQLITE_ROW == db_step(&st) ){
     @ <tr>
       for( i = 0; i < colc; ++i ) {
         char * xf = 0;
@@ -190,15 +187,16 @@
   }
   else
   {
     limitstr = mprintf( "LIMIT %d", limit );
-    @ <h2>%d(limit) most recent tags:</h2>
+    @ <h2>%d(limit) most recent non-wiki tags:</h2>
   }
   char * sql = mprintf(
     "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid "
     "FROM tag t, tagxref tx, blob b "
     "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) "
     "AND (tx.tagtype != 0) %s "
+    "AND t.tagname NOT GLOB 'wiki-*' "
     "ORDER BY tx.mtime DESC %s",
     likeclause ? likeclause : " ",
     limitstr ? limitstr : " "
     );
@@ -230,9 +228,11 @@
   @ </form>
   @ </div>
 }
 
-
+/**
+ tagview_page_default() renders the default page for tagview_page().
+*/
 static void tagview_page_default(void){
   tagview_page_list_tags( 0 );
 }
 
@@ -245,18 +245,19 @@
   char * sql = mprintf(
     "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid "
     "FROM tag t, tagxref tx, blob b "
     "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
+    "AND t.tagname NOT GLOB 'wiki-*' "
     "ORDER BY tx.mtime DESC",
   tagid);
   char const * const colnames[] = {
       "Tag Name", "Timestamp", "Version"
-    };
+  };
   tagview_strxform_f xf[] = {
       tagview_xf_link_to_tagname,
       0,
       tagview_xf_link_to_uuid
-    };
+  };
   tagview_run_query( sql, colnames, xf );
   free(sql);
 }
 
@@ -269,8 +270,9 @@
   char * sql = mprintf(
     "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid "
     "FROM tag t, tagxref tx, blob b "
     "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
+    "AND t.tagname NOT GLOB 'wiki-*' "
     "ORDER BY tx.mtime DESC",
     tagname);
   char const * const colnames[] = {
       "Tag ID", "Timestamp", "Version"
@@ -290,9 +292,9 @@
 */
 void tagview_page(void){
 
   login_check_credentials();
-  if( !g.okSetup ){
+  if( !g.okRdWiki ){
     login_needed();
   }
   style_header("Tags");
   tagview_page_search_miniform();