aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-18 01:52:04 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-18 01:52:04 +0200
commit24bf14f6653ebf1c1ba79b9f212d35417bb6acbf (patch)
tree913a0f1bebf835a1109652b1c61d363972ee9a28 /t
parente25f56cbe86041d4ab19e474e38032fa7e681ac7 (diff)
downloadcforum-24bf14f6653ebf1c1ba79b9f212d35417bb6acbf.tar.gz
Implement attachments
Diffstat (limited to 't')
-rw-r--r--t/front.t11
-rw-r--r--t/front.tc24
-rw-r--r--t/post.t22
-rw-r--r--t/post.tc22
4 files changed, 58 insertions, 21 deletions
diff --git a/t/front.t b/t/front.t
index 86b8fb5..5f59c1c 100644
--- a/t/front.t
+++ b/t/front.t
@@ -1,6 +1,6 @@
<% #include "head.tc" %>
<h1><%= site.name %></h1>
-<p>Thanks for the <%= getenv("REQUEST_METHOD") %> request!</p>
+<h3>Latest posts</h3>
<table border="1">
<%
struct post *post;
@@ -10,12 +10,9 @@
user = getuser(byid("users", post->user), 1);
%>
<tr>
- <td><a href="?user=<% printf("%d", post->user); %>"><%=
- user->name
- %></a></td>
- <td><a href="?post=<% printf("%d", post->id); %>"><%=
- post->subject
- %></a></td>
+ <td><a href="?post=<% printf("%d", post->id); %>"><%= post->subject %></a></td>
+ <td><a href="?user=<% printf("%d", post->user); %>"><%= user->name %></a></td>
+ <td><% printdate(post->created); %></td>
</tr>
<%
}
diff --git a/t/front.tc b/t/front.tc
index f95d8cb..9bed8a1 100644
--- a/t/front.tc
+++ b/t/front.tc
@@ -1,28 +1,24 @@
#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 ");
+printf("</h1>\n<h3>Latest posts</h3>\n<table border=\"1\">\n ");
struct post *post;
struct user *user;
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("\n <tr>\n <td><a href=\"?post=");
printf("%d", post->id);
printf("\">");
-printf("%s",
- post->subject
- );
-printf("</a></td>\n </tr>\n ");
+printf("%s", post->subject );
+printf("</a></td>\n <td><a href=\"?user=");
+printf("%d", post->user);
+printf("\">");
+printf("%s", user->name );
+printf("</a></td>\n <td>");
+printdate(post->created);
+printf("</td>\n </tr>\n ");
}
printf("\n</table>\n");
diff --git a/t/post.t b/t/post.t
index b4d1e52..200e27d 100644
--- a/t/post.t
+++ b/t/post.t
@@ -13,4 +13,26 @@
<pre>
<%= post->text %>
</pre>
+<%
+struct attachment *attachment;
+
+if(attachment = getattachment(stmt, 0)){
+%>
+<h3>Attachments</h3>
+<table border="1">
+ <%
+ do{
+ %>
+ <tr>
+ <td><a href="?attachment=<% printf("%d", attachment->id); %>"><%= attachment->name %></a></td>
+ <td><%= attachment->mime %></td>
+ <td><%= attachment->description %></td>
+ </tr>
+ <%
+ }while(attachment = getattachment(stmt, 0));
+ %>
+</table>
+<%
+}
+%>
<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/post.tc b/t/post.tc
index 9207de5..89298db 100644
--- a/t/post.tc
+++ b/t/post.tc
@@ -31,4 +31,26 @@ printf("</a>\n");
printf("\n<pre>\n");
printf("%s", post->text );
printf("\n</pre>\n");
+struct attachment *attachment;
+
+if(attachment = getattachment(stmt, 0)){
+
+printf("\n<h3>Attachments</h3>\n<table border=\"1\">\n ");
+ do{
+
+printf("\n <tr>\n <td><a href=\"?attachment=");
+printf("%d", attachment->id);
+printf("\">");
+printf("%s", attachment->name );
+printf("</a></td>\n <td>");
+printf("%s", attachment->mime );
+printf("</td>\n <td>");
+printf("%s", attachment->description );
+printf("</td>\n </tr>\n ");
+ }while(attachment = getattachment(stmt, 0));
+
+printf("\n</table>\n");
+}
+
+printf("\n");
#include "foot.tc"