Apply fixes from trunk.
authorNot Zed <notzed@gmail.com>
Thu, 2 May 2019 23:07:23 +0000 (08:37 +0930)
committerNot Zed <notzed@gmail.com>
Thu, 2 May 2019 23:07:23 +0000 (08:37 +0930)
Fix script paths missing from config.h.in
Makefile fixes
Binary names are configurable
Fix script paths used in posts.

Makefile
blog.c
config.h.in

index 22f13c0..839e8c9 100644 (file)
--- a/Makefile
+++ b/Makefile
 # see config.h for application level config, config.make is created from it
 include config.make
 
+CPPFLAGS=
 CFLAGS=-Og -g -Wall -Wno-unused-function $(DEBUG_CFLAGS)
+LDLIBS=
 
-dist_VERSION=0.3
+dist_VERSION=0.3.99
 
 tools=newpost
-cgis=$(if $(USE_FCGI),blog.fcgi,blog.cgi)
+cgis=$(if $(USE_FCGI),$(BLOGZ_FCGI),$(BLOGZ_CGI))
 
 # these are the intermediate targets, not the sources
 blogz_TEMPLATES=blog-header.c blog-footer.c
 
 blogz_PROGRAMS= $(cgis) $(tools)
 
-blog.fcgi_SRCS=blog.c posts.c $(blogz_TEMPLATES) blogio-fcgi.c fcgi.c
-blog.cgi_SRCS=blog.c posts.c $(blogz_TEMPLATES)  blogio-stdio.c
+$(BLOGZ_FCGI)_SRCS=blog.c posts.c $(blogz_TEMPLATES) blogio-fcgi.c fcgi.c
+$(BLOGZ_CGI)_SRCS=blog.c posts.c $(blogz_TEMPLATES)  blogio-stdio.c
 newpost_SRCS=newpost.c
 
 built_SRCS=$(sort $(foreach prog,$(blogz_PROGRAMS),$($(prog)_SRCS)))
 
-dist_PROGRAMS=blog.cgi blog.fcgi newpost
+dist_PROGRAMS=$(BLOGZ_CGI) $(BLOGZ_FCGI) newpost
 dist_SRCS=$(sort $(foreach prog,$(dist_PROGRAMS),$($(prog)_SRCS)))
 dist_EXTRA=Makefile                                                    \
        README COPYING                                                  \
@@ -72,11 +74,13 @@ blog-%.c: template/blog-%.html maketemplate.pl
 etag.h: posts-tables.h $(blogz_TEMPLATES)
        date --rfc-3339 ns | md5sum  | awk '{ printf "static const char* etag = \"%s\";\n",$$1 }' > etag.h
 
+blog.o: etag.h
+
 clean:
        rm -f posts-tables.h $(blogz_TEMPLATES) config.make
        rm -f *.o
        rm -rf .deps
-       rm -f blog.cgi blog.fcgi
+       rm -f $(BLOGZ_CGI) $(BLOGZ_FCGI)
        rm -rf newpost
 
 $(DB_POST):
diff --git a/blog.c b/blog.c
index 4b787d7..4bea800 100644 (file)
--- a/blog.c
+++ b/blog.c
@@ -283,9 +283,9 @@ static void print_blog(const char *how, const char *path, postid_t *ids, int cou
        for (i=0;i<count;i++) {
                sprintf(file, "%s/%012lx", db, ids[i]);
 
-               post_header("post", ids[i]);
+               post_header(POST_SCRIPT, ids[i]);
                sendpath(file);
-               post_footer("blog", ids[i]);
+               post_footer(BLOG_SCRIPT, ids[i]);
        }
 
        if (newer || older) {
@@ -410,9 +410,9 @@ static void dopost(const char *path, const char *query) {
        page_header(blog_time(id));
        print_tags();
        
-       post_header("blog", id);
+       post_header(BLOG_SCRIPT, id);
        sendpath(file);
-       post_footer("blog", id);
+       post_footer(BLOG_SCRIPT, id);
 
        // TODO: Once I have a proper index this should output the post name
        if (newer || older) {
index 1900202..c4028e8 100644 (file)
 // Whether to create a FastCGI binary
 #define USE_FCGI 1
 
-// Name of main installed binary
-#define blog_bin "blog.fcgi"
-//#define blog_bin "blog"
-// If cgi mode is used, name of command that handles tag urls (softlink to blog_bin)
-#define tag_bin "tag"
-// If cgi mode is used, name of command that handles post urls (softlink to blog_bin)
-#define post_bin "post"
-
+// Name of the backend binary
+#define BLOGZ_FCGI "blogz.fcgi"
+#define BLOGZ_CGI "blogz.cgi"
+
+// The name of the script from cgi SCRIPT_NAME variable.
+// This must match the ScriptAlias key
+#define BLOG_SCRIPT "/blog"
+#define TAG_SCRIPT "/tag"
+#define POST_SCRIPT "/post"