]> Pileus Git - ~andy/aweather-web/commitdiff
Add user manual
authorAndy Spencer <andy753421@gmail.com>
Wed, 28 Dec 2011 05:41:49 +0000 (05:41 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 28 Dec 2011 05:59:04 +0000 (05:59 +0000)
.gitignore
data/global.css
html.ct
html.h
index.c
mkfile
toc.awk [new file with mode: 0644]

index e419fa2f99df56012830594b69cc90288050f397..e28005f9239fd295025ff71bb0d13f2d4da8ba63 100644 (file)
@@ -3,4 +3,5 @@
 *.cgi
 *.swp
 html.c
+manual.inc
 tags
index aa85aad9ffe588effcf4f4f8b2427e38fdad59e5..970effd1a0f24b0d924c117c40a70892ea0fa1c0 100644 (file)
@@ -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 f9194a324d2d4852fd8e0f9229be0db17330c054..68be68379603b7c8ab2642cfa0babb6e9dd284be 100644 (file)
--- a/html.ct
+++ b/html.ct
@@ -127,6 +127,12 @@ Content-Type: text/html; charset=UTF-8
           without any license fees or royalties.</p>
 <% } %>
 
+<% void print_manual(void) { %>
+       <div class="asciidoc">
+               <% print_file("manual.inc"); %>
+       </div>
+<% } %>
+
 <% void print_news(void) { %>
        <!-- It's not really spring anymore :/ -->
        <!-- <p class="quote">Now that it's spring again, progress on AWeather is continuing.</p> -->
diff --git a/html.h b/html.h
index 4c84a5863201fc9f49a664aaed233f73141511c8..4ad29e0a1d45fa483619f70fccecd0b7b9949ba3 100644 (file)
--- 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 7877fb073c3dfae7d1278950eb47cb730fcbd34b..304293d174754068b5a86e5bce5cb9672b2eedf0 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #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 dc180674b4d5516d9d25bd4cf988a7ee1d967efb..83df9326cb0b1b3ea52bfe5228ffc067456e8dfa 100644 (file)
--- 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 (file)
index 0000000..c973f66
--- /dev/null
+++ b/toc.awk
@@ -0,0 +1,16 @@
+// {
+       if (match($0, /<h[0-9] id="([^"]*)">([0-9.]* *)([^<]*)<\/h[0-9]>/, arr)) {
+               id   = arr[1];
+               num  = arr[2];
+               txt  = arr[3];
+               toc  = toc  "\n" "<li>" num "<a href=\"#" id "\">" txt "</a></li>"
+               body = body "\n" "<a id=\"" id "\"></a>"
+       }
+       body = body "\n" $0
+}
+
+END {
+       print "<h2>Table of Contents</h2>";
+       print "<ul style=\"list-style:none;\">" toc "</ul>";
+       print body;
+}