summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h9
-rw-r--r--makefile2
-rw-r--r--pages.c13
-rw-r--r--pages.h4
4 files changed, 15 insertions, 13 deletions
diff --git a/config.h b/config.h
index bcd15c1..fd3e6dd 100644
--- a/config.h
+++ b/config.h
@@ -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
diff --git a/makefile b/makefile
index 1530317..898378e 100644
--- a/makefile
+++ b/makefile
@@ -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
diff --git a/pages.c b/pages.c
index 3498e20..1e5d152 100644
--- a/pages.c
+++ b/pages.c
@@ -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;
}
diff --git a/pages.h b/pages.h
index 5c79db5..bce30d6 100644
--- a/pages.h
+++ b/pages.h
@@ -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);