From 8aec1a788f381cbe18eafc729a89b303bec05944 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 23 Nov 2008 23:21:18 +0000 Subject: [PATCH] * add transitional beginboxx template and move some places to the new syntax * finish preferences settings via templates * add new settings to pre-select from/name/handle in case of email / posting into forums * find some more missing error messages in the templating... --- webcit/auth.c | 8 +- webcit/graphics.c | 7 +- webcit/inetconf.c | 2 +- webcit/listsub.c | 2 +- webcit/mainmenu.c | 2 +- webcit/openid.c | 2 +- webcit/preferences.c | 6 +- webcit/roomops.c | 25 ++-- webcit/sieve.c | 6 +- webcit/static/t/beginbox.html | 2 +- webcit/static/t/beginboxx.html | 5 + webcit/static/t/beginboxx.m.html | 5 + webcit/static/t/box_preferences.html | 134 +++++++++++++++--- webcit/static/t/edit_message.html | 12 +- webcit/static/t/menu_your_info.html | 2 +- .../t/section_msg_sender_from_select.html | 2 +- .../t/section_msg_sender_name_select.html | 2 +- webcit/subst.c | 28 +++- webcit/summary.c | 2 +- webcit/sysmsgs.c | 2 +- webcit/vcard_edit.c | 2 +- webcit/webcit.c | 2 +- webcit/webcit.h | 1 + 23 files changed, 202 insertions(+), 59 deletions(-) create mode 100644 webcit/static/t/beginboxx.html create mode 100644 webcit/static/t/beginboxx.m.html diff --git a/webcit/auth.c b/webcit/auth.c index 0c4e76b51..73a39ba62 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -792,11 +792,13 @@ void display_reg(int during_login) void display_changepw(void) { char buf[SIZ]; - + StrBuf *Buf; output_headers(1, 1, 1, 0, 0, 0); - svput("BOXTITLE", WCS_STRING, _("Change your password")); - do_template("beginbox", NULL); + Buf = NewStrBufPlain(_("Change your password"), -1); + DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF); + + FreeStrBuf(&Buf); if (!IsEmptyStr(WC->ImportantMessage)) { wprintf("" diff --git a/webcit/graphics.c b/webcit/graphics.c index 601b4d0a4..add3b0021 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -22,10 +22,13 @@ void display_graphics_upload(char *description, char *filename, char *uplurl) } output_headers(1, 1, 0, 0, 0, 0); + StrBuf *Buf; output_headers(1, 1, 1, 0, 0, 0); - svput("BOXTITLE", WCS_STRING, _("Image upload")); - do_template("beginbox", NULL); + Buf = NewStrBufPlain(_("Image upload"), -1); + DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF); + + FreeStrBuf(&Buf); wprintf("
\n", uplurl); diff --git a/webcit/inetconf.c b/webcit/inetconf.c index c025792b0..191f90e76 100644 --- a/webcit/inetconf.c +++ b/webcit/inetconf.c @@ -110,7 +110,7 @@ void display_inetconf(void) wprintf(""); } svput("BOXTITLE", WCS_STRING, ic_boxtitle[which]); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf(""); escputs(ic_desc[which]); wprintf("
"); diff --git a/webcit/listsub.c b/webcit/listsub.c index 604d3d47b..0f2fd8e86 100644 --- a/webcit/listsub.c +++ b/webcit/listsub.c @@ -49,7 +49,7 @@ void do_listsub(void) wprintf("
"); svput("BOXTITLE", WCS_STRING, _("List subscribe/unsubscribe")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf("

"); /* diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 4c1943817..aa2e07396 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -275,7 +275,7 @@ void do_generic(void) serv_getln(buf, sizeof buf); svput("BOXTITLE", WCS_STRING, _("Server command results")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf("
Command:"); escputs(bstr("g_cmd")); diff --git a/webcit/openid.c b/webcit/openid.c index 2d905bd50..464f3c912 100644 --- a/webcit/openid.c +++ b/webcit/openid.c @@ -18,7 +18,7 @@ void display_openids(void) wprintf("
"); svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); if (serv_info.serv_supports_openid) { diff --git a/webcit/preferences.c b/webcit/preferences.c index c839d5738..800968875 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -656,6 +656,7 @@ void set_preferences(void) set_preference("emptyfloors", NewStrBufPlain(bstr("emptyfloors"), -1), 0); set_preference("defaultfrom", NewStrBufDup(sbstr("defaultfrom")), 0); set_preference("defaultname", NewStrBufDup(sbstr("defaultname")), 0); + set_preference("defaulthandle", NewStrBufDup(sbstr("defaulthandle")), 0); buf = NewStrBufPlain(bstr("signature"), -1); @@ -741,6 +742,7 @@ HashList *GetGVEAHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void * } else { i = snprintf(N, sizeof(N), "%d", n); + StrBufTrim(Rcp); Put(List, N, i, Rcp, HFreeStrBuf); Rcp = NewStrBuf(); } @@ -777,6 +779,7 @@ HashList *GetGVSNHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void * } else { i = snprintf(N, sizeof(N), "%d", n); + StrBufTrim(Rcp); Put(List, N, i, Rcp, HFreeStrBuf); Rcp = NewStrBuf(); } @@ -811,8 +814,7 @@ InitModule_PREFERENCES RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO); RegisterPreference("defaultfrom", _("Prefered Email Address"), PRF_STRING); RegisterPreference("defaultname", _("Prefered Email Sendername"), PRF_STRING); - - + RegisterPreference("defaulthandle", _("Prefered Name for posting messages"), PRF_STRING); RegisterNamespace("PREF:VALUE", 1, 2, tmplput_CFG_Value, CTX_NONE); diff --git a/webcit/roomops.c b/webcit/roomops.c index edbb48fd7..93a6bfa52 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -256,10 +256,13 @@ void listrms(char *variety) */ void zapped_list(void) { + StrBuf *Buf; output_headers(1, 1, 1, 0, 0, 0); - svput("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); - do_template("beginbox", NULL); + Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1); + DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF); + + FreeStrBuf(&Buf); listrms("LZRM -1"); @@ -2631,10 +2634,13 @@ void entroom(void) */ void display_private(char *rname, int req_pass) { + StrBuf *Buf; output_headers(1, 1, 1, 0, 0, 0); - svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room")); - do_template("beginbox", NULL); + Buf = NewStrBufPlain(_("Go to a hidden room"), -1); + DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF); + + FreeStrBuf(&Buf); wprintf("

"); wprintf(_("If you know the name of a hidden (guess-name) or " @@ -3093,7 +3099,6 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { char buf[256]; char floor_name[256]; char old_floor_name[256]; - char boxtitle[256]; int levels, oldlevels; int i, t; int num_boxes = 0; @@ -3139,10 +3144,12 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { strcpy(old_floor_name, floor_name); if (levels == 1) { - /** Begin inner box */ - stresc(boxtitle, 256, floor_name, 1, 0); - svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle); - do_template("beginbox", NULL); + StrBuf *Buf; + + Buf = NewStrBufPlain(floor_name, -1); + DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF); + + FreeStrBuf(&Buf); } oldlevels = levels; diff --git a/webcit/sieve.c b/webcit/sieve.c index 0f9687d35..14a04a7ad 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -656,7 +656,7 @@ void display_add_remove_scripts(char *message) wprintf("
\n"); svput("BOXTITLE", WCS_STRING, _("Add a new script")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf(_("To create a new script, enter the desired " "script name in the box below and click 'Create'.")); @@ -672,7 +672,7 @@ void display_add_remove_scripts(char *message) do_template("endbox", NULL); svput("BOXTITLE", WCS_STRING, _("Edit scripts")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf("
%s

\n", _("Return to the script editing screen") ); @@ -681,7 +681,7 @@ void display_add_remove_scripts(char *message) wprintf("
"); svput("BOXTITLE", WCS_STRING, _("Delete scripts")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf(_("To delete an existing script, select the script " "name from the list and click 'Delete'.")); diff --git a/webcit/static/t/beginbox.html b/webcit/static/t/beginbox.html index 32ecfedac..2d9cc609d 100644 --- a/webcit/static/t/beginbox.html +++ b/webcit/static/t/beginbox.html @@ -1,5 +1,5 @@
-
+
diff --git a/webcit/static/t/beginboxx.html b/webcit/static/t/beginboxx.html new file mode 100644 index 000000000..593fefef9 --- /dev/null +++ b/webcit/static/t/beginboxx.html @@ -0,0 +1,5 @@ + +
+
+
+ diff --git a/webcit/static/t/beginboxx.m.html b/webcit/static/t/beginboxx.m.html new file mode 100644 index 000000000..593fefef9 --- /dev/null +++ b/webcit/static/t/beginboxx.m.html @@ -0,0 +1,5 @@ + +
+
+
+ diff --git a/webcit/static/t/box_preferences.html b/webcit/static/t/box_preferences.html index faa26c9de..0181d6db8 100644 --- a/webcit/static/t/box_preferences.html +++ b/webcit/static/t/box_preferences.html @@ -1,30 +1,33 @@ - - - - @@ -88,8 +146,8 @@ @@ -108,15 +166,17 @@ } -signature - - - + > + +  ,   - + >

-
+ + @@ -130,11 +190,45 @@ signature + + + + + + + + + + + + + + + + +
- > + + >     - > + >
+ - > + + + >     - > + >
- > + + + >     - > + >
+ + +
+ + +
+ +
diff --git a/webcit/static/t/edit_message.html b/webcit/static/t/edit_message.html index 3c02d02cf..74fcd5dfc 100644 --- a/webcit/static/t/edit_message.html +++ b/webcit/static/t/edit_message.html @@ -21,6 +21,17 @@
+ + + + + + - diff --git a/webcit/static/t/menu_your_info.html b/webcit/static/t/menu_your_info.html index 95b011e47..04609c936 100644 --- a/webcit/static/t/menu_your_info.html +++ b/webcit/static/t/menu_your_info.html @@ -1,5 +1,5 @@
    -
  • +
  • diff --git a/webcit/static/t/section_msg_sender_from_select.html b/webcit/static/t/section_msg_sender_from_select.html index 6fe807466..b80b79cb8 100644 --- a/webcit/static/t/section_msg_sender_from_select.html +++ b/webcit/static/t/section_msg_sender_from_select.html @@ -1 +1 @@ - + diff --git a/webcit/static/t/section_msg_sender_name_select.html b/webcit/static/t/section_msg_sender_name_select.html index a0b760f4c..33e0495b7 100644 --- a/webcit/static/t/section_msg_sender_name_select.html +++ b/webcit/static/t/section_msg_sender_name_select.html @@ -1 +1 @@ - + diff --git a/webcit/subst.c b/webcit/subst.c index 4d102045b..a1879ba9d 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -513,7 +513,7 @@ void GetTemplateTokenString(WCTemplateToken *Tokens, { StrBuf *Buf; - if (Tokens->HaveParameters < N) { + if (Tokens->nParameters < N) { *Value = ""; *len = 0; return; @@ -1057,6 +1057,20 @@ int EvaluateToken(StrBuf *Target, WCTemplateToken *Token, WCTemplate *pTmpl, voi Token->Params[4]->len, 0); } + else { + lprintf(1, "Conditional [%s] (in '%s' line %ld); needs at least 6 Params![%s]\n", + Token->Params[0]->Start, + ChrPtr(pTmpl->FileName), + Token->Line, + ChrPtr(Token->FlatToken)); + StrBufAppendPrintf( + Target, + "
    \nConditional [%s] (in '%s' line %ld); needs 6 Params!\n[%s]\n
    \n", + Token->Params[0]->Start, + ChrPtr(pTmpl->FileName), + Token->Line, + ChrPtr(Token->FlatToken)); + } break; case SV_SUBTEMPL: if (Token->nParameters == 1) @@ -1635,6 +1649,7 @@ void RegisterConditional(const char *Name, long len, int ContextRequired) { ConditionalStruct *Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct)); + Cond->PlainName = Name; Cond->nParams = nParams; Cond->CondF = CondF; Cond->ContextRequired = ContextRequired; @@ -1648,12 +1663,12 @@ void tmplput_ContextString(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, v } int ConditionalContextStr(WCTemplateToken *Tokens, void *Context, int ContextType) { - StrBuf *EmailAddr = (StrBuf*) Context; + StrBuf *TokenText = (StrBuf*) Context; const char *CompareToken; long len; - GetTemplateTokenString(Tokens, 3, &CompareToken, &len); - return strcmp(ChrPtr(EmailAddr), CompareToken) == 0; + GetTemplateTokenString(Tokens, 2, &CompareToken, &len); + return strcmp(ChrPtr(TokenText), CompareToken) == 0; } @@ -1671,7 +1686,7 @@ void tmpl_do_boxed(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Con } else { const char *Ch; - long *len; + long len; GetTemplateTokenString(Tokens, 1, &Ch, @@ -1735,8 +1750,7 @@ InitModule_SUBST RegisterNamespace("DOBOXED", 1, 2, tmpl_do_boxed, CTX_NONE); RegisterNamespace("DOTABBED", 2, 100, tmpl_do_tabbed, CTX_NONE); RegisterConditional(HKEY("COND:SUBST"), 3, ConditionalVar, CTX_NONE); - RegisterConditional(HKEY("COND:CONTEXT"), 3, ConditionalContextStr, CTX_NONE); - + RegisterConditional(HKEY("COND:CONTEXTSTR"), 3, ConditionalContextStr, CTX_STRBUF); } /*@}*/ diff --git a/webcit/summary.c b/webcit/summary.c index 6f03c42d8..c18b57b81 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -29,7 +29,7 @@ void output_date(void) { */ void dummy_section(void) { svput("BOXTITLE", WCS_STRING, "(dummy section)"); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf(_("(nothing)")); do_template("endbox", NULL); } diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c index 7db7f4f7f..009cd051b 100644 --- a/webcit/sysmsgs.c +++ b/webcit/sysmsgs.c @@ -33,7 +33,7 @@ void display_edit(char *description, char *check_cmd, } svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Edit %s"), description); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf(_("Enter %s below. Text is formatted to the reader's browser." " A newline is forced by preceding the next line by a blank."), description); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 27cbc4379..47032cfc2 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -688,7 +688,7 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to, char *force_room output_headers(1, 1, 1, 0, 0, 0); svput("BOXTITLE", WCS_STRING, _("Edit contact information")); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf("\n"); wprintf("\n", WC->nonce); diff --git a/webcit/webcit.c b/webcit/webcit.c index efeda29b5..c2866279e 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -793,7 +793,7 @@ void print_menu_box(char* Title, char *Class, int nLines, ...) long i; svput("BOXTITLE", WCS_STRING, Title); - do_template("beginbox", NULL); + do_template("beginboxx", NULL); wprintf("
      ", Class); diff --git a/webcit/webcit.h b/webcit/webcit.h index 7dd5922d5..1250676ec 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -331,6 +331,7 @@ void RegisterNS(const char *NSName, long len, typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType); typedef struct _ConditionalStruct { + const char *PlainName; int nParams; int ContextRequired; WCConditionalFunc CondF; -- 2.30.2