changeset 1032:c0d131c337eb

combine template and web dir config knobs into a single theme setting Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 24 Jul 2020 14:57:27 -0400
parents 31c9d3b5007a
children 29e9acfeebeb
files README config.c config.cmake config.h.in lisplint.c render.c samples/full.lisp static.c
diffstat 8 files changed, 22 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/README	Fri Jul 24 14:21:47 2020 -0400
+++ b/README	Fri Jul 24 14:57:27 2020 -0400
@@ -25,7 +25,7 @@
 				  considered a spam
 
 	DEFAULT_DATA_DIR	- default path to the data directory
-	DEFAULT_WEB_DIR		- default path to the web directory
+	DEFAULT_THEME_DIR	- default path to the theme directory
 
 	VAR_MAX_SCOPES		- maximum number of internal scopes
 	VAR_NAME_MAXLEN		- maximum length of a variable name
--- a/config.c	Fri Jul 24 14:21:47 2020 -0400
+++ b/config.c	Fri Jul 24 14:57:27 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -145,9 +145,8 @@
 	config_load_u64(lv, CONFIG_COMMENT_CAPTCHA_B, &config.comment_captcha_b,
 			rand());
 	config_load_str(lv, CONFIG_DATA_DIR, &config.data_dir, DEFAULT_DATA_DIR);
-	config_load_str(lv, CONFIG_WEB_DIR, &config.web_dir, DEFAULT_WEB_DIR);
-	config_load_str(lv, CONFIG_TEMPLATE_DIR, &config.template_dir,
-			DEFAULT_TEMPLATE_DIR);
+	config_load_str(lv, CONFIG_THEME_DIR, &config.theme_dir,
+			DEFAULT_THEME_DIR);
 	config_load_url(lv, CONFIG_BASE_URL, &config.base_url);
 	config_load_url(lv, CONFIG_BUG_BASE_URL, &config.bug_base_url);
 	config_load_url(lv, CONFIG_WIKI_BASE_URL, &config.wiki_base_url);
@@ -174,8 +173,7 @@
 	DBG("config.comment_captcha_a = %"PRIu64, config.comment_captcha_a);
 	DBG("config.comment_captcha_b = %"PRIu64, config.comment_captcha_b);
 	DBG("config.data_dir = %s", str_cstr(config.data_dir));
-	DBG("config.web_dir = %s", str_cstr(config.web_dir));
-	DBG("config.template_dir = %s", str_cstr(config.template_dir));
+	DBG("config.theme_dir = %s", str_cstr(config.theme_dir));
 	DBG("config.base_url = %s", str_cstr(config.base_url));
 	DBG("config.wiki_base_url = %s", str_cstr(config.wiki_base_url));
 	DBG("config.bug_base_url = %s", str_cstr(config.bug_base_url));
--- a/config.cmake	Fri Jul 24 14:21:47 2020 -0400
+++ b/config.cmake	Fri Jul 24 14:57:27 2020 -0400
@@ -45,8 +45,7 @@
 set_default(DEFAULT_COMMENT_MIN_THINK	10)	# 10 secs min think time
 
 set_default(DEFAULT_DATA_DIR		"./data")
-set_default(DEFAULT_WEB_DIR		"./theme/static")
-set_default(DEFAULT_TEMPLATE_DIR	"./theme")
+set_default(DEFAULT_THEME_DIR		"./theme")
 
 set_default(BASE_URL			"http://blahg.josefsipek.net")
 set_default(BUG_BASE_URL		"http://bugs.31bits.net")
--- a/config.h.in	Fri Jul 24 14:21:47 2020 -0400
+++ b/config.h.in	Fri Jul 24 14:57:27 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2012-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -35,8 +35,7 @@
 #cmakedefine DEFAULT_COMMENT_MIN_THINK	${DEFAULT_COMMENT_MIN_THINK}
 
 #cmakedefine DEFAULT_DATA_DIR		"${DEFAULT_DATA_DIR}"
-#cmakedefine DEFAULT_WEB_DIR		"${DEFAULT_WEB_DIR}"
-#cmakedefine DEFAULT_TEMPLATE_DIR	"${DEFAULT_TEMPLATE_DIR}"
+#cmakedefine DEFAULT_THEME_DIR		"${DEFAULT_THEME_DIR}"
 
 #cmakedefine VAR_MAX_SCOPES		${VAR_MAX_SCOPES}
 #cmakedefine VAR_NAME_MAXLEN		${VAR_NAME_MAXLEN}
@@ -61,8 +60,7 @@
 #define CONFIG_COMMENT_CAPTCHA_A	"comment-captcha-a"
 #define CONFIG_COMMENT_CAPTCHA_B	"comment-captcha-b"
 #define CONFIG_DATA_DIR			"data-dir"
-#define CONFIG_WEB_DIR			"web-dir"
-#define CONFIG_TEMPLATE_DIR		"template-dir"
+#define CONFIG_THEME_DIR		"theme-dir"
 #define CONFIG_BASE_URL			"base-url"
 #define CONFIG_BUG_BASE_URL		"bug-base-url"
 #define CONFIG_WIKI_BASE_URL		"wiki-base-url"
@@ -89,8 +87,7 @@
 	uint64_t comment_captcha_a;
 	uint64_t comment_captcha_b;
 	struct str *data_dir;
-	struct str *web_dir;
-	struct str *template_dir;
+	struct str *theme_dir;
 	struct str *base_url;
 	struct str *bug_base_url;
 	struct str *wiki_base_url;
--- a/lisplint.c	Fri Jul 24 14:21:47 2020 -0400
+++ b/lisplint.c	Fri Jul 24 14:57:27 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -139,8 +139,7 @@
 	ret = check_type(fname, lv, CONFIG_COMMENT_CAPTCHA_A, VT_INT, false) && ret;
 	ret = check_type(fname, lv, CONFIG_COMMENT_CAPTCHA_B, VT_INT, false) && ret;
 	ret = check_type(fname, lv, CONFIG_DATA_DIR, VT_STR, false) && ret;
-	ret = check_type(fname, lv, CONFIG_WEB_DIR, VT_STR, false) && ret;
-	ret = check_type(fname, lv, CONFIG_TEMPLATE_DIR, VT_STR, false) && ret;
+	ret = check_type(fname, lv, CONFIG_THEME_DIR, VT_STR, false) && ret;
 	ret = check_type(fname, lv, CONFIG_BASE_URL, VT_STR, false) && ret;
 	ret = check_type(fname, lv, CONFIG_BUG_BASE_URL, VT_STR, false) && ret;
 	ret = check_type(fname, lv, CONFIG_WIKI_BASE_URL, VT_STR, false) && ret;
--- a/render.c	Fri Jul 24 14:21:47 2020 -0400
+++ b/render.c	Fri Jul 24 14:57:27 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2013-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -66,7 +66,7 @@
 	char *out;
 
 	snprintf(path, sizeof(path), "%s/%s/%s.tmpl",
-		 str_cstr(config.template_dir), str_cstr(req->fmt), tmpl);
+		 str_cstr(config.theme_dir), str_cstr(req->fmt), tmpl);
 
 	raw = file_cache_get(path, NULL);
 	if (IS_ERR(raw))
--- a/samples/full.lisp	Fri Jul 24 14:21:47 2020 -0400
+++ b/samples/full.lisp	Fri Jul 24 14:57:27 2020 -0400
@@ -25,12 +25,8 @@
  ; contains a directory for each post.
  (data-dir . "/blahg/data")
 
- ; The location of the web directory with static files.  Default is
- ; "./theme/static".
- (web-dir . "/blahg/theme/static")
-
- ; The location of the templates directory.  Default is "./theme".
- (template-dir . "/blahg/theme")
+ ; The location of the theme directory.  Default is "./theme".
+ (theme-dir . "/blahg/theme")
 
  ; The base URL for the blahg.  This is the URL for the index page.
  (base-url . "http://blahg.example.com")
--- a/static.c	Fri Jul 24 14:21:47 2020 -0400
+++ b/static.c	Fri Jul 24 14:57:27 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -87,13 +87,15 @@
 	/* SCGI_DOCUMENT_URI comes with a leading /, remove it. */
 	uri++;
 
-	snprintf(path, sizeof(path), "%s/%s", str_cstr(config.web_dir), uri);
+	snprintf(path, sizeof(path), "%s/static/%s", str_cstr(config.theme_dir),
+		 uri);
 
 	str_putref(uri_str);
 
 	/*
-	 * We assume that the URI is relative to the web dir.  Since we
-	 * have a whitelist of allowed URIs, whe should be safe here.
+	 * We assume that the URI is relative to the theme's static subdir.
+	 * Since we have a whitelist of allowed URIs, whe should be safe
+	 * here.
 	 */
 	req->scgi->response.body = read_file_len(path,
 						 &req->scgi->response.bodylen);