From 24bf14f6653ebf1c1ba79b9f212d35417bb6acbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 18 Sep 2021 01:52:04 +0200 Subject: Implement attachments --- t/front.t | 11 ++++------- t/front.tc | 24 ++++++++++-------------- t/post.t | 22 ++++++++++++++++++++++ t/post.tc | 22 ++++++++++++++++++++++ 4 files changed, 58 insertions(+), 21 deletions(-) (limited to 't') 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" %>

<%= site.name %>

-

Thanks for the <%= getenv("REQUEST_METHOD") %> request!

+

Latest posts

<% struct post *post; @@ -10,12 +10,9 @@ user = getuser(byid("users", post->user), 1); %> - - + + + <% } 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

"); printf("%s", site.name ); -printf("

\n

Thanks for the "); -printf("%s", getenv("REQUEST_METHOD") ); -printf(" request!

\n
user); %>"><%= - user->name - %>id); %>"><%= - post->subject - %>id); %>"><%= post->subject %>user); %>"><%= user->name %><% printdate(post->created); %>
\n "); +printf("\n

Latest posts

\n
\n "); struct post *post; struct user *user; while(post = getpost(stmt, 0)){ user = getuser(byid("users", post->user), 1); -printf("\n \n \n \n \n "); +printf("%s", post->subject ); +printf("\n \n \n \n "); } printf("\n
user); -printf("\">"); -printf("%s", - user->name - ); -printf("\n id); printf("\">"); -printf("%s", - post->subject - ); -printf("
user); +printf("\">"); +printf("%s", user->name ); +printf(""); +printdate(post->created); +printf("
\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 @@
 <%= post->text %>
 
+<% +struct attachment *attachment; + +if(attachment = getattachment(stmt, 0)){ +%> +

Attachments

+ + <% + do{ + %> + + + + + + <% + }while(attachment = getattachment(stmt, 0)); + %> +
id); %>"><%= attachment->name %><%= attachment->mime %><%= attachment->description %>
+<% +} +%> <% #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("\n"); printf("\n
\n");
 printf("%s",  post->text );
 printf("\n
\n"); +struct attachment *attachment; + +if(attachment = getattachment(stmt, 0)){ + +printf("\n

Attachments

\n\n "); + do{ + +printf("\n \n \n \n \n \n "); + }while(attachment = getattachment(stmt, 0)); + +printf("\n
id); +printf("\">"); +printf("%s", attachment->name ); +printf(""); +printf("%s", attachment->mime ); +printf(""); +printf("%s", attachment->description ); +printf("
\n"); +} + +printf("\n"); #include "foot.tc" -- cgit v1.2.3