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,
10437374a7 2008-02-02       drh:      "SELECT t.tagname, DATETIME(tx.mtime), b.uuid "
10437374a7 2008-02-02       drh:      "  FROM tag t, tagxref tx, blob b"
10437374a7 2008-02-02       drh:      " WHERE t.tagid=tx.tagid and tx.rid=b.rid"
10437374a7 2008-02-02       drh:      "   AND tx.tagtype != 0"
10437374a7 2008-02-02       drh:      /* "   AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */
10437374a7 2008-02-02       drh:      " ORDER BY tx.mtime DESC"
10437374a7 2008-02-02       drh:   );
10437374a7 2008-02-02       drh:   while( SQLITE_ROW == db_step(&st) ){
10437374a7 2008-02-02       drh:     char const * tagname = db_column_text( &st, 0 );
10437374a7 2008-02-02       drh:     char const * tagtime = db_column_text( &st, 1 );
10437374a7 2008-02-02       drh:     char const * uuid = db_column_text( &st, 2 );
10437374a7 2008-02-02       drh:     const int offset = 10;
10437374a7 2008-02-02       drh:     char shortname[offset+1];
10437374a7 2008-02-02       drh:     shortname[offset] = '\0';
10437374a7 2008-02-02       drh:     memcpy( shortname, uuid, offset );
10437374a7 2008-02-02       drh:     @ <tr>
10437374a7 2008-02-02       drh:     @ <td><tt>%s(tagname)</tt></td>
10437374a7 2008-02-02       drh:     @ <td align='center'><tt>%s(tagtime)</tt></td>
10437374a7 2008-02-02       drh:     @ <td><tt>
10437374a7 2008-02-02       drh:     @ <a href='/vinfo/%s(uuid)'>
10437374a7 2008-02-02       drh:     @ <strong>%s(shortname)</strong>%s(uuid+offset)</a></tt>
10437374a7 2008-02-02       drh:     @ </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: }