]> Pileus Git - ~andy/aweather-web/commitdiff
Add sitemap, per-page descriptions, misc updates
authorAndy Spencer <andy753421@gmail.com>
Fri, 22 Jul 2011 21:48:01 +0000 (21:48 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 22 Jul 2011 21:48:01 +0000 (21:48 +0000)
.gitignore
.htaccess
html.ct
html.h
index.c

index ea1a3a0d77655a1c37383d0aa6b6e56cec5d8afd..e419fa2f99df56012830594b69cc90288050f397 100644 (file)
@@ -3,3 +3,4 @@
 *.cgi
 *.swp
 html.c
+tags
index e36ed8a7fa8127294f09985452002d24f0a3a475..cf0a1e400d5004133519fd8f413270c7abe74a3d 100644 (file)
--- 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 9494b5d8d3f7272b4ae4e5d59ac1ff152228c827..9cc8b76bc549a3648b833cba0ee64c7fdf8ab626 100644 (file)
--- a/html.ct
+++ b/html.ct
@@ -18,20 +18,23 @@ Content-Type: text/html; charset=UTF-8
 <% } %>
 
 <% void print_page(const page_t *page) { %>
-<?xml version="1.0" encoding="UTF-8"?> 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
-       <head> 
-               <title>AWeather<% if (page->name) printf(" - %s", page->name); %></title> 
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+       <head>
+               <title>AWeather<% if (page->name) printf(" - %s", page->name); %></title>
                <link rel="shortcut icon" href="images/aweather.ico" />
                <link href="data/global.css" rel="stylesheet" type="text/css" />
                <meta http-equiv="X-UA-Compatible" content="IE=9" />
-               <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> 
-               <meta name="keywords" content="weather, radar, nexrad, level-ii, virtual globe, grits, rsl" >
-               <meta name="description" content="AWeather is a free real-time weather data viewer
-                       that supports Level-II NEXRAD files, polarimetric radars, and volume rendering." >
-       </head> 
-       <body> 
+               <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
+               <meta name="keywords" content="weather, radar, nexrad, level-ii, virtual globe, grits, rsl" />
+               <% if (page->desc) { %>
+               <meta name="description" content="<%= page->desc %>" />
+               <% } %>
+               <meta name="google-site-verification" content="-SZkTpNRWHrpESTGNZ8Pshnz4zKbwfKv54NoavUKK_Y" />
+               <meta name="y_key" content="abe8287921b25151" />
+       </head>
+       <body>
                <div class="top">
                        <a href="."><img class="logo" src="images/logo.png" alt="AWeather" /></a>
                        <h1 class="title"><a href=".">AWeather</a></h1>
@@ -56,8 +59,8 @@ Content-Type: text/html; charset=UTF-8
                                | <% print_nav(&footer[i], page); %>
                        <% } %>
                </p>
-       </body> 
-</html> 
+       </body>
+</html>
 <% } %>
 
 <% /* Normal Pages */ %>
@@ -76,7 +79,7 @@ Content-Type: text/html; charset=UTF-8
                and IDV.
        </p>
        <hr />
-       
+
        <h2>Features</h2>
        <div class="col">
                <h3>Working</h3>
@@ -113,7 +116,7 @@ Content-Type: text/html; charset=UTF-8
 
        <div style="clear:both;"></div>
        <h2>Licencing</h2>
-       <p>AWeather is free software licensed under the terms of the 
+       <p>AWeather is free software licensed under the terms of the
           <a href="http://www.gnu.org/licenses/gpl.html">GNU GPL</a>.
           As such, it can be used by any individuals or organizations
           without any license fees or royalties.</p>
@@ -138,7 +141,7 @@ Content-Type: text/html; charset=UTF-8
                                    and <a href="<%= GW_RSL %>">git</a></li>
                        </ul>
                        <b>Update:</b> AWeather 0.5 is also compatible with the
-                       newly released RSL v1.41</li>
+                       newly released RSL v1.41
                </dd>
 
                <dt>2011-06-13</dt>
@@ -252,7 +255,7 @@ Content-Type: text/html; charset=UTF-8
                Development code is available from Git
                (and gitweb:
                 <a href="<%= GW_AWEATHER %>">AWeather</a>,
-                <a href="<%= GW_GRITS    %>">Grits</a>, 
+                <a href="<%= GW_GRITS    %>">Grits</a>,
                 <a href="<%= GW_RSL      %>">RSL</a>)
        </p>
        <div style="margin-left: 30px;">
@@ -412,3 +415,20 @@ Content-Type: text/html; charset=UTF-8
        <p>If Andy screwed up, feel free to <a href="contact">tell him</a>,
           otherwise, go away</p>
 <% } %>
+
+<% void print_sitemap(const page_t **pages) { %>
+<?xml version='1.0' encoding='UTF-8'?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
+                           http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
+       <% for (int i = 0; pages[i];         i++) { %>
+       <% for (int j = 0; pages[i][j].link; j++) { %>
+       <% if  (pages[i][j].prio >= 0) { %>
+       <url>
+               <loc><%% "%s%s", PREFIX, pages[i][j].link %></loc>
+               <priority><%% "%3.1f", pages[i][j].prio %></priority>
+       </url>
+       <% } } } %>
+</urlset>
+<% } %>
diff --git a/html.h b/html.h
index c51637a8e2f94e2f2d1c96654b8186434a8f942b..5f96e4dd5c8b5346d617176c9f6e076e3b69079f 100644 (file)
--- a/html.h
+++ b/html.h
 #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 f43a9d83ab25f596ed8dcd1c5f0e79732fdffe26..b4a23af409fd1ffe7c67975dc2a6c820e04ddaf2 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1,32 +1,37 @@
 #include <glib.h>
 #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;
 }