add twtxt feed and tweak footer
This commit is contained in:
parent
894b72e5f2
commit
6ed6221461
1 changed files with 53 additions and 4 deletions
57
main.c
57
main.c
|
@ -3,7 +3,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Derek Stevens
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
|
@ -76,6 +75,41 @@ int findf(Lexicon* l, char* f) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int gettwtxt(FILE* f) {
|
||||
char buf[1024] = {0};
|
||||
char line[256];
|
||||
char datebuf[16] = {0};
|
||||
char msgbuf[240] = {0};
|
||||
char* l;
|
||||
FILE* twtxt = fopen(SITEROOT "twtxt.txt", "r");
|
||||
|
||||
scat(buf, "<div id='twtxtFeed'><h2>recent activity:</h2>");
|
||||
if (!twtxt) {
|
||||
error("Get twtxt feed", "no twtxt.txt");
|
||||
return 0;
|
||||
} else {
|
||||
int i = 0;
|
||||
while (fgets(line, 256, twtxt) && i < 3) {
|
||||
l = line;
|
||||
while (*l != 'T') {
|
||||
ccat(datebuf, *l++);
|
||||
}
|
||||
while (*l != '\t') {
|
||||
l++;
|
||||
}
|
||||
scat(msgbuf, l);
|
||||
scat(buf, datebuf);
|
||||
scat(buf, ": ");
|
||||
scat(buf, msgbuf);
|
||||
scat(buf, "<br/>");
|
||||
i++;
|
||||
}
|
||||
scat(buf, "</div>");
|
||||
fputs(buf, f);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void fpedited(FILE* f, char* path) {
|
||||
struct stat attr;
|
||||
stat(path, &attr);
|
||||
|
@ -293,13 +327,26 @@ int fpfooter(FILE* f, char* name, char* path) {
|
|||
fputs("(<a href='keys.html'>keys</a>)<br/>", f);
|
||||
}
|
||||
fputs(
|
||||
"<a href='https://webring.xxiivv.com'><img width='24' height='24' "
|
||||
"src='/img/webring.svg' alt='visit the webring'/></a> ",
|
||||
"<a href='" DOMAIN "/git/'><img width='24' height='24' "
|
||||
"src='/img/git.svg' alt='visit the nilFM hack lab'/></a> ",
|
||||
f);
|
||||
fputs(
|
||||
"<a rel=\"me\" href=\"https://fosstodon.org/@nilix\"><img width='24' "
|
||||
"height='24' "
|
||||
"src='/img/mastodon.svg' alt='visit me on Mastodon'/></a> ",
|
||||
f);
|
||||
fputs(
|
||||
"<a href='https://vimeo.com/rexnillith'><img width='24' height='24' "
|
||||
"src='/img/vimeo.svg' alt='visit me on Vimeo'/></a> ",
|
||||
f);
|
||||
fputs(
|
||||
"<a href='https://webring.xxiivv.com'><img width='24' height='24' "
|
||||
"src='/img/webring.svg' alt='visit the Webring'/></a><br/>",
|
||||
f);
|
||||
/*fputs(
|
||||
"<a href='https://lieu.cblgh.org'><img width='24' height='24' "
|
||||
"src='/img/lieu.svg' alt='search the webring'/></a><br/>",
|
||||
f);
|
||||
f);*/
|
||||
fputs(
|
||||
"<a rel='license' "
|
||||
"href='https://creativecommons.org/licenses/by-nc/4.0/"
|
||||
|
@ -359,6 +406,8 @@ FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
|
|||
if (!fpinject(f, l, srcpath))
|
||||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("\n\n</main>", f);
|
||||
} else {
|
||||
gettwtxt(f);
|
||||
}
|
||||
/* footer */
|
||||
if (!fpfooter(f, name, srcpath)) {
|
||||
|
|
Loading…
Reference in a new issue