From 9c134385629287d38a624301822b378cdb70d2d9 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 13 Jun 2022 07:53:12 -0600 Subject: [PATCH] add sitemap, update build to play nice with nirvash --- .gitignore | 1 + build.sh | 7 ++++--- config.def.h | 56 +++++++++++++++++++++++++++++++--------------------- main.c | 46 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 83 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 7944fd1..abba12e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ inc/ old/ config.h +map.htm diff --git a/build.sh b/build.sh index 6e0d2d9..3a62ab4 100755 --- a/build.sh +++ b/build.sh @@ -22,7 +22,7 @@ clang-format -i main.c config.h rm -f ./main # 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) cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main @@ -47,10 +47,11 @@ fi ./main exitstatus=$? if [ "${exitstatus}" = "0" ]; then - ./thumbnailer.sh build & + echo "Generating thumbnails in the background" + (./thumbnailer.sh build > /dev/null 2>&1) & fi # Cleanup rm -f ./main -exit ${exitstatus} \ No newline at end of file +exit ${exitstatus} diff --git a/config.def.h b/config.def.h index 3af61d1..2536b72 100644 --- a/config.def.h +++ b/config.def.h @@ -1,25 +1,37 @@ +#define DESC "lair of drkste aka nilix: artist, programmer, philosopher" #define LEXICON_SIZE 1024 -#define TAG_BODY_SIZE 4096 - -#define NAME "nilFM" -#define DOMAIN "https://nilfm.cc" -#define LOGO "blackHole://server" -#define DESC "lair of drkste aka nilix: programmer, artist, philosopher" -#define ABOUT "Derek Stevens <"\ - "nilix@nilfm.cc>
\n"\ - "artist, programmer, philosopher

\n"\ - "verify my signature: signing public key
\n"\ - "send me an encrypted message: encryption public key\n" -#define CONTACT "contact: nilix@nilfm.cc (keys)
\n" -#define FOOTER "visit the nilFM hack lab. \n"\ - "visit me on the Fediverse. \n"\ - "visit the Webring.
\n" -#define LICENSE "CC-BY-NC 4" -#define SITEROOT "../www/" #define MAINCSS "/new.css" +#define FOOTER \ + "visit the nilFM hack "         \
+  "lab. \n" \ + " \n" \ + "
\n" \ + "sitemap
\n" +#define LICENSE \ + "CC-BY-NC 4
\n" \ + "opinions are my own" +#define SITEROOT "../www/" +#define TAG_BODY_SIZE 4096 +#define CONTACT \ + "contact: nilix@nilfm.cc (keys)
\n" \ + "" +#define DOMAIN "https://nilfm.cc" #define FRONTCSS "/front.css" +#define ABOUT \ + "Derek Stevens <nilix@nilfm.cc>
\n" \ + "artist, programmer, philosopher

\n" \ + "verify my signature: signing public " \ + "key
\n" \ + "send me an encrypted message: encryption " \ + "public key\n" \ + "" +#define LOGO "blackHole://server" +#define NAME "nilFM" diff --git a/main.c b/main.c index 9fc2a32..0bba6f4 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,9 @@ -#include +#define _GNU_SOURCE + #include +#include +#include #include -#include #include #include "config.h" @@ -623,6 +625,45 @@ void inspect(Lexicon* l) { 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
    tag because it will easily overflow + * TAG_BODY_SIZE */ + fprintf(siteMap, "
      \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, "
    \n"); + fclose(siteMap); + fclose(build(fopen(dstpath, "w"), l, "sitemap", srcpath)); + printf("Created sitemap\n"); +} + int main(void) { Lexicon lex; DIR* d; @@ -633,6 +674,7 @@ int main(void) { return error("Indexing", "Failed"); if (!generate(&lex)) return error("Generating", "Failed"); + map(&lex); inspect(&lex); return 0; }