summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile1
-rw-r--r--pages.c24
-rw-r--r--pages.h2
-rw-r--r--template.txt3
4 files changed, 27 insertions, 3 deletions
diff --git a/makefile b/makefile
index c818ff3..76b4a8b 100644
--- a/makefile
+++ b/makefile
@@ -21,5 +21,6 @@ $(TARGET): $(OBJECTS)
clean:
-rm -f *.o
+ -rm 0f *.tmp
-rm -f $(TARGET)
diff --git a/pages.c b/pages.c
index 5afd8c3..b905290 100644
--- a/pages.c
+++ b/pages.c
@@ -757,6 +757,23 @@ char
str[idx-1] = '\0';
return str;
}
+
+char
+*rfc822date(char *date, size_t size)
+{
+ /*
+ * convert a dumb d/m/y date string into something rfc822 compliant
+ * absolutely not portable
+ */
+ struct tm tm;
+ char buff[size];
+ strptime(date, "%d/%m/%Y", &tm);
+ strftime(buff, size, "%d %b %Y", &tm);
+ strncpy(date, buff, size);
+ snprintf(date, size, "%s 00:00:00 GMT", buff);
+ return date;
+}
+
int
writerss(FILE *out, int post)
{
@@ -811,6 +828,7 @@ writerss(FILE *out, int post)
striphtml(date, strlen(date));
striphtml(description, strlen(description));
strcat(description, " ...");
+ rfc822date(date, 512);
//printf("title is: %s date is: %s: desc is: %s\n", title, date, description);
snprintf(item, 4096, "<item>\n\t<title>%s</title>\n\t<pubDate>%s</pubDate>\n\t<link>https://danieljon.es/posts/direct/%d</link>\n\t<guid>https://danieljon.es/posts/direct/%d</guid>\n\t<description>%s</description>\n</item>\n", title, date, post, post, description);
@@ -853,13 +871,15 @@ generaterss(const int *posts, size_t totalposts)
struct fileorstring src = {"rss.tmp", NULL};
+ /* we need to flush the file, so just close it */
+ fclose(tmp);
+
if (!replaceinpage(rss_output, rss_string, &src))
{
fprintf(stderr, "unable to replace %s in %s, unrecoverable failure\n", rss_string, rss_output);
return 0;
}
- fclose(tmp);
- //remove("rss.tmp");
+ remove("rss.tmp");
return 1;
}
diff --git a/pages.h b/pages.h
index 09c1abe..d20ea83 100644
--- a/pages.h
+++ b/pages.h
@@ -15,6 +15,7 @@
#ifndef PAGES_H
#define PAGES_H
+#define _XOPEN_SOURCE
#include <stdio.h>
#include <string.h>
@@ -49,6 +50,7 @@ int writeposts(const int *posts, size_t totalposts, const char *outfile, int cur
int generaterss(const int *posts, size_t totalposts);
int writerss(FILE *out, int post);
char *striphtml(char *str, size_t size);
+char *rfc822date(char *date, size_t size);
/* generators (to be put into the pages array) */
int frontpage(int flags);
diff --git a/template.txt b/template.txt
index 6f14b2d..8595c77 100644
--- a/template.txt
+++ b/template.txt
@@ -46,7 +46,8 @@ div.cover{display:inline-block; vertical-align: top; padding-top: 28px; padding-
{CONTENT}
</div>
<!-- <br><br> <div class="middle"> <img src="https://danieljon.es/linuxfreak.png"> <br> <a id="gentag" href="https://gitlab.com/ubunchu-translators/ubunchu">source</a> </div> -->
-<br><br> <div class="middle"> <a href="https://www.fsf.org/"><img src="https://danieljon.es/media/fsf_member.png" alt="FSF member"></a></div>
+<br><br><div class="middle"> <a href="https://danieljon.es/posts/posts.rss"><img src="https://danieljon.es/media/rss.gif" alt="RSS feed"></a></div>
+<div class="middle"> <a href="https://www.fsf.org/"><img src="https://danieljon.es/media/fsf_member.png" alt="FSF member"></a></div>
<br> <div id="gentag">page generated {TIME} using <a href="https://git.danieljon.es/websitegenerator/">websitegenerator in C</a></div>
<a href="https://danieljon.es/cirno"><img src="https://danieljon.es/media/do_you_want_to_talk.png" style="z-index: -1; position: fixed; right: 0%; bottom: -0px; width: 10%; height: auto;"></a>
</body>