* calculate dirs right
authorWilfried Göesgens <willi@citadel.org>
Tue, 2 Oct 2007 23:13:23 +0000 (23:13 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 2 Oct 2007 23:13:23 +0000 (23:13 +0000)
* use the static.local / static aproach in our templates section too.

webcit/Makefile.in
webcit/configure.ac
webcit/subst.c
webcit/webserver.c

index ef6465b1f918a315cc69be6e8b0c66659a6fe7a6..1c31348aae9e8960a1848e5a1245ae314f59e729 100644 (file)
@@ -17,9 +17,8 @@ top_builddir=`pwd`
 LIB_SUBDIRS=
 PROG_SUBDIRS=@PROG_SUBDIRS@
 SUBDIRS=$(LIB_SUBDIRS) $(PROG_SUBDIRS) 
-#LOCALEDIR=@LOCALEDIR@
-#WWWDIR=@WWWDIR@
-#EDITORDIR=@EDITORDIR@
+LOCALEDIR=@LOCALEDIR@
+WWWDIR=@WWWDIR@
 
 # End of configuration section
 
@@ -73,18 +72,6 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \
 .cpp.o:
        $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) $<
 
-#.c.o:
-#      $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) \
-#              -DWEBCITDIR=\"$(WWWDIR)\" \
-#              -DLOCALEDIR=\"$(LOCALEDIR)\" \
-#              -DEDITORDIR=\"$(EDITORDIR)\" $<
-#
-#.cpp.o:
-#      $(CC) $(CFLAGS) $(DEFS) -c $(PTHREAD_DEFS) \
-#              -DWEBCITDIR=\"$(WWWDIR)\" \
-#              -DLOCALEDIR=\"$(LOCALEDIR)\"  \
-#              -DEDITORDIR=\"$(EDITORDIR)\"$<
-#
 Makefile: $(srcdir)/Makefile.in config.status
        CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
 
index d5335eb4d3ce82aae53067963718c232cbac6e7d..f0f968738e79d9120e140a32288d5ab5748d23b8 100644 (file)
@@ -412,6 +412,8 @@ AC_ARG_WITH(localedir,
                        ]
 )
 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
+LOCALEDIR=$localedir
+AC_SUBST(LOCALEDIR)
 
 dnl Checks where to put our templates
 AC_ARG_WITH(wwwdir, 
@@ -422,7 +424,8 @@ AC_ARG_WITH(wwwdir,
                        ]
 )
 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
-
+WWWDIR=$wwwdir
+AC_SUBST(WWWDIR)
 
 
 dnl Checks for the run-dir for the sockets
index 2cccbc1478a46f19873954fa4268eee3364a46b9..77c8a370d51cc8a1e122e6a956e88c4b408cb5b7 100644 (file)
@@ -8,8 +8,12 @@
 
 /*@{*/
 
-#include "webcit.h"
+#include "sysdep.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
+#include "webcit.h"
 
 /**
  * \brief Clear out the list of substitution variables local to this session
@@ -190,27 +194,36 @@ void print_value_of(char *keyname) {
        }
 }
 
-
+extern char *static_dirs[PATH_MAX];  /**< Disk representation */
 
 /**
  * \brief Display a variable-substituted template
  * \param templatename template file to load
  */
 void do_template(void *templatename) {
+       char flat_filename[PATH_MAX];
        char filename[PATH_MAX];
        FILE *fp;
        char inbuf[1024];
        char outbuf[sizeof inbuf];
        char key[sizeof inbuf];
        int i, pos;
+       struct stat mystat;
 
-       strcpy(filename, "static/");
-       strcat(filename, templatename);
+       strcpy(flat_filename, templatename);
        if (WC->is_wap)
-               strcat(filename, ".wml");
+               strcat(flat_filename, ".wml");
        else
-               strcat(filename, ".html");
+               strcat(flat_filename, ".html");
        
+       strcpy(filename, static_dirs[1]);
+       strcat(filename, flat_filename);
+       if (stat(filename, &mystat) == -1)
+       {
+               strcpy(filename, static_dirs[0]);
+               strcat(filename, flat_filename);
+       }
+
        fp = fopen(filename, "r");
        if (fp == NULL) {
                wprintf(_("ERROR: could not open template "));
index d280ac8feed7ddf40b33c929a13be7b7b69eb7e6..d67fcc956dc4272fa26d7d7fbe5db4b5077674ab 100644 (file)
@@ -772,9 +772,9 @@ int main(int argc, char **argv)
                         (dirbuffer[0]!='\0')?"/":"");
        basedir=RUNDIR;
        COMPUTE_DIRECTORY(socket_dir);
-       basedir=DATADIR "/static";
+       basedir=WWWDIR "/static";
        COMPUTE_DIRECTORY(static_dir);
-       basedir=DATADIR "/static.local";
+       basedir=WWWDIR "/static.local";
        COMPUTE_DIRECTORY(static_local_dir);
 
        snprintf(file_crpt_file_key,