File Annotation
Not logged in
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Copyright (c) 2006 D. Richard Hipp
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is free software; you can redistribute it and/or
dbda8d6ce9 2007-07-21       drh: ** modify it under the terms of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License version 2 as published by the Free Software Foundation.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is distributed in the hope that it will be useful,
dbda8d6ce9 2007-07-21       drh: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
dbda8d6ce9 2007-07-21       drh: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dbda8d6ce9 2007-07-21       drh: ** General Public License for more details.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** You should have received a copy of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License along with this library; if not, write to the
dbda8d6ce9 2007-07-21       drh: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dbda8d6ce9 2007-07-21       drh: ** Boston, MA  02111-1307, USA.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Author contact information:
dbda8d6ce9 2007-07-21       drh: **   drh@hwaci.com
dbda8d6ce9 2007-07-21       drh: **   http://www.hwaci.com/drh/
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: *******************************************************************************
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This file contains code to implement the basic web page look and feel.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: #include "config.h"
dbda8d6ce9 2007-07-21       drh: #include "style.h"
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Elements of the submenu are collected into the following
dbda8d6ce9 2007-07-21       drh: ** structure and displayed below the main menu by style_header().
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Populate this structure with calls to style_submenu_element()
dbda8d6ce9 2007-07-21       drh: ** prior to calling style_header().
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static struct Submenu {
dbda8d6ce9 2007-07-21       drh:   const char *zLabel;
dbda8d6ce9 2007-07-21       drh:   const char *zTitle;
dbda8d6ce9 2007-07-21       drh:   const char *zLink;
dbda8d6ce9 2007-07-21       drh: } aSubmenu[30];
dbda8d6ce9 2007-07-21       drh: static int nSubmenu = 0;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Add a new element to the submenu
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void style_submenu_element(
dbda8d6ce9 2007-07-21       drh:   const char *zLabel,
dbda8d6ce9 2007-07-21       drh:   const char *zTitle,
dbda8d6ce9 2007-07-21       drh:   const char *zLink
dbda8d6ce9 2007-07-21       drh: ){
dbda8d6ce9 2007-07-21       drh:   assert( nSubmenu < sizeof(aSubmenu)/sizeof(aSubmenu[0]) );
dbda8d6ce9 2007-07-21       drh:   aSubmenu[nSubmenu].zLabel = zLabel;
dbda8d6ce9 2007-07-21       drh:   aSubmenu[nSubmenu].zTitle = zTitle;
dbda8d6ce9 2007-07-21       drh:   aSubmenu[nSubmenu].zLink = zLink;
dbda8d6ce9 2007-07-21       drh:   nSubmenu++;
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Compare two submenu items for sorting purposes
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static int submenuCompare(const void *a, const void *b){
dbda8d6ce9 2007-07-21       drh:   const struct Submenu *A = (const struct Submenu*)a;
dbda8d6ce9 2007-07-21       drh:   const struct Submenu *B = (const struct Submenu*)B;
dbda8d6ce9 2007-07-21       drh:   return strcmp(A->zLabel, B->zLabel);
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Draw the header.
dbda8d6ce9 2007-07-21       drh: */
66f4caa379 2007-07-23       drh: void style_header(const char *zTitle){
dbda8d6ce9 2007-07-21       drh:   const char *zLogInOut = "Logout";
916b6e4b3b 2007-07-21       drh:   login_check_credentials();
dbda8d6ce9 2007-07-21       drh:   @ <html>
dbda8d6ce9 2007-07-21       drh:   @ <body bgcolor="white">
dbda8d6ce9 2007-07-21       drh:   @ <hr size="1">
dbda8d6ce9 2007-07-21       drh:   @ <table border="0" cellpadding="0" cellspacing="0" width="100%%">
dbda8d6ce9 2007-07-21       drh:   @ <tr><td valign="top" align="left">
66f4caa379 2007-07-23       drh:   @ <big><big><b>%s(zTitle)</b></big></big><br>
9c952d247e 2007-07-31       drh:   if( g.zLogin==0 ){
dbda8d6ce9 2007-07-21       drh:     @ <small>not logged in</small>
dbda8d6ce9 2007-07-21       drh:     zLogInOut = "Login";
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     @ <small>logged in as %h(g.zLogin)</small>
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   @ </td><td valign="top" align="right">
dbda8d6ce9 2007-07-21       drh:   @ <a href="%s(g.zBaseURL)/index">Home</a>
dbda8d6ce9 2007-07-21       drh:   @ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
66f4caa379 2007-07-23       drh:   if( g.okRdWiki ){
66f4caa379 2007-07-23       drh:     @ | <a href="%s(g.zBaseURL)/wiki">Wiki</a>
66f4caa379 2007-07-23       drh:   }
66f4caa379 2007-07-23       drh: #if 0
dbda8d6ce9 2007-07-21       drh:   @ | <font color="#888888">Search</font>
dbda8d6ce9 2007-07-21       drh:   @ | <font color="#888888">Ticket</font>
dbda8d6ce9 2007-07-21       drh:   @ | <font color="#888888">Reports</font>
66f4caa379 2007-07-23       drh: #endif
dbda8d6ce9 2007-07-21       drh:   if( g.okSetup ){
dbda8d6ce9 2007-07-21       drh:     @ | <a href="%s(g.zBaseURL)/setup">Setup</a>
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( !g.noPswd ){
dbda8d6ce9 2007-07-21       drh:     @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a>
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( nSubmenu>0 ){
dbda8d6ce9 2007-07-21       drh:     int i;
dbda8d6ce9 2007-07-21       drh:     @ <br>
dbda8d6ce9 2007-07-21       drh:     qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
dbda8d6ce9 2007-07-21       drh:     for(i=0; i<nSubmenu; i++){
dbda8d6ce9 2007-07-21       drh:       struct Submenu *p = &aSubmenu[i];
dbda8d6ce9 2007-07-21       drh:       char *zTail = i<nSubmenu-1 ? " | " : "";
dbda8d6ce9 2007-07-21       drh:       if( p->zLink==0 ){
dbda8d6ce9 2007-07-21       drh:         @ <font color="#888888">%h(p->zLabel)</font> %s(zTail)
dbda8d6ce9 2007-07-21       drh:       }else{
916b6e4b3b 2007-07-21       drh:         @ <a href="%T(p->zLink)">%h(p->zLabel)</a> %s(zTail)
dbda8d6ce9 2007-07-21       drh:       }
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   @ </td></tr></table>
dbda8d6ce9 2007-07-21       drh:   @ <hr size="1">
dbda8d6ce9 2007-07-21       drh:   g.cgiPanic = 1;
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Draw the footer at the bottom of the page.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void style_footer(void){
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: index
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: home
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: not_found
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void page_index(void){
66f4caa379 2007-07-23       drh:   style_header("Main Title Page");
dbda8d6ce9 2007-07-21       drh:   @ This will become the title page
dbda8d6ce9 2007-07-21       drh:   style_footer();
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** WEBPAGE: test_env
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void page_test_env(void){
66f4caa379 2007-07-23       drh:   style_header("Environment Test");
dbda8d6ce9 2007-07-21       drh:   cgi_print_all();
dbda8d6ce9 2007-07-21       drh:   style_footer();
dbda8d6ce9 2007-07-21       drh: }