From: Andy Spencer Date: Wed, 28 Dec 2011 05:41:49 +0000 (+0000) Subject: Add user manual X-Git-Url: http://pileus.org/git/?p=~andy%2Faweather-web;a=commitdiff_plain;h=3934139d14007a885a99e2a2517446998df3dac0 Add user manual --- diff --git a/.gitignore b/.gitignore index e419fa2..e28005f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ *.cgi *.swp html.c +manual.inc tags diff --git a/data/global.css b/data/global.css index aa85aad..970effd 100644 --- a/data/global.css +++ b/data/global.css @@ -339,3 +339,15 @@ dl.inline dt:after { dl.small dt { width: 4em; } + +/* Asciidoc */ +.asciidoc p { + margin-top: 0.7em; +} +.asciidoc li p, +.asciidoc td p { + margin-top: 0em; +} +.asciidoc .hdlist table { + padding-left: 1em; +} diff --git a/html.ct b/html.ct index f9194a3..68be683 100644 --- a/html.ct +++ b/html.ct @@ -127,6 +127,12 @@ Content-Type: text/html; charset=UTF-8 without any license fees or royalties.

<% } %> +<% void print_manual(void) { %> +
+ <% print_file("manual.inc"); %> +
+<% } %> + <% void print_news(void) { %> diff --git a/html.h b/html.h index 4c84a58..4ad29e0 100644 --- a/html.h +++ b/html.h @@ -49,11 +49,13 @@ extern page_t footer[]; extern page_t special[]; /* Global functions */ +void print_file(char *file); void print_header(void); void print_page(const page_t *which); /* Pages */ void print_about(void); +void print_manual(void); void print_news(void); void print_oldnews(void); void print_screenshots(void); diff --git a/index.c b/index.c index 7877fb0..304293d 100644 --- a/index.c +++ b/index.c @@ -1,3 +1,4 @@ +#include #include #include #include "html.h" @@ -10,6 +11,7 @@ const char desc[] = /* Page data */ page_t header[] = { {"about", "About", print_about, 0.7, NULL}, + {"manual", "Manual", print_manual, 0.5, NULL}, {"news", "News", print_news, 0.3, NULL}, {"screenshots", "Screenshots", print_screenshots, 0.5, NULL}, {"download", "Download", print_download, 0.7, NULL}, @@ -35,6 +37,17 @@ const page_t *everything[] = {header, other, footer, special, NULL}; const page_t *index = &special[0]; const page_t *notfound = &special[2]; +/* Helper functions */ +void print_file(char *file) +{ + char data[512]; + FILE *fd = fopen(file, "r"); + while (!feof(fd)) { + size_t size = fread(data, 1, sizeof(data), fd); + fwrite(data, 1, size, stdout); + } +} + /* Main */ int main(int argc, char **argv) { diff --git a/mkfile b/mkfile index dc18067..83df932 100644 --- a/mkfile +++ b/mkfile @@ -1,6 +1,8 @@ CT=/scratch/ct/ct CFLAGS='--std=c99 -Wall' +all:V: index.cgi manual.inc + index.cgi: index.o html.o gcc $CFLAGS -o $target $prereq $PKG_LIBS @@ -10,16 +12,21 @@ index.cgi: index.o html.o %.c: %.ct $CT -o $target $prereq +manual.inc: ../docs/manual.ad + asciidoc -s -a toc -a numbered -b xhtml11 -o- $prereq \ + | awk -f toc.awk > $target + clean:V: rm -f *.o *.cgi html.c push:V: user=spenceal dest=/home/lug/htdocs/proj/aweather/ + serv=lug.rose-hulman.edu rsync -uavz .htaccess \ - $user@lug.rose-hulman.edu:$dest + $user@$serv:$dest rsync -uavz --delete \ --exclude '*~' \ --exclude '.*' \ - index.cgi images screens data \ - $user@lug.rose-hulman.edu:$dest + index.cgi manual.inc images screens data \ + $user@$serv:$dest diff --git a/toc.awk b/toc.awk new file mode 100644 index 0000000..c973f66 --- /dev/null +++ b/toc.awk @@ -0,0 +1,16 @@ +// { + if (match($0, /([0-9.]* *)([^<]*)<\/h[0-9]>/, arr)) { + id = arr[1]; + num = arr[2]; + txt = arr[3]; + toc = toc "\n" "
  • " num "" txt "
  • " + body = body "\n" "" + } + body = body "\n" $0 +} + +END { + print "

    Table of Contents

    "; + print "
      " toc "
    "; + print body; +}