Website layout

Justin C. Sherrill justin at shiningsilence.com
Thu Oct 16 13:20:08 PDT 2003


I recall Matt saying he wanted to get away from the 2-menu layout, and 
also that Hiten was working on a new site at 
http://hmp.serverninjas.com/df-www/index.html - so here is a changed 
tablecg.c.  

I expect Hiten's XML/XSLT changes will override this, when he's ready, but 
this could work as a transition.  

http://hmp.serverninjas.com/df-www/stylesheet.css needs to be placed in 
/site/data too.

For a working example, look at http://home.shiningsilence.com:81/

--- tablecg-old.c       Mon Oct 13 22:09:03 2003
+++ tablecg.c   Thu Oct 16 16:15:03 2003
@@ -107,6 +107,7 @@
     printf("<HTML>\n");
     printf("<HEAD>\n");
     printf("<TITLE></TITLE>\n");
+    printf("<LINK REL=\"stylesheet\" HREF=\"/stylesheet.css\" TYPE=\"text/css\">");
     printf("</HEAD>\n");
     printf("<BODY>\n");
     /*
@@ -146,23 +147,23 @@
        }
        fclose(fi);
     }
-    printf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#b0b0e0\">\n");
-    printf("<TR><TD><IMG SRC=\"/smalldf.jpg\"></TD>");
-    printf("<TD WIDTH=100%%>");
-       printf("<TABLE BORDER=0 WIDTH=100%%>");
-       printf("<TR><TD ALIGN=center WIDTH=100%%>");
+    printf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#FFFFFF\">\n");
+    printf("<TR><TD ALIGN=CENTER COLSPAN=2>");
+
+    printf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#FFFFFF\">\n");
+    printf("<TR><TD VALIGN=\"bottom\" ALIGN=\"right\">");
+
        if (Title) {
            printf("<H2>%s</H2>", Title);
        }
-       printf("</TD></TR>");
-       printf("<TR><TD ALIGN=left>");
-       generate_top_headers();
-       printf("</TD></TR>\n");
-       printf("</TABLE>");
-    printf("</TD></TR>");
-    printf("<TR><TD VALIGN=top>");
+    printf("</TD><TD ALIGN=\"right\"><IMG SRC=\"/smalldf.jpg\"></TD>");
+    printf("</TR><TR><TD COLSPAN=\"2\"><HR></TD>");
+    printf("</TR></TABLE>");
+
+    printf("</TD></TR>\n");
+    printf("<TR><TD VALIGN=top WIDTH=\"20%%\">");
     generate_side_headers();
-    printf("</TD><TD WIDTH=100%%  BGCOLOR=\"#c0c0ff\">");
+    printf("</TD><TD WIDTH=100%%  BGCOLOR=\"#ffffff\">");
     fflush(stdout);
     buildflush();
     printf("<PRE>\n");
@@ -179,20 +180,21 @@
 }
 
 /*
- * The headers along the top are synthesized from the directory level
- * just above the file.
+ * The menu is synthesized from the existing file structure.
  */
 static void
-generate_top_headers(void)
+generate_side_headers(void)
 {
     DIR *dir;
     struct dirent *den;
+    DIR *tdir;
+    struct dirent *tden;
 
-    printf("<TABLE BORDER=0 CELLPADDING=4>");
+    printf("<TABLE BORDER=\"0\" CELLPADDING=\"4\" WIDTH=\"100%%\">");
     if ((dir = opendir(ParentDir)) != NULL) {
        printf("<TR>");
        while ((den = readdir(dir)) != NULL) {
-           const char *bgcolor = "";
+           const char *sectionclass = "";
 
            if (den->d_name[0] == '.')
                continue;
@@ -202,52 +204,52 @@
                continue;
            if (den->d_type != DT_DIR)
                continue;
-           if (strcmp(den->d_name, DirName) == 0)
-               bgcolor = " BGCOLOR=\"lightgreen\"";
-           printf("<TD%s><H2><A HREF=\"../%s\">%s</A></H2></TD>", 
-               bgcolor, den->d_name, den->d_name);
-       }
-       printf("<TD WIDTH=100%%></TD>");
-       printf("</TR>");
-       closedir(dir);
-    }
-    printf("</TABLE>");
-}
+           printf("<TD%s><H2><A HREF=\"../%s\">%s</A></H2>",
+               sectionclass, den->d_name, den->d_name);
 
-static void
-generate_side_headers(void)
-{
-    DIR *dir;
-    struct dirent *den;
+           if (strcmp(den->d_name, DirName) == 0) {
+               printf("</TD></TR>\n<TR><TD><TABLE BORDER=\"0\" WIDTH=\"100%%\">");
+               if ((tdir = opendir(DirPath)) != NULL) {
+                       while ((tden = readdir(tdir)) != NULL) {
+                       int len;
+                       const char *ptr;
+                       const char *fileclass = "";
+
+                       if (tden->d_name[0] == '.')
+                               continue;
+                       if (tden->d_type != DT_REG)
+                               continue;
+                       if (strcmp(tden->d_name, FileName) == 0)
+                               fileclass = " CLASS=\"topLevelSelected\"";
+                       else
+                               fileclass = " CLASS=\"topLevel\"";
+
+                       if ((ptr = strchr(tden->d_name, '.')) != NULL &&
+                               (strcmp(ptr + 1, "cgi") == 0 ||
+                               strcmp(ptr + 1, "html") == 0)
+                       ) {
+                               len = ptr - tden->d_name;
+                               printf("<TR><TD%s><A HREF=\"%s\">%*.*s</A></TD></TR>\n",
+                               fileclass,
+                               tden->d_name,
+                               len, len, tden->d_name);
+                       }
+                       }
+                       closedir(tdir);
+               }
+               printf("</TABLE>\n</TD>");
+           } else {
+               printf("</TD>");
+           }
 
-    printf("<TABLE BORDER=\"0\">");
-    if ((dir = opendir(DirPath)) != NULL) {
-       while ((den = readdir(dir)) != NULL) {
-           int len;
-           const char *ptr;
-           const char *bgcolor = "";
+       printf("</TR>\n");
 
-           if (den->d_name[0] == '.')
-               continue;
-           if (den->d_type != DT_REG)
-               continue;
-           if (strcmp(den->d_name, FileName) == 0)
-               bgcolor = " BGCOLOR=\"lightgreen\"";
-
-           if ((ptr = strchr(den->d_name, '.')) != NULL &&
-               (strcmp(ptr + 1, "cgi") == 0 ||
-                strcmp(ptr + 1, "html") == 0)
-           ) {
-               len = ptr - den->d_name;
-               printf("<TR><TD%s><H2><A HREF=\"%s\">%*.*s</A></H2></TD></TR>\n",
-                   bgcolor,
-                   den->d_name,
-                   len, len, den->d_name);
-           }
        }
+       printf("<TD WIDTH=100%%></TD>");
+       printf("</TR>");
        closedir(dir);
     }
-    printf("</TABLE>\n");
+    printf("</TABLE>");
 }
 
 static void





More information about the Submit mailing list