]> Pileus Git - ~andy/aweather-web/blob - index.c
Split news into news/oldnews
[~andy/aweather-web] / index.c
1 #include <glib.h>
2 #include "html.h"
3
4 const char desc[] =
5         "AWeather is a free real-time weather data viewer that "
6         "supports Level-II NEXRAD files, polarimetric radars, "
7         "and volume rendering.";
8
9 /* Page data */
10 page_t header[] = {
11         {"about",       "About",       print_about,        0.7, NULL},
12         {"news",        "News",        print_news,         0.3, NULL},
13         {"screenshots", "Screenshots", print_screenshots,  0.5, NULL},
14         {"download",    "Download",    print_download,     0.7, NULL},
15         {"development", "Development", print_development,  0.3, NULL},
16         {NULL,          NULL,          NULL,               0.0, NULL},
17 };
18 page_t other[] = {
19         {"grits",       "Grits",       print_grits,        0.8, NULL},
20         {"rsl",         "RSL",         print_rsl,          0.3, NULL},
21         {NULL,          NULL,          NULL,               0.0, NULL},
22 };
23 page_t footer[] = {
24         {"contact",     "Contact",     print_contact,      0.2, NULL},
25         {NULL,          NULL,          NULL,               0.0, NULL},
26 };
27 page_t special[] = {
28         {"",            NULL,          print_index,        1.0, desc},
29         {"oldnews",     "Old News",    print_oldnews,      0.2, NULL},
30         {NULL,          "Not found",   print_notfound,    -1.0, NULL},
31         {NULL,          NULL,          NULL,               0.0, NULL},
32 };
33 const page_t *everything[] = {header, other, footer, special, NULL};
34 const page_t *index        = &special[0];
35 const page_t *notfound     = &special[1];
36
37 /* Main */
38 int main(int argc, char **argv)
39 {
40         print_header();
41
42         const gchar *name = g_getenv("PATH_INFO");
43         if (name == NULL || name[0] == '\0' || name[1] == '\0')
44                 return print_page(index), 0;
45
46         /* Look up a specific page */
47         for (int i = 0; everything[i];         i++)
48         for (int j = 0; everything[i][j].link; j++) {
49                 const page_t *page = &everything[i][j];
50                 if (g_str_equal(name+1, page->link))
51                         return print_page(page), 0;
52         }
53
54         /* Print sitemap by itself */
55         if (g_str_equal(name+1, "sitemap.xml"))
56                 return print_sitemap(everything), 0;
57
58         /* 404 */
59         return print_page(notfound), 0;
60 }