diff --git a/config.def.h b/config.def.h index e919edf..04d99e1 100644 --- a/config.def.h +++ b/config.def.h @@ -18,4 +18,5 @@ #define ABOUT_HTML "

Welcome to this website

" #define NAME "a website" #define IS_HTML5_VIDEO_ENABLED 0 +#define CONTACT_ADDRESS "contact@amotherfuckingwebsite.com" /* clang-format on */ diff --git a/main.c b/main.c index acbb919..90c1d69 100644 --- a/main.c +++ b/main.c @@ -9,7 +9,7 @@ #include "config.h" /* -Copyright (c) 2021 Derek Stevens +Copyright (c) 2021 Iris Lightshard Copyright (c) 2021 Devine Lu Linvega Permission to use, copy, modify, and distribute this software for any @@ -54,6 +54,12 @@ int error(char* msg, char* val) { return 0; } +void clearstr(char* s) { + while (*s) { + *s++ = 0; + } +} + time_t getlater(time_t a, time_t b) { return a > b ? a : b; } int ismetanav(char* name) { return scmp(name, "meta.nav"); } @@ -75,7 +81,7 @@ int gettwtxt(FILE* f) { char datebuf[16] = {0}; char msgbuf[240] = {0}; char urlbuf[256] = {0}; - char *l, *d, *m, *u; + char* l; FILE* twtxt = fopen(SITEROOT TWTXT, "r"); scat(buf, "

recent activity

\n\n"); @@ -121,18 +127,9 @@ int gettwtxt(FILE* f) { scat(buf, msgbuf); } scat(buf, "\n"); - d = datebuf; - while (*d) { - *d++ = 0; - } - m = msgbuf; - while (*m) { - *m++ = 0; - } - u = urlbuf; - while (*u) { - *u++ = 0; - } + clearstr(datebuf); + clearstr(msgbuf); + clearstr(urlbuf); i++; } fclose(twtxt); @@ -539,6 +536,139 @@ int fpblock(FILE* f, char* s) { return 1; } +int fppiclisting(FILE* f, Lexicon* l, char* s) { + char desc[1024] = {0}; + char href[1024] = {0}; + char img[1024] = {0}; + char metaimg[1024] = {0}; + int target = 0; + + char* c = s; + int i = 0; + while (i < 2) { + if (*c == '|' || !(*c)) { + i++; + c++; + continue; + } + switch (i) { + case 0: + ccat(desc, *c++); + break; + case 1: + ccat(img, *c++); + break; + } + } + scpy(desc, href, slen(desc) + 1); + scsw(stlc(href), ' ', '_'); + scat(metaimg, href); + scat(metaimg, "|/"); + scat(metaimg, href); + scat(metaimg, ".html|"); + scat(metaimg, img); + scat(metaimg, desc); + + fputs("
  • ", f); + fphimg(f, metaimg); + target = findf(l, desc); + if (target < 0) { + return error("Missing link", s); + } + + fprintf(f, "", scsw(stlc(desc), ' ', '_')); + fprintf(f, "%s", scsw(stlc(desc), '_', ' ')); + l->refs[target]++; + fputs("
  • ", f); + return 1; +} + +int fpshop(FILE* f, Lexicon* l, char* s) { + + char paylink[1024] = {0}; + char desc[1024] = {0}; + + char img[1024] = {0}; + char alt[1024] = {0}; + + char metaimg[1024] = {0}; + char imgcountbuf[12] = {0}; + int imgcount = 0; + + char* c = s; + + int i = 0; + + while (i < 2) { + if (*c == '|' || !(*c)) { + i++; + c++; + continue; + } + switch (i) { + case 0: + ccat(paylink, *c++); + break; + case 1: + ccat(desc, *c++); + break; + } + } + + fputs("
    ", f); + + for (;;) { + + if (*c == '|' || !(*c)) { + if (i % 2 == 0) { + clearstr(metaimg); + sprintf(imgcountbuf, "%d", ++imgcount); + scat(metaimg, "img"); + scat(metaimg, imgcountbuf); + scat(metaimg, "|"); + scat(metaimg, img); + scat(metaimg, "|"); + } else { + scat(metaimg, alt); + + fpimg(f, metaimg); + + clearstr(imgcountbuf); + clearstr(img); + clearstr(alt); + } + + if (!(*c)) { + if (i % 2 == 0) { + return error("Needs even number of args", s); + } else { + break; + } + } + + i++; + c++; + continue; + } + if (i % 2 == 0) { + ccat(img, *c++); + } else { + ccat(alt, *c++); + } + } + + fputs("
    ", f); + + fppara(f, l, desc); + fprintf( + f, + "", + paylink); + fputs("
    ", f); + return 1; +} + int fptemplate(FILE* f, Lexicon* l, char* s) { int target = 0; switch (s[0]) { @@ -594,6 +724,10 @@ int fptemplate(FILE* f, Lexicon* l, char* s) { return fpsans(f, l, s + 1); case ')': return fpserif(f, l, s + 1); + case '%': + return fppiclisting(f, l, s + 1); + case '^': + return fpshop(f, l, s + 1); } if (s[0]) { target = findf(l, s);