diff options
Diffstat (limited to 'skull.c')
-rw-r--r-- | skull.c | 82 |
1 files changed, 82 insertions, 0 deletions
@@ -0,0 +1,82 @@ +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +#include "sm.h" +#include "util.h" + +extern char kcontentdir[]; +extern char kskullexport[]; + +static void skullexport(Document **, int); + +Plugin skull = {"skull", skullexport, NULL, 0}; + +static void +skullexport(Document **doc, int ndoc) +{ + char path[512], outpath[512]; + FILE *outf; + int i, j; + + char title[128], creat[64], mod[64]; + char *header[] = { "\ +<!DOCTYPE html>\n\ +<html>\n\ + <title>", title, "</title>\n\ + <meta charset=\"utf-8\"/>\n\ + <style>\n\ + h1, nav { text-align: center }\n\ + p { margin-left: 6%; margin-right: 6% }\n\ + </style>\n\ +</head>\n\ +<body bgcolor=\"#000000\" background=\"/pix/crackblk.jpg\" text=\"#eeeeee\" \ +link=\"orange\" alink=\"red\" vlink=\"red\">\n\ + <a href=\"https://previousplan.org\"><img src=\"/pix/previousplan-button.gif\" alt=\"PreviousPlan! web button\" title=\"PreviousPlan! web button\"></a>\n\ + <nav>\n\ + <img src=\"/pix/s-spin.gif\"/>\n\ + <i><font size=\"6\" color=\"gold\">Previous Plan!</font></i>\n\ + -\n\ + <a href=\"/about.html\">Home</a>\n\ + -\n\ + <a href=\"/posts.html\">Posts</a>\n\ + -\n\ + <a href=\"/rss.xml\">RSS</a>\n\ + -\n\ + <a href=\"/donate.html\">Donate</a>\n\ + <img src=\"/pix/s-spin.gif\"/>\n\ + </nav>\n\ +" }; + + char *footer[] = { "\ + <hr/>\n\ + <p>Written: ", creat, ", Last modified: ", mod, "</p>\n\ + <img src=\"pix/s-mail.gif\" alt=\"EMAIL\"/>\n\ + <p>Webmaster email: <a \ +href=\"mailto:erikk@previousplan.org\">erikk@previousplan.org</a> \ +<a href=\"/erikk.asc\">(PGP key)</a></p>\n\ +</body>\n\ +</html>\n\ +" }; + + for (i = 0; i < ndoc; i++) { + snprintf(path, sizeof(path), "%s/%s", kcontentdir, doc[i]->filename); + snprintf(outpath, sizeof(outpath), "%s/%s", kskullexport, doc[i]->filename); + + if ((outf = fopen(outpath, "w")) == NULL) { + fprintf(stderr, "%s: %s\n", outpath, strerror(errno)); + continue; + } + + my_strlcpy(title, doc[i]->title, sizeof(title)); + strftime(creat, sizeof(creat), "%a, %Y %b %d", gmtime(&doc[i]->creat)); + strftime(mod, sizeof(mod), "%a, %Y %b %d", gmtime(&doc[i]->mod)); + for (j = 0; j < LEN(header); j++) + xfputs(header[j], outf); + cat(path, outf); + for (j = 0; j < LEN(footer); j++) + xfputs(footer[j], outf); + fclose(outf); + } +} |