add sitemap, update build to play nice with nirvash

This commit is contained in:
Iris Lightshard 2022-06-13 07:53:12 -06:00
parent 1e232e2b9a
commit 9c13438562
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
4 changed files with 83 additions and 27 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
inc/ inc/
old/ old/
config.h config.h
map.htm

View file

@ -22,7 +22,7 @@ clang-format -i main.c config.h
rm -f ./main rm -f ./main
# Linux(debug) # Linux(debug)
# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main #cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main
# Linux(fast) # Linux(fast)
cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main
@ -47,7 +47,8 @@ fi
./main ./main
exitstatus=$? exitstatus=$?
if [ "${exitstatus}" = "0" ]; then if [ "${exitstatus}" = "0" ]; then
./thumbnailer.sh build & echo "Generating thumbnails in the background"
(./thumbnailer.sh build > /dev/null 2>&1) &
fi fi
# Cleanup # Cleanup

View file

@ -1,25 +1,37 @@
#define DESC "lair of drkste aka nilix: artist, programmer, philosopher"
#define LEXICON_SIZE 1024 #define LEXICON_SIZE 1024
#define TAG_BODY_SIZE 4096
#define NAME "nilFM"
#define DOMAIN "https://nilfm.cc"
#define LOGO "<img src='/img/nilfm_blackHole_96.png' alt='blackHole://server'/>"
#define DESC "lair of drkste aka nilix: programmer, artist, philosopher"
#define ABOUT "Derek Stevens &lt;"\
"<a href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a>&gt;<br/>\n"\
"artist, programmer, philosopher<br/><br/>\n"\
"verify my signature: <a href='/serv/signingKey.pub'>signing public key</a><br/>\n"\
"send me an encrypted message: <a href='/serv/encryptionKey.pub'>encryption public key</a>\n"
#define CONTACT "contact: <a href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a> (<a href='keys.html'>keys</a>)<br/>\n"
#define FOOTER "<a href='/git/'><img "\
"src='/img/git.svg' alt='visit the nilFM hack lab.'/></a>&nbsp;\n"\
"<a rel='me' href='https://cafe.nilfm.cc/u/nilix'><img "\
"src='/img/honk.svg' alt='visit me on the Fediverse.'/></a>&nbsp;\n"\
"<a href='https://webring.xxiivv.com'><img "\
"src='/img/webring.svg' alt='visit the Webring.'/></a><br/>\n"
#define LICENSE "<a rel='license' "\
"href='https://creativecommons.org/licenses/by-nc/4.0/"\
"legalcode.txt'>CC-BY-NC 4</a>"
#define SITEROOT "../www/"
#define MAINCSS "/new.css" #define MAINCSS "/new.css"
#define FOOTER \
"<a href='/git/'><img src='/img/git.svg' alt='visit the nilFM hack " \
"lab.'/></a>&nbsp;\n" \
"<a rel='me' href='https://cafe.nilfm.cc/u/nilix'><img src='/img/honk.svg' " \
"alt='visit me on the Fediverse.'/></a>&nbsp;\n" \
"<a href='https://webring.xxiivv.com'><img src='/img/webring.svg' " \
"alt='visit the Webring.'/></a><br/>\n" \
"<a href='/sitemap.html'>sitemap</a><br/>\n"
#define LICENSE \
"<a rel='license' " \
"href='https://creativecommons.org/licenses/by-nc/4.0/" \
"legalcode.txt'>CC-BY-NC 4</a><br/>\n" \
"<a href='/legal_disclaimer.html'>opinions are my own</a>"
#define SITEROOT "../www/"
#define TAG_BODY_SIZE 4096
#define CONTACT \
"contact: <a href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a> (<a " \
"href='keys.html'>keys</a>)<br/>\n" \
""
#define DOMAIN "https://nilfm.cc"
#define FRONTCSS "/front.css" #define FRONTCSS "/front.css"
#define ABOUT \
"Derek Stevens &lt;<a " \
"href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a>&gt;<br/>\n" \
"artist, programmer, philosopher<br/><br/>\n" \
"verify my signature: <a " \
"href='/serv/90587A740FA4FFA0971575383B7FBC22144E6398.asc'>signing public " \
"key</a><br/>\n" \
"send me an encrypted message: <a " \
"href='/serv/F5672E001CC962BE3B6C8887C65B677280C66DE5.asc'>encryption " \
"public key</a>\n" \
""
#define LOGO "<img src='/img/nilfm_blackHole_96.png' alt='blackHole://server'/>"
#define NAME "nilFM"

46
main.c
View file

@ -1,7 +1,9 @@
#include <dirent.h> #define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/dir.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h>
#include <time.h> #include <time.h>
#include "config.h" #include "config.h"
@ -623,6 +625,45 @@ void inspect(Lexicon* l) {
error("Orphaned", l->files[i]); error("Orphaned", l->files[i]);
} }
void map(Lexicon* l) {
char dstpath[64];
char srcpath[64];
struct dirent** d;
FILE* siteMap;
int n, i = 0;
n = scandir("inc", &d, NULL, alphasort);
if (n < 0)
return;
dstpath[0] = 0;
srcpath[0] = 0;
scat(dstpath, SITEROOT);
scat(dstpath, "sitemap.html");
scat(srcpath, "map.htm");
siteMap = fopen("map.htm", "w");
/* don't use shorthand for the <ul> tag because it will easily overflow
* TAG_BODY_SIZE */
fprintf(siteMap, "<ul>\n");
while (i < n) {
char filepath[64], filename[64];
if (d[i]->d_name[0] != '.') {
scpy(d[i]->d_name, filepath, 64);
fprintf(
siteMap,
" {-{%s}}\n",
scsw(
scpy(d[i]->d_name, filename, ssin(d[i]->d_name, ".htm") + 1),
'_',
' '));
}
free(d[i++]);
}
free(d);
fprintf(siteMap, "</ul>\n");
fclose(siteMap);
fclose(build(fopen(dstpath, "w"), l, "sitemap", srcpath));
printf("Created sitemap\n");
}
int main(void) { int main(void) {
Lexicon lex; Lexicon lex;
DIR* d; DIR* d;
@ -633,6 +674,7 @@ int main(void) {
return error("Indexing", "Failed"); return error("Indexing", "Failed");
if (!generate(&lex)) if (!generate(&lex))
return error("Generating", "Failed"); return error("Generating", "Failed");
map(&lex);
inspect(&lex); inspect(&lex);
return 0; return 0;
} }