From 3934139d14007a885a99e2a2517446998df3dac0 Mon Sep 17 00:00:00 2001
From: Andy Spencer
Date: Wed, 28 Dec 2011 05:41:49 +0000
Subject: [PATCH] Add user manual
---
.gitignore | 1 +
data/global.css | 12 ++++++++++++
html.ct | 6 ++++++
html.h | 2 ++
index.c | 13 +++++++++++++
mkfile | 13 ++++++++++---
toc.awk | 16 ++++++++++++++++
7 files changed, 60 insertions(+), 3 deletions(-)
create mode 100644 toc.awk
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 "";
+ print body;
+}
--
2.41.0