aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-17 23:47:58 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-17 23:47:58 +0200
commit7d65ce8c8e304dc8367f4492948514f2acc07a3b (patch)
tree1d1e8584ad326cf3ea7701e2a726a0f0ae1cb6cf /t
parent56509ab16c8d2225182eb0400e5c6a4900870391 (diff)
downloadcforum-7d65ce8c8e304dc8367f4492948514f2acc07a3b.tar.gz
Whatever
Diffstat (limited to 't')
-rw-r--r--t/err.t4
-rw-r--r--t/err.tc6
-rw-r--r--t/front.t24
-rw-r--r--t/front.tc34
-rw-r--r--t/post.t13
-rw-r--r--t/post.tc19
-rw-r--r--t/user.t4
-rw-r--r--t/user.tc6
8 files changed, 73 insertions, 37 deletions
diff --git a/t/err.t b/t/err.t
index 437effc..9a4aa61 100644
--- a/t/err.t
+++ b/t/err.t
@@ -1,2 +1,4 @@
+<% #include "head.tc" %>
<h1><%= title %></h1>
-<p><%= err %></p> \ No newline at end of file
+<p><%= err %></p>
+<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/err.tc b/t/err.tc
index c4369a9..c066a5a 100644
--- a/t/err.tc
+++ b/t/err.tc
@@ -1,5 +1,7 @@
-printf("<h1>");
+#include "head.tc"
+printf("\n<h1>");
printf("%s", title );
printf("</h1>\n<p>");
printf("%s", err );
-printf("</p>");
+printf("</p>\n");
+#include "foot.tc"
diff --git a/t/front.t b/t/front.t
index a9badb0..86b8fb5 100644
--- a/t/front.t
+++ b/t/front.t
@@ -1,20 +1,24 @@
+<% #include "head.tc" %>
<h1><%= site.name %></h1>
<p>Thanks for the <%= getenv("REQUEST_METHOD") %> request!</p>
<table border="1">
- <tr style="font-weight: bold;">
- <td style="width: 60px;">Key</td>
- <td style="width: 140px;">Value</td>
- </tr>
<%
- char *p, *v;
- while(p = nextparam(GET, 512)){
- v = split(p);
+ struct post *post;
+ struct user *user;
+
+ while(post = getpost(stmt, 0)){
+ user = getuser(byid("users", post->user), 1);
%>
<tr>
- <td><%= p %></td>
- <td><%= v %></td>
+ <td><a href="?user=<% printf("%d", post->user); %>"><%=
+ user->name
+ %></a></td>
+ <td><a href="?post=<% printf("%d", post->id); %>"><%=
+ post->subject
+ %></a></td>
</tr>
<%
}
%>
-</table> \ No newline at end of file
+</table>
+<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/front.tc b/t/front.tc
index d7afb7b..f95d8cb 100644
--- a/t/front.tc
+++ b/t/front.tc
@@ -1,17 +1,29 @@
-printf("<h1>");
+#include "head.tc"
+printf("\n<h1>");
printf("%s", site.name );
printf("</h1>\n<p>Thanks for the ");
printf("%s", getenv("REQUEST_METHOD") );
-printf(" request!</p>\n<table border=\"1\">\n <tr style=\"font-weight: bold;\">\n <td style=\"width: 60px;\">Key</td>\n <td style=\"width: 140px;\">Value</td>\n </tr>\n ");
- char *p, *v;
- while(p = nextparam(GET, 512)){
- v = split(p);
+printf(" request!</p>\n<table border=\"1\">\n ");
+ struct post *post;
+ struct user *user;
-printf("\n <tr>\n <td>");
-printf("%s", p );
-printf("</td>\n <td>");
-printf("%s", v );
-printf("</td>\n </tr>\n ");
+ while(post = getpost(stmt, 0)){
+ user = getuser(byid("users", post->user), 1);
+
+printf("\n <tr>\n <td><a href=\"?user=");
+printf("%d", post->user);
+printf("\">");
+printf("%s",
+ user->name
+ );
+printf("</a></td>\n <td><a href=\"?post=");
+printf("%d", post->id);
+printf("\">");
+printf("%s",
+ post->subject
+ );
+printf("</a></td>\n </tr>\n ");
}
-printf("\n</table>");
+printf("\n</table>\n");
+#include "foot.tc"
diff --git a/t/post.t b/t/post.t
index 83529d7..b4d1e52 100644
--- a/t/post.t
+++ b/t/post.t
@@ -1,13 +1,16 @@
+<% #include "head.tc" %>
<h1>Post <% printf("%d", id); %>: <%= post->subject %></h1>
-<p>From: <%= user->full? user->full: "" %> <%
-if(user->full) printf("&lt;");
-%><a href="?user=<% printf("%d", user->id); %>"><%= user->name %></a><%
-if(user->full) printf("&gt;"); %>
+<p>From: <%= user->full? user->full: "" %>
+<% if(user->full) printf("&lt;"); %><a href="?user=<% printf("%d", user->id); %>"><%= user->name %></a><% if(user->full) printf("&gt;"); %>
<br>Date: <% printdate(post->created); %>
<% if(post->edited){
printf("<br>Edited: ");
printdate(post->edited);
} %>
+<% if(post->parent){ %>
+<br>In Reply To: <a href="?post=<% printf("%d", post->parent); %>"><% printf("%d", post->parent); %></a>
+<% } %>
<pre>
<%= post->text %>
-</pre> \ No newline at end of file
+</pre>
+<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/post.tc b/t/post.tc
index 732f0a7..9207de5 100644
--- a/t/post.tc
+++ b/t/post.tc
@@ -1,12 +1,12 @@
-printf("<h1>Post ");
+#include "head.tc"
+printf("\n<h1>Post ");
printf("%d", id);
printf(": ");
printf("%s", post->subject );
printf("</h1>\n<p>From: ");
printf("%s", user->full? user->full: "" );
-printf(" ");
-if(user->full) printf("&lt;");
-
+printf("\n");
+if(user->full) printf("&lt;");
printf("<a href=\"?user=");
printf("%d", user->id);
printf("\">");
@@ -20,6 +20,15 @@ if(post->edited){
printf("<br>Edited: ");
printdate(post->edited);
}
+printf("\n");
+if(post->parent){
+printf("\n<br>In Reply To: <a href=\"?post=");
+printf("%d", post->parent);
+printf("\">");
+printf("%d", post->parent);
+printf("</a>\n");
+}
printf("\n<pre>\n");
printf("%s", post->text );
-printf("\n</pre>");
+printf("\n</pre>\n");
+#include "foot.tc"
diff --git a/t/user.t b/t/user.t
index 9a0fd49..af7c8cd 100644
--- a/t/user.t
+++ b/t/user.t
@@ -1 +1,3 @@
-<h1>User <% printf("%d", id); %>: <%= user->name %></h1> \ No newline at end of file
+<% #include "head.tc" %>
+<h1>User <% printf("%d", id); %>: <%= user->name %></h1>
+<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/user.tc b/t/user.tc
index 3d92e16..3527acb 100644
--- a/t/user.tc
+++ b/t/user.tc
@@ -1,5 +1,7 @@
-printf("<h1>User ");
+#include "head.tc"
+printf("\n<h1>User ");
printf("%d", id);
printf(": ");
printf("%s", user->name );
-printf("</h1>");
+printf("</h1>\n");
+#include "foot.tc"