--- /dev/null
+html.c
+main
#include <stdio.h>
-#include "lib.h"
+#include "html.h"
int main(int argc, char **argv)
{
--- /dev/null
+PROGS=main
+CLEAN=html.c
+
+default:V: run
+main: main.o html.o
+
+<../mkcommon
--- /dev/null
+gallery
+html.c
--- /dev/null
+#include <glib.h>
+#include "html.h"
+
+const gchar *query_string;
+
+void ct_init()
+{
+ query_string = g_getenv("QUERY_STRING");
+}
+
+GList *read_dir(gchar *dirname)
+{
+ GDir *dir = g_dir_open(dirname, 0, NULL);
+ const gchar *name = NULL;
+ GList *images = NULL;
+ while ((name = g_dir_read_name(dir)))
+ images = g_list_prepend(images, (gchar*)name);
+ g_dir_close(dir);
+ return images;
+}
+
+int main()
+{
+ ct_init();
+
+ header();
+ g_print("\n");
+
+ if (query_string == NULL)
+ frame_index();
+ else if (g_str_equal(query_string, "noframe"))
+ frame_nav(TRUE, read_dir("images"));
+ else if (g_str_equal(query_string, "nav"))
+ frame_nav(FALSE, read_dir("images"));
+ else if (g_str_equal(query_string, "head"))
+ frame_head();
+ else if (g_str_equal(query_string, "content"))
+ frame_content();
+ else
+ frame_index();
+}
--- /dev/null
+[#include <glib.h>]
+
+[void header() {]
+Content-Type: text/html; charset=UTF-8
+[}]
+
+
+[void frame_index(){]
+<html>
+ <frameset rows="20, *">
+ <frame name="head" src="?head">
+ <frameset cols="240,*">
+ <frame name="nav" src="?nav">
+ <frame name="content" src="?content">
+ </frameset>
+ </frameset>
+</html>
+[}]
+
+
+[void frame_head(){]
+<html>
+ <head>
+ <style>
+ body {
+ padding:0px;
+ margin:0px;
+ }
+ </style>
+ </head>
+ <body>
+ <center>
+ <a href="?noframe" target="parent">No Frames</a>
+ </center>
+ </body>
+</html>
+[}]
+
+
+[void frame_nav(int square, GList *thumbs) {]
+<!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" lang="en" xml:lang="en">
+ <head>
+ <title>Image viewer</title>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
+ <style type="text/css">
+ * {padding:0; margin:0;}
+ .align {
+ display:block;
+ float:left;
+ margin:10px;
+ text-align:center;
+ text-decoration:none;
+ width:214px;
+ [if (square)]
+ height:214px;
+ }
+ .box {
+ background-color:#f8fbFF;
+ border:solid 2px #B4C7F8;
+ display:block;
+ text-align:center;
+ text-decoration:none;
+ padding:5px;
+ overflow:hidden;
+ }
+ .box img {
+ border:none;
+ }
+ .box:hover {
+ color:transparent;
+ }
+ </style>
+ </head>
+ <body>
+ [for (GList *cur =thumbs; cur; cur = cur->next) {]
+ <div class="align">
+ <a class="box" target="content"
+ [g_print("href=\"images/%s\"", (gchar*)cur->data);]
+ ><img
+ [g_print("src=\"thumbs/%s\"", (gchar*)cur->data);]
+ ></a>
+ </div>
+ [}]
+ </body>
+</html>
+[}]
+
+
+[void frame_content(){]
+<html>
+</html>
+[}]
--- /dev/null
+void header();
+
+void frame_index();
+
+void frame_head();
+
+void frame_nav(int square, GList *thumbs);
+
+void frame_content();
--- /dev/null
+PROGS=gallery
+PKGS=glib-2.0
+CLEAN=html.c
+
+default:V: run
+gallery: gallery.o html.o
+
+<../mkcommon
--- /dev/null
+%.c: %.ct
+ ../tmpl.awk <$prereq >$target
+ ex +'norm gg=G' +'wq' $target
+
+<$HOME/lib/mkcommon
+++ /dev/null
-PKGS=glib-2.0
-PROGS=test
-default:V: test
- #cat test.c
- ./test
-test: test.o lib.o
-lib.c: lib.ct tmpl.awk
- ./tmpl.awk <lib.ct >lib.c
- ex +'norm gg=G' +'wq' lib.c
-<$HOME/lib/mkcommon
next
}
/./{
+ gsub(/"/, "\\\"")
data[length(data)] = "\""$0"\\n\""
i=length(data)-1
code[length(code)] = "fwrite(data"i", sizeof(data"i")-1, 1, stdout);"