From 409fd833e63bde6da22bcf3a7eb4f16bb15d0fb1 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 22 Jul 2011 21:48:01 +0000 Subject: [PATCH] Add sitemap, per-page descriptions, misc updates --- .gitignore | 1 + .htaccess | 2 +- html.ct | 54 +++++++++++++++++++++++++++++++++++++----------------- html.h | 6 ++++++ index.c | 47 ++++++++++++++++++++++++++++------------------- 5 files changed, 73 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index ea1a3a0..e419fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.cgi *.swp html.c +tags diff --git a/.htaccess b/.htaccess index e36ed8a..cf0a1e4 100644 --- a/.htaccess +++ b/.htaccess @@ -1,7 +1,7 @@ Options +ExecCGI AddHandler cgi-script .cgi RewriteEngine on -RewriteRule ^([a-z]*)$ 'index.cgi/$1' +RewriteRule ^([a-z.]*)$ 'index.cgi/$1' # ** Andy stabs apache ** RewriteCond %{REQUEST_URI} ^(.*)/[^/]*$ diff --git a/html.ct b/html.ct index 9494b5d..9cc8b76 100644 --- a/html.ct +++ b/html.ct @@ -18,20 +18,23 @@ Content-Type: text/html; charset=UTF-8 <% } %> <% void print_page(const page_t *page) { %> - - - - - AWeather<% if (page->name) printf(" - %s", page->name); %> + + + + + AWeather<% if (page->name) printf(" - %s", page->name); %> - - - - - + + + <% if (page->desc) { %> + + <% } %> + + + +

AWeather

@@ -56,8 +59,8 @@ Content-Type: text/html; charset=UTF-8 | <% print_nav(&footer[i], page); %> <% } %>

- - + + <% } %> <% /* Normal Pages */ %> @@ -76,7 +79,7 @@ Content-Type: text/html; charset=UTF-8 and IDV.


- +

Features

Working

@@ -113,7 +116,7 @@ Content-Type: text/html; charset=UTF-8

Licencing

-

AWeather is free software licensed under the terms of the +

AWeather is free software licensed under the terms of the GNU GPL. As such, it can be used by any individuals or organizations without any license fees or royalties.

@@ -138,7 +141,7 @@ Content-Type: text/html; charset=UTF-8 and git Update: AWeather 0.5 is also compatible with the - newly released RSL v1.41 + newly released RSL v1.41
2011-06-13
@@ -252,7 +255,7 @@ Content-Type: text/html; charset=UTF-8 Development code is available from Git (and gitweb: AWeather, - Grits, + Grits, RSL)

@@ -412,3 +415,20 @@ Content-Type: text/html; charset=UTF-8

If Andy screwed up, feel free to tell him, otherwise, go away

<% } %> + +<% void print_sitemap(const page_t **pages) { %> + + + <% for (int i = 0; pages[i]; i++) { %> + <% for (int j = 0; pages[i][j].link; j++) { %> + <% if (pages[i][j].prio >= 0) { %> + + <%% "%s%s", PREFIX, pages[i][j].link %> + <%% "%3.1f", pages[i][j].prio %> + + <% } } } %> + +<% } %> diff --git a/html.h b/html.h index c51637a..5f96e4d 100644 --- a/html.h +++ b/html.h @@ -24,11 +24,16 @@ #define RSL_WEB "http://trmm-fc.gsfc.nasa.gov/trmm_gv/software/rsl/" #define RSL_FTP "ftp://trmm-fc.gsfc.nasa.gov/software/rsl-v1.41.tar.gz" +#define PREFIX "http://lug.rose-hulman.edu/proj/aweather/" + /* Types */ typedef struct { const char *link; const char *name; void (*print)(void); + float prio; + /* Optional */ + const char *desc; } page_t; /* Data */ @@ -55,3 +60,4 @@ void print_legal(void); void print_index(void); void print_notfound(void); +void print_sitemap(const page_t **pages); diff --git a/index.c b/index.c index f43a9d8..b4a23af 100644 --- a/index.c +++ b/index.c @@ -1,32 +1,37 @@ #include #include "html.h" +const char desc[] = + "AWeather is a free real-time weather data viewer that " + "supports Level-II NEXRAD files, polarimetric radars, " + "and volume rendering."; + /* Page data */ page_t header[] = { - {"about", "About", print_about}, - {"news", "News", print_news}, - {"screenshots", "Screenshots", print_screenshots}, - {"download", "Download", print_download}, - {"development", "Development", print_development}, - {NULL, NULL, NULL}, + {"about", "About", print_about, 0.7, NULL}, + {"news", "News", print_news, 0.3, NULL}, + {"screenshots", "Screenshots", print_screenshots, 0.5, NULL}, + {"download", "Download", print_download, 0.7, NULL}, + {"development", "Development", print_development, 0.3, NULL}, + {NULL, NULL, NULL, 0.0, NULL}, }; page_t other[] = { - {"grits", "Grits", print_grits}, - {"rsl", "RSL", print_rsl}, - {NULL, NULL, NULL}, + {"grits", "Grits", print_grits, 0.8, NULL}, + {"rsl", "RSL", print_rsl, 0.3, NULL}, + {NULL, NULL, NULL, 0.0, NULL}, }; page_t footer[] = { - {"contact", "Contact", print_contact}, - {NULL, NULL, NULL}, + {"contact", "Contact", print_contact, 0.2, NULL}, + {NULL, NULL, NULL, 0.0, NULL}, }; page_t special[] = { - {"index.cgi", NULL, print_index}, - {"notfound", "Not found", print_notfound}, - {NULL, NULL, NULL}, + {"", NULL, print_index, 1.0, desc}, + {NULL, "Not found", print_notfound, -1.0, NULL}, + {NULL, NULL, NULL, 0.0, NULL}, }; -page_t *everything[] = {header, other, footer, special, NULL}; -const page_t *index = &special[0]; -const page_t *notfound = &special[1]; +const page_t *everything[] = {header, other, footer, special, NULL}; +const page_t *index = &special[0]; +const page_t *notfound = &special[1]; /* Main */ int main(int argc, char **argv) @@ -40,11 +45,15 @@ int main(int argc, char **argv) /* Look up a specific page */ for (int i = 0; everything[i]; i++) for (int j = 0; everything[i][j].link; j++) { - page_t *page = &everything[i][j]; - if (g_str_equal(page->link, name+1)) + const page_t *page = &everything[i][j]; + if (g_str_equal(name+1, page->link)) return print_page(page), 0; } + /* Print sitemap by itself */ + if (g_str_equal(name+1, "sitemap.xml")) + return print_sitemap(everything), 0; + /* 404 */ return print_page(notfound), 0; } -- 2.43.2