diff options
author | Daniel Jones <admin@danieljon.es> | 2020-02-09 23:00:13 +1030 |
---|---|---|
committer | Daniel Jones <admin@danieljon.es> | 2020-02-09 23:00:13 +1030 |
commit | 09db8e9120d948edc2596cae82019de1e3b0c566 (patch) | |
tree | 74077638ff0f6e8c84f1517be58f1b8779cefc73 | |
parent | fd7d4c157e1de0d9573ab5b3c5a062db193ba917 (diff) | |
download | websitegenerator-09db8e9120d948edc2596cae82019de1e3b0c566.tar.gz websitegenerator-09db8e9120d948edc2596cae82019de1e3b0c566.zip |
add flag for images in RSS feed
-rw-r--r-- | config.h | 9 | ||||
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | pages.c | 13 | ||||
-rw-r--r-- | pages.h | 4 |
4 files changed, 15 insertions, 13 deletions
@@ -20,9 +20,10 @@ enum flag { - NONE = 0, - RSS = 1, - PINNED = 2, + NONE = 1<<0, + RSS = 1<<1, + RSSIMAGES = 1<<2, + PINNED = 1<<3, }; struct page @@ -116,7 +117,7 @@ static const struct page pages[] = { {opinions_animepage, NONE}, {opinions_everythingpage, NONE}, {portfoliopage, NONE}, - {postspage, RSS|PINNED}, /* flags: RSS feed, pinned posts */ + {postspage, RSS|RSSIMAGES|PINNED}, /* flags: RSS feed, RSS images, pinned posts */ }; #endif @@ -1,7 +1,7 @@ TARGET = generate LIBS = CC = gcc -CFLAGS = -std=c99 -g -Wall -Werror -Wno-unused-variable +CFLAGS = -std=c99 -g -Wall -Werror -Wno-unused-variable .PHONY: default all clean @@ -659,6 +659,7 @@ generatepinned(char *buff, size_t size) strncat(buff, "<br><br>\n<div class=\"pinned\">\nPinned posts:\n", 60); + //TODO: check we fit into the buffer // pray we fit for (int i = 0; i < sizeof(pinned)/sizeof(pinned[0]); i++) { @@ -775,7 +776,7 @@ postspage(int flags) /* generate rss feed if required */ if (flags & RSS) { - generaterss(posts, totalposts); + generaterss(posts, totalposts, flags); } return 1; } @@ -868,7 +869,7 @@ char } int -writerss(FILE *out, int post) +writerss(FILE *out, int post, int flags) { /* * create rss item using 'post_content'/'posts'.txt into FILE 'out' @@ -918,9 +919,9 @@ writerss(FILE *out, int post) strncpy(description, line, 100); } - /* try to find images */ + /* try to find images if flag set */ char *img; - if ((img = strstr(line, "<img"))) + if ((flags & RSSIMAGES) && (img = strstr(line, "<img"))) { hasimg = 1; getimage(img, image, 1024); @@ -949,7 +950,7 @@ writerss(FILE *out, int post) } int -generaterss(const int *posts, size_t totalposts) +generaterss(const int *posts, size_t totalposts, int flags) { /* * generate an rss feed for our blog/posts @@ -976,7 +977,7 @@ generaterss(const int *posts, size_t totalposts) towrite--; for (i = 1; i <= towrite; i++) { - if (!writerss(tmp, (totalposts - posts[i]))) + if (!writerss(tmp, (totalposts - posts[i]), flags)) return 0; } @@ -48,8 +48,8 @@ char *generatepagebar(char *bar, size_t size, const int *posts, size_t totalpost int generatepostpages(const int *posts, size_t totalposts, int pagecount, int flags); int writeposts(const int *posts, size_t totalposts, const char *outfile, int currentpage, int pagecount, int flags); int generatepinned(char *buff, size_t size); -int generaterss(const int *posts, size_t totalposts); -int writerss(FILE *out, int post); +int generaterss(const int *posts, size_t totalposts, int flags); +int writerss(FILE *out, int post, int flags); char *striphtml(char *str, size_t size); char *rfc822date(char *date, size_t size); char *getimage(const char *line, char *buff, size_t size); |