чување 1ad4667aa19a9026a47e8738616b34ca72ea642f
родитељ a510b0c889310a604ceb397b9e3372d7f175811d
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Mon, 22 Feb 2021 16:08:15 +0100
Added feed and feed-desc YAML variables
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 3, додавања: 17(+), брисања: 3(-)
diff --git a/index.html b/index.html
@@ -152,7 +152,7 @@ this program. If not, see <<a href="https://www.gnu.org/licenses">https://www
<div id="git-log">
Previous commit:
-index.slw 39035ff 2021-02-15 21:33:47 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
+index.slw a510b0c 2021-02-17 14:58:10 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
</div><!--git-log-->
diff --git a/slweb.1.in b/slweb.1.in
@@ -752,13 +752,19 @@ permalink will have \fCblog/2020/august\fP.
.
.IP \[bu]
.BR favicon-url .
-if present, this
+If present, this
.SM URL
will be used as a favicon
.SM URL
instead of the default, \fC/favicon.ico\fP.
.
.IP \[bu]
+.BR feed ", " feed-desc .
+If both are present, contents of those variables will be added as \fIhref\fP and
+\fItitle\fP attributes (respectively) to the \fC<link rel="alternate"
+type="application/rss+xml">\fP tag in the page's \fC<head>\fP.
+.
+.IP \[bu]
.BR header-text .
The contents of this variable will be added to the start of the output body
(inside a \fC<header>\fP tag if it is set), surrounded by \fC<p></p>\fP.
diff --git a/slweb.c b/slweb.c
@@ -49,7 +49,7 @@ static long csv_iter = 0;
static ULONG state = ST_NONE;
#define CHECKEXITNOMEM(ptr) { if (!ptr) exit(error(ENOMEM, \
- (uint8_t*)"Memory allocation failed (out of memory?)\n")); }
+ (uint8_t*)"Memory allocation failed (out of memory?)")); }
#define CALLOC(ptr, ptrtype, nmemb) { ptr = calloc(nmemb, sizeof(ptrtype)); \
CHECKEXITNOMEM(ptr) }
@@ -1797,6 +1797,9 @@ begin_html_and_head(FILE* output)
uint8_t* favicon_url = get_value(vars, vars_count, (uint8_t*)"favicon-url", NULL);
uint8_t* meta = get_value(vars, vars_count, (uint8_t*)"meta", NULL);
+ uint8_t* feed = get_value(vars, vars_count, (uint8_t*)"feed", NULL);
+ uint8_t* feed_desc = get_value(vars, vars_count, (uint8_t*)"feed-desc", NULL);
+
print_output(output, "<!DOCTYPE html>\n"
"<html lang=\"%s\">\n"
"<head>\n"
@@ -1827,6 +1830,11 @@ begin_html_and_head(FILE* output)
print_output(output, "<link rel=\"canonical\" href=\"%s\" />\n",
(char*)canonical);
+ if (feed && *feed && feed_desc && *feed_desc)
+ print_output(output, "<link rel=\"alternate\""
+ " type=\"application/rss+xml\" href=\"%s\" title=\"%s\" />\n",
+ (char*)feed, (char*)feed_desc);
+
if (site_desc && *site_desc)
print_output(output, "<meta name=\"description\" content=\"%s\" />\n",
(char*)site_desc);