From: Wilfried Göesgens Date: Tue, 12 Aug 2008 21:56:39 +0000 (+0000) Subject: * move templates to static/t/ ; made make install target respect this X-Git-Tag: v7.86~2038 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=836c829b448402fabc06b420bd878583a725f608 * move templates to static/t/ ; made make install target respect this * load templates on webcit start into memory --- diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 5042d4f56..0b607b909 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -102,8 +102,8 @@ install-setupbin: install-bin install-wwwdata: - test -d $(DESTDIR)$(WWWDIR)/static.local || mkdir -p $(DESTDIR)$(WWWDIR)/static.local - test -d $(DESTDIR)$(WWWDIR)/static || mkdir -p $(DESTDIR)$(WWWDIR)/static + test -d $(DESTDIR)$(WWWDIR)/static.local/t || mkdir -p $(DESTDIR)$(WWWDIR)/static.local/t + test -d $(DESTDIR)$(WWWDIR)/static/t || mkdir -p $(DESTDIR)$(WWWDIR)/static/t for i in `find static -type f | grep -v .svn`; do \ $(INSTALL) $$i $(DESTDIR)$(WWWDIR)/$$i; \ done diff --git a/webcit/static/beginbox.html b/webcit/static/beginbox.html deleted file mode 100644 index 593fefef9..000000000 --- a/webcit/static/beginbox.html +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
- diff --git a/webcit/static/beginbox.m.html b/webcit/static/beginbox.m.html deleted file mode 100644 index 593fefef9..000000000 --- a/webcit/static/beginbox.m.html +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
- diff --git a/webcit/static/beginbox_nt.html b/webcit/static/beginbox_nt.html deleted file mode 100644 index adb84e34b..000000000 --- a/webcit/static/beginbox_nt.html +++ /dev/null @@ -1,5 +0,0 @@ - -
- -
- diff --git a/webcit/static/chatframeset.html b/webcit/static/chatframeset.html deleted file mode 100644 index 935d79ec0..000000000 --- a/webcit/static/chatframeset.html +++ /dev/null @@ -1,27 +0,0 @@ - - -Real-time chat: <?ROOMNAME> - - - - - - - - - - - - - - - - - -<div align="center"> -This function requires a browser that can support frames. -</div> - - - - diff --git a/webcit/static/endbox.html b/webcit/static/endbox.html deleted file mode 100644 index e04ad1b9c..000000000 --- a/webcit/static/endbox.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/webcit/static/endbox.m.html b/webcit/static/endbox.m.html deleted file mode 100644 index e04ad1b9c..000000000 --- a/webcit/static/endbox.m.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/webcit/static/head.html b/webcit/static/head.html deleted file mode 100644 index 23e43a2d2..000000000 --- a/webcit/static/head.html +++ /dev/null @@ -1,24 +0,0 @@ - - - -<?CURRENT_USER> - <?SERV_HUMANNODE> - - - - - - - - - - - - - - - - - -
- diff --git a/webcit/static/head.m.html b/webcit/static/head.m.html deleted file mode 100644 index 9e85a78b8..000000000 --- a/webcit/static/head.m.html +++ /dev/null @@ -1,14 +0,0 @@ - - - -<?CURRENT_USER> - <?SERV_HUMANNODE> - - - - - - - -
- diff --git a/webcit/static/msgcontrols.m.html b/webcit/static/msgcontrols.m.html deleted file mode 100644 index 9d467578a..000000000 --- a/webcit/static/msgcontrols.m.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -<?CURRENT_USER> - <?SERV_HUMANNODE> - - - - - - - - -
-
- -
-
-
diff --git a/webcit/static/newstartpage.html b/webcit/static/newstartpage.html deleted file mode 100644 index 72247e3d7..000000000 --- a/webcit/static/newstartpage.html +++ /dev/null @@ -1,19 +0,0 @@ - -
-
-

New start page

-  -
-
-
-Your start page has been changed.
-

-
-(Note: this does not change your browser's home page. -It changes the page you begin on when you log on to ). -

- -Back... -
-
- \ No newline at end of file diff --git a/webcit/static/openid_login.html b/webcit/static/openid_login.html deleted file mode 100644 index 9c0f81155..000000000 --- a/webcit/static/openid_login.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -
- -
- -
-
- - -
-
-
- - - - diff --git a/webcit/static/openid_manual_create.html b/webcit/static/openid_manual_create.html deleted file mode 100644 index 7b4807de0..000000000 --- a/webcit/static/openid_manual_create.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -
- - -
-
- - -
-
-
- diff --git a/webcit/static/pushemail.html b/webcit/static/pushemail.html deleted file mode 100644 index bf9213b8c..000000000 --- a/webcit/static/pushemail.html +++ /dev/null @@ -1,41 +0,0 @@ - - -
- -
-
-
- - - -
-
-

If your administrator has enabled the functionality, Citadel can notify a - Funambol server that you haved recieved new email and automatically syncronize - any devices you have with the Funambol client installed.

- -

Alternatively, if the administrator has configured it, Citadel can send a - text message to you when new mail arrives.

-
- -
-

>Notify Funambol server

- -

>Send a text message to... > (Use international format, without any - leading zeros, spaces or hypens, like +61415011501)

- -

>Don't send any notifications

- -

-
-
-
-
-
-
diff --git a/webcit/static/roombanner.html b/webcit/static/roombanner.html deleted file mode 100644 index 2fcfb2edf..000000000 --- a/webcit/static/roombanner.html +++ /dev/null @@ -1,13 +0,0 @@ - -
- -

- -

-
-
    -
  • - -
  • -
- diff --git a/webcit/static/roombanner.m.html b/webcit/static/roombanner.m.html deleted file mode 100644 index a026fa08c..000000000 --- a/webcit/static/roombanner.m.html +++ /dev/null @@ -1,7 +0,0 @@ - -
-

-

-

-
- diff --git a/webcit/static/t/beginbox.html b/webcit/static/t/beginbox.html new file mode 100644 index 000000000..593fefef9 --- /dev/null +++ b/webcit/static/t/beginbox.html @@ -0,0 +1,5 @@ + +
+
+
+ diff --git a/webcit/static/t/beginbox.m.html b/webcit/static/t/beginbox.m.html new file mode 100644 index 000000000..593fefef9 --- /dev/null +++ b/webcit/static/t/beginbox.m.html @@ -0,0 +1,5 @@ + +
+
+
+ diff --git a/webcit/static/t/beginbox_nt.html b/webcit/static/t/beginbox_nt.html new file mode 100644 index 000000000..adb84e34b --- /dev/null +++ b/webcit/static/t/beginbox_nt.html @@ -0,0 +1,5 @@ + +
+ +
+ diff --git a/webcit/static/t/chatframeset.html b/webcit/static/t/chatframeset.html new file mode 100644 index 000000000..935d79ec0 --- /dev/null +++ b/webcit/static/t/chatframeset.html @@ -0,0 +1,27 @@ + + +Real-time chat: <?ROOMNAME> + + + + + + + + + + + + + + + + + +<div align="center"> +This function requires a browser that can support frames. +</div> + + + + diff --git a/webcit/static/t/endbox.html b/webcit/static/t/endbox.html new file mode 100644 index 000000000..e04ad1b9c --- /dev/null +++ b/webcit/static/t/endbox.html @@ -0,0 +1 @@ + diff --git a/webcit/static/t/endbox.m.html b/webcit/static/t/endbox.m.html new file mode 100644 index 000000000..e04ad1b9c --- /dev/null +++ b/webcit/static/t/endbox.m.html @@ -0,0 +1 @@ + diff --git a/webcit/static/t/head.html b/webcit/static/t/head.html new file mode 100644 index 000000000..23e43a2d2 --- /dev/null +++ b/webcit/static/t/head.html @@ -0,0 +1,24 @@ + + + +<?CURRENT_USER> - <?SERV_HUMANNODE> + + + + + + + + + + + + + + + + + +
+ diff --git a/webcit/static/t/head.m.html b/webcit/static/t/head.m.html new file mode 100644 index 000000000..9e85a78b8 --- /dev/null +++ b/webcit/static/t/head.m.html @@ -0,0 +1,14 @@ + + + +<?CURRENT_USER> - <?SERV_HUMANNODE> + + + + + + + +
+ diff --git a/webcit/static/t/msgcontrols.m.html b/webcit/static/t/msgcontrols.m.html new file mode 100644 index 000000000..9d467578a --- /dev/null +++ b/webcit/static/t/msgcontrols.m.html @@ -0,0 +1,20 @@ + + + +<?CURRENT_USER> - <?SERV_HUMANNODE> + + + + + + + + +
+
+ +
+
+
diff --git a/webcit/static/t/newstartpage.html b/webcit/static/t/newstartpage.html new file mode 100644 index 000000000..72247e3d7 --- /dev/null +++ b/webcit/static/t/newstartpage.html @@ -0,0 +1,19 @@ + +
+
+

New start page

+  +
+
+
+Your start page has been changed.
+

+
+(Note: this does not change your browser's home page. +It changes the page you begin on when you log on to ). +

+ +Back... +
+
+ \ No newline at end of file diff --git a/webcit/static/t/openid_login.html b/webcit/static/t/openid_login.html new file mode 100644 index 000000000..9c0f81155 --- /dev/null +++ b/webcit/static/t/openid_login.html @@ -0,0 +1,18 @@ + + + +
+ +
+ +
+
+ + +
+
+
+ + + + diff --git a/webcit/static/t/openid_manual_create.html b/webcit/static/t/openid_manual_create.html new file mode 100644 index 000000000..7b4807de0 --- /dev/null +++ b/webcit/static/t/openid_manual_create.html @@ -0,0 +1,18 @@ + + + +
+ + +
+
+ + +
+
+
+ diff --git a/webcit/static/t/pushemail.html b/webcit/static/t/pushemail.html new file mode 100644 index 000000000..bf9213b8c --- /dev/null +++ b/webcit/static/t/pushemail.html @@ -0,0 +1,41 @@ + + +
+ +
+
+
+ + + +
+
+

If your administrator has enabled the functionality, Citadel can notify a + Funambol server that you haved recieved new email and automatically syncronize + any devices you have with the Funambol client installed.

+ +

Alternatively, if the administrator has configured it, Citadel can send a + text message to you when new mail arrives.

+
+ +
+

>Notify Funambol server

+ +

>Send a text message to... > (Use international format, without any + leading zeros, spaces or hypens, like +61415011501)

+ +

>Don't send any notifications

+ +

+
+
+
+
+
+
diff --git a/webcit/static/t/roombanner.html b/webcit/static/t/roombanner.html new file mode 100644 index 000000000..2fcfb2edf --- /dev/null +++ b/webcit/static/t/roombanner.html @@ -0,0 +1,13 @@ + +
+ +

+ +

+
+
    +
  • + +
  • +
+ diff --git a/webcit/static/t/roombanner.m.html b/webcit/static/t/roombanner.m.html new file mode 100644 index 000000000..a026fa08c --- /dev/null +++ b/webcit/static/t/roombanner.m.html @@ -0,0 +1,7 @@ + +
+

+

+

+
+ diff --git a/webcit/subst.c b/webcit/subst.c index 35c117d47..35dbfb012 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "webcit.h" #include "webserver.h" @@ -488,53 +490,26 @@ void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target) * \brief Display a variable-substituted template * \param templatename template file to load */ -void *load_template(const char *templatename, long len) { - HashList *pCache; - HashList *Static; - HashList *StaticLocal; - StrBuf *flat_filename; - char filename[PATH_MAX]; +void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) +{ int fd; struct stat statbuf; const char *pS, *pE, *pch, *Err; int pos; - struct stat mystat; WCTemplate *NewTemplate; - flat_filename = NewStrBufPlain(templatename, len); - if (WC->is_mobile) { - Static = WirelessTemplateCache; - StaticLocal = WirelessLocalTemplateCache; - StrBufAppendBufPlain(flat_filename, HKEY(".m.html"), 0); - } - else { - Static = TemplateCache; - StaticLocal = LocalTemplateCache; - StrBufAppendBufPlain(flat_filename, HKEY(".html"), 0); - } - - strcpy(filename, static_dirs[1]); - strcat(filename, ChrPtr(flat_filename)); - pCache = StaticLocal; - if (stat(filename, &mystat) == -1) - { - pCache = Static; - strcpy(filename, static_dirs[0]); - strcat(filename, ChrPtr(flat_filename)); - } - - fd = open(filename, O_RDONLY); + fd = open(ChrPtr(filename), O_RDONLY); if (fd <= 0) { wprintf(_("ERROR: could not open template ")); wprintf("'%s' - %s
\n", - (const char*)templatename, strerror(errno)); + ChrPtr(filename), strerror(errno)); return NULL; } if (fstat(fd, &statbuf) == -1) { wprintf(_("ERROR: could not stat template ")); wprintf("'%s' - %s
\n", - (const char*)templatename, strerror(errno)); + ChrPtr(filename), strerror(errno)); return NULL; } @@ -548,7 +523,7 @@ void *load_template(const char *templatename, long len) { FreeWCTemplate(NewTemplate); wprintf(_("ERROR: reading template ")); wprintf("'%s' - %s
\n", - (const char*)templatename, strerror(errno)); + ChrPtr(filename), strerror(errno)); return NULL; } close(fd); @@ -584,7 +559,7 @@ void *load_template(const char *templatename, long len) { PutNewToken(NewTemplate, NewTemlpateSubstitute(pS, pts, pte)); pch ++; } - Put(pCache, filename, strlen(filename), NewTemplate, FreeWCTemplate); + Put(PutThere, ChrPtr(Key), StrLength(Key), NewTemplate, FreeWCTemplate); return NewTemplate; } @@ -609,8 +584,8 @@ void DoTemplate(const char *templatename, long len) if (!GetHash(StaticLocal, templatename, len, &vTmpl) && !GetHash(Static, templatename, len, &vTmpl)) { - vTmpl = load_template(templatename, len); - //////TODO: lock this! + printf ("didn't find %s\n", templatename); + return; } if (vTmpl == NULL) return; @@ -618,6 +593,73 @@ void DoTemplate(const char *templatename, long len) } +int LoadTemplateDir(const char *DirName, HashList *wireless, HashList *big) +{ + StrBuf *FileName; + StrBuf *Tag; + StrBuf *Dir; + DIR *filedir = NULL; + struct dirent *filedir_entry; + int d_namelen; + int d_without_ext; + int IsMobile; + + Dir = NewStrBuf(); + StrBufPrintf(Dir, "%s/t", DirName); + filedir = opendir (ChrPtr(Dir)); + if (filedir == NULL) { + return 0; + } + + FileName = NewStrBuf(); + Tag = NewStrBuf(); + while ((filedir_entry = readdir(filedir))) + { + char *MinorPtr; + char *PStart; +#ifdef _DIRENT_HAVE_D_NAMELEN + d_namelen = filedir_entry->d_namelen; +#else + d_namelen = strlen(filedir_entry->d_name); +#endif + d_without_ext = d_namelen; + while ((d_without_ext > 0) && (filedir_entry->d_name[d_without_ext] != '.')) + d_without_ext --; + if ((d_without_ext == 0) || (d_namelen < 3)) + continue; + + IsMobile = (strstr(filedir_entry->d_name, ".m.html")!= NULL); + PStart = filedir_entry->d_name; + StrBufPrintf(FileName, "%s/t/%s", ChrPtr(Dir), filedir_entry->d_name); + MinorPtr = strchr(filedir_entry->d_name, '.'); + if (MinorPtr != NULL) + *MinorPtr = '\0'; + StrBufPlain(Tag, filedir_entry->d_name, MinorPtr - filedir_entry->d_name); + + + printf("%s %d %s\n",ChrPtr(FileName), IsMobile, ChrPtr(Tag)); + load_template(FileName, Tag, (IsMobile)?wireless:big); + } + closedir(filedir); + FreeStrBuf(&FileName); + FreeStrBuf(&Tag); + FreeStrBuf(&Dir); + return 1; +} + +void InitTemplateCache(void) +{ + + LoadTemplateDir(static_dirs[0], + WirelessTemplateCache, + TemplateCache); + LoadTemplateDir(static_dirs[1], + WirelessLocalTemplateCache, + LocalTemplateCache); + + +} + void InitModule_SUBST (void) diff --git a/webcit/webserver.c b/webcit/webserver.c index b6cdd9960..6a0c80abf 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -587,6 +587,7 @@ void spawn_another_worker_thread() const char foobuf[32]; const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;} #endif +void InitTemplateCache(void); /* * \brief Here's where it all begins. @@ -621,6 +622,7 @@ int main(int argc, char **argv) WirelessLocalTemplateCache = NewHash(1, NULL); TemplateCache = NewHash(1, NULL); LocalTemplateCache = NewHash(1, NULL); + InitTemplateCache(); initialise_modules();