]> Pileus Git - ~andy/ct/blob - knot/html.ct
Use dynamic memory, fix CSS for tables
[~andy/ct] / knot / html.ct
1 <% #include "knot.h" %>
2
3 <% static void print_img(int ptrn) { %>
4         <% if (ptrn) { %>
5         <img src="img/<% if (ptrn & LEFT ) printf("l"); %>
6                       <% if (ptrn & RIGHT) printf("r"); %>
7                       <% if (ptrn & UP   ) printf("u"); %>
8                       <% if (ptrn & DOWN ) printf("d"); %>.png">
9         <% } %>
10 <% } %>
11
12 <% void print_index(row_t *rows) { %>
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
14   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
15 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
16         <title>Knot</title>
17         <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
18         <head>
19                 <style type="text/css">
20                         td  { min-width:64px; height:64px; }
21                         img { position:absolute; }
22                 </style>
23         </head>
24         <body>
25         <table cellpadding="0" cellspacing="0">
26                 <% for (int row = 1; rows[row].cols; row++) { %>
27                 <tr>
28                         <% for (int col = 1; col < rows[row].ncols; col++) { %>
29                         <td>
30                                 <% print_img(rows[row].cols[col].bot); %>
31                                 <% print_img(rows[row].cols[col].top); %>
32                         </td>
33                         <% } %>
34                 </tr>
35                 <% } %>
36                 </table>
37         </body>
38 </html>
39 <% } %>