File Annotation
Not logged in
02d1ed6ad2 2008-02-02   stephan: /*
02d1ed6ad2 2008-02-02   stephan: ** Copyright (c) 2007 D. Richard Hipp
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: ** This program is free software; you can redistribute it and/or
02d1ed6ad2 2008-02-02   stephan: ** modify it under the terms of the GNU General Public
02d1ed6ad2 2008-02-02   stephan: ** License as published by the Free Software Foundation; either
02d1ed6ad2 2008-02-02   stephan: ** version 2 of the License, or (at your option) any later version.
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: ** This program is distributed in the hope that it will be useful,
02d1ed6ad2 2008-02-02   stephan: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
02d1ed6ad2 2008-02-02   stephan: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
02d1ed6ad2 2008-02-02   stephan: ** General Public License for more details.
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: ** You should have received a copy of the GNU General Public
02d1ed6ad2 2008-02-02   stephan: ** License along with this library; if not, write to the
02d1ed6ad2 2008-02-02   stephan: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
02d1ed6ad2 2008-02-02   stephan: ** Boston, MA  02111-1307, USA.
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: ** Author contact information:
02d1ed6ad2 2008-02-02   stephan: **   drh@hwaci.com
02d1ed6ad2 2008-02-02   stephan: **   http://www.hwaci.com/drh/
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: *******************************************************************************
02d1ed6ad2 2008-02-02   stephan: **
02d1ed6ad2 2008-02-02   stephan: ** Implementation of the Tag View page
02d1ed6ad2 2008-02-02   stephan: */
02d1ed6ad2 2008-02-02   stephan: #include <assert.h>
02d1ed6ad2 2008-02-02   stephan: #include "config.h"
02d1ed6ad2 2008-02-02   stephan: #include "tagview.h"
02d1ed6ad2 2008-02-02   stephan: 
02d1ed6ad2 2008-02-02   stephan: 
02d1ed6ad2 2008-02-02   stephan: /*
02d1ed6ad2 2008-02-02   stephan: ** Output a single entry for a menu generated using an HTML table.
02d1ed6ad2 2008-02-02   stephan: ** If zLink is not NULL or an empty string, then it is the page that
02d1ed6ad2 2008-02-02   stephan: ** the menu entry will hyperlink to.  If zLink is NULL or "", then
02d1ed6ad2 2008-02-02   stephan: ** the menu entry has no hyperlink - it is disabled.
02d1ed6ad2 2008-02-02   stephan: */
02d1ed6ad2 2008-02-02   stephan: void tagview_menu_entry(
02d1ed6ad2 2008-02-02   stephan:   const char *zTitle,
02d1ed6ad2 2008-02-02   stephan:   const char *zLink,
02d1ed6ad2 2008-02-02   stephan:   const char *zDesc
02d1ed6ad2 2008-02-02   stephan: ){
02d1ed6ad2 2008-02-02   stephan:   @ <tr><td valign="top" align="right">
02d1ed6ad2 2008-02-02   stephan:   if( zLink && zLink[0] ){
02d1ed6ad2 2008-02-02   stephan:     @ <a href="%s(zLink)">%h(zTitle)</a>
02d1ed6ad2 2008-02-02   stephan:   }else{
02d1ed6ad2 2008-02-02   stephan:     @ %h(zTitle)
02d1ed6ad2 2008-02-02   stephan:   }
02d1ed6ad2 2008-02-02   stephan:   @ </td><td valign="top">%h(zDesc)</td></tr>
02d1ed6ad2 2008-02-02   stephan: }
02d1ed6ad2 2008-02-02   stephan: 
02d1ed6ad2 2008-02-02   stephan: /*
02d1ed6ad2 2008-02-02   stephan: ** WEBPAGE: /tagview
02d1ed6ad2 2008-02-02   stephan: */
02d1ed6ad2 2008-02-02   stephan: void tagview_page(void){
02d1ed6ad2 2008-02-02   stephan:   Stmt st;
02d1ed6ad2 2008-02-02   stephan: 
02d1ed6ad2 2008-02-02   stephan:   login_check_credentials();
02d1ed6ad2 2008-02-02   stephan:   if( !g.okSetup ){
02d1ed6ad2 2008-02-02   stephan:     login_needed();
02d1ed6ad2 2008-02-02   stephan:   }
02d1ed6ad2 2008-02-02   stephan:   style_header("Tags List");
02d1ed6ad2 2008-02-02   stephan:   @ <table cellpadding='4px' border='1'><tbody>
02d1ed6ad2 2008-02-02   stephan:   @ <tr><th>Tag name</th><th>Timestamp</th><th>Version</th></tr>
02d1ed6ad2 2008-02-02   stephan:   db_prepare( &st,
02d1ed6ad2 2008-02-02   stephan: 	      "select t.tagname, DATETIME(tx.mtime), b.uuid "
02d1ed6ad2 2008-02-02   stephan: 	      "FROM tag t, tagxref tx, blob b "
02d1ed6ad2 2008-02-02   stephan: 	      "WHERE t.tagid=tx.tagid and tx.rid=b.rid "
02d1ed6ad2 2008-02-02   stephan: 	      "AND tx.tagtype != 0 "
02d1ed6ad2 2008-02-02   stephan: 	      "ORDER BY tx.mtime DESC"
02d1ed6ad2 2008-02-02   stephan: 	      );
02d1ed6ad2 2008-02-02   stephan:   while( SQLITE_ROW == db_step(&st) )
02d1ed6ad2 2008-02-02   stephan:   {
02d1ed6ad2 2008-02-02   stephan: 	  char const * tagname = db_column_text( &st, 0 );
02d1ed6ad2 2008-02-02   stephan: 	  char const * tagtime = db_column_text( &st, 1 );
02d1ed6ad2 2008-02-02   stephan: 	  char const * uuid = db_column_text( &st, 2 );
02d1ed6ad2 2008-02-02   stephan: 	  const int offset = 10;
02d1ed6ad2 2008-02-02   stephan: 	  char shortname[offset+1];
02d1ed6ad2 2008-02-02   stephan: 	shortname[offset] = '\0';
02d1ed6ad2 2008-02-02   stephan: 	memcpy( shortname, uuid, offset );
02d1ed6ad2 2008-02-02   stephan: 	  @ <tr>
02d1ed6ad2 2008-02-02   stephan: 	  @ <td><tt>%s(tagname)</tt></td>
02d1ed6ad2 2008-02-02   stephan: 	  @ <td align='center'><tt>%s(tagtime)</tt></td>
02d1ed6ad2 2008-02-02   stephan: 	  @ <td><tt>
02d1ed6ad2 2008-02-02   stephan:           @ <a href='/vinfo/%s(uuid)'><strong>%s(shortname)</strong>%s(uuid+offset)</a></tt>
02d1ed6ad2 2008-02-02   stephan: 	  @ </td></tr>
02d1ed6ad2 2008-02-02   stephan:   }
02d1ed6ad2 2008-02-02   stephan:   db_finalize( &st );
02d1ed6ad2 2008-02-02   stephan:   @ </tbody></table>
02d1ed6ad2 2008-02-02   stephan:   @ <hr/>TODOs include:
02d1ed6ad2 2008-02-02   stephan:   @ <ul>
02d1ed6ad2 2008-02-02   stephan:   @  <li>Page through long tags lists.</li>
02d1ed6ad2 2008-02-02   stephan:   @  <li>Format the timestamp field.</li>
02d1ed6ad2 2008-02-02   stephan:   @  <li>Allow different sorting.</li>
02d1ed6ad2 2008-02-02   stephan:   @  <li>?</li>
02d1ed6ad2 2008-02-02   stephan:   @ </ul>
02d1ed6ad2 2008-02-02   stephan:   style_footer();
02d1ed6ad2 2008-02-02   stephan: }
02d1ed6ad2 2008-02-02   stephan: