From 593af65c41d9a6385a5273a11e70aa88a32a4237 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 27 Nov 2008 00:01:20 +0000 Subject: [PATCH] * rework login screen to utilize more modern templating * add MESG() template hook * (still somewhat unfinished, errormessages won't show up yet...) --- webcit/auth.c | 114 ++++++------------- webcit/gettext.c | 11 +- webcit/serv_func.c | 53 +++++++-- webcit/static/t/login.html | 51 ++++++--- webcit/static/t/view_message_replyquote.html | 2 +- webcit/webcit.h | 2 +- 6 files changed, 127 insertions(+), 106 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index be6b00ef3..618956d61 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -34,72 +34,12 @@ void initialize_axdefs(void) { * Display the login screen * mesg = the error message if last attempt failed. */ -void display_login(char *mesg) +void display_login(void) { - char buf[SIZ]; - - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - - if ((mesg != NULL) && (!IsEmptyStr(mesg))) { - stresc(buf, SIZ, mesg, 0, 0); - svprintf(HKEY("MESG"), WCS_STRING, "%s", buf); - } - - svprintf(HKEY("LOGIN_INSTRUCTIONS"), WCS_STRING, - _(""), - serv_info.serv_humannode - ); - - svput("USERNAME_BOX", WCS_STRING, _("User name:")); - svput("PASSWORD_BOX", WCS_STRING, _("Password:")); - svput("LANGUAGE_BOX", WCS_STRING, _("Language:")); - svput("LOGIN_BUTTON", WCS_STRING, _("Login")); - svput("NEWUSER_BUTTON", WCS_STRING, _("New User")); - svput("EXIT_BUTTON", WCS_STRING, _("Exit")); - svput("HELLO", WCS_SERVCMD, "MESG hello"); - svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by Citadel"), - serv_info.serv_humannode); - svcallback("DO_LANGUAGE_BOX", offer_languages); - if (serv_info.serv_newuser_disabled) { - svput("NEWUSER_BUTTON_PRE", WCS_STRING, "
"); - svput("NEWUSER_BUTTON_POST", WCS_STRING, "
"); - } - else { - svput("NEWUSER_BUTTON_PRE", WCS_STRING, ""); - svput("NEWUSER_BUTTON_POST", WCS_STRING, ""); - } - - if (serv_info.serv_supports_openid) { - svprintf(HKEY("OFFER_OPENID_LOGIN"), WCS_STRING, - "
" - "" - "" - "%s" - "
" - , - "Log in using OpenID" - ); - } - else { - svput("OFFER_OPENID_LOGIN", WCS_STRING, ""); - } - + begin_burst(); + output_headers(1, 0, 0, 0, 1, 0); do_template("login", NULL); - - wDumpContent(2); + end_burst(); } @@ -135,15 +75,8 @@ void display_openid_login(char *mesg) "") ); - svput("OPENID_BOX", WCS_STRING, _("OpenID URL:")); - svput("LANGUAGE_BOX", WCS_STRING, _("Language:")); - svput("LOGIN_BUTTON", WCS_STRING, _("Login")); - svput("EXIT_BUTTON", WCS_STRING, _("Exit")); svput("HELLO", WCS_SERVCMD, "MESG hello"); - svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by Citadel"), - serv_info.serv_humannode); - svcallback("DO_LANGUAGE_BOX", offer_languages); - + svprintf(HKEY("OFFER_CONVENTIONAL_LOGIN"), WCS_STRING, "
" "" @@ -243,6 +176,7 @@ void become_logged_in(char *user, char *pass, char *serv_response) */ void do_login(void) { + struct wcsession *WCC = WC; char buf[SIZ]; if (havebstr("language")) { @@ -263,17 +197,29 @@ void do_login(void) if (buf[0] == '2') { become_logged_in(bstr("name"), bstr("pass"), buf); } else { - display_login(&buf[4]); + snprintf(WCC->ImportantMessage, + sizeof (WCC->ImportantMessage), + "%s", + &buf[4]); + display_login(); return; } } else { - display_login(&buf[4]); + snprintf(WCC->ImportantMessage, + sizeof (WCC->ImportantMessage), + "%s", + &buf[4]); + display_login(); return; } } if (havebstr("newuser_action")) { if (!havebstr("pass")) { - display_login(_("Blank passwords are not allowed.")); + snprintf(WCC->ImportantMessage, + sizeof (WCC->ImportantMessage), + "%s", + _("Blank passwords are not allowed.")); + display_login(); return; } serv_printf("NEWU %s", bstr("name")); @@ -283,21 +229,29 @@ void do_login(void) serv_printf("SETP %s", bstr("pass")); serv_getln(buf, sizeof buf); } else { - display_login(&buf[4]); + snprintf(WCC->ImportantMessage, + sizeof (WCC->ImportantMessage), + "%s", + &buf[4]); + display_login(); return; } } - if (WC->logged_in) { + if (WCC->logged_in) { set_preference("language", NewStrBufPlain(bstr("language"), -1), 1); - if (WC->need_regi) { + if (WCC->need_regi) { display_reg(1); - } else if (WC->need_vali) { + } else if (WCC->need_vali) { validate(); } else { do_welcome(); } } else { - display_login(_("Your password was not accepted.")); + snprintf(WCC->ImportantMessage, + sizeof (WCC->ImportantMessage), + "%s", + _("Your password was not accepted.")); + display_login(); } } diff --git a/webcit/gettext.c b/webcit/gettext.c index 1402983c0..d504a6eaf 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -205,7 +205,7 @@ void httplang_to_locale(StrBuf *LocaleString) * depending on the browser locale change the sequence of the * language chooser. */ -void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { +void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { int i; #ifndef HAVE_USELOCALE char *Lang = getenv("LANG"); @@ -344,7 +344,7 @@ void ShutdownLocale(void) #else /* ENABLE_NLS */ /** \brief dummy for non NLS enabled systems */ -void offer_languages(void) { +void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wprintf("English (US)"); } @@ -388,4 +388,9 @@ const char *get_selected_language(void) { #endif } - +void +InitModule_GETTEXT +(void) +{ + RegisterNamespace("LANG:SELECT", 0, 0, tmplput_offer_languages, CTX_NONE); +} diff --git a/webcit/serv_func.c b/webcit/serv_func.c index a01184f35..24d645896 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -168,7 +168,7 @@ void FmOut(StrBuf *Target, char *align, StrBuf *Source) long len; int intext = 0; - StrBufAppendPrintf(Target, "
\n", align); + StrBufAppendPrintf(Target, "
\n", align); while ((n = StrBufSipLine(Line, Source, &BufPtr), n >= 0) && !done) { done = n == 0; @@ -523,7 +523,7 @@ void tmplput_serv_fqdn(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void StrEscAppend(Target, NULL, serv_info.serv_fqdn, 0, 0); } -void tmmplput_serv_software(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +void tmplput_serv_software(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { StrEscAppend(Target, NULL, serv_info.serv_software, 0, 0); } @@ -534,8 +534,16 @@ void tmplput_serv_rev_level(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, serv_info.serv_rev_level / 100, serv_info.serv_rev_level % 100); } +int conditional_serv_newuser_disabled(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + return serv_info.serv_newuser_disabled != 0; +} +int conditional_serv_supports_openid(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + return serv_info.serv_supports_openid != 0; +} -void tmmplput_serv_bbs_city(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +void tmplput_serv_bbs_city(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { StrEscAppend(Target, NULL, serv_info.serv_bbs_city, 0, 0); } @@ -551,23 +559,54 @@ void tmplput_current_room(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, vo } +void tmplput_mesg(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +{ + int n = 0; + int Done = 0; + StrBuf *Line; + StrBuf *Buf; - + Buf = NewStrBuf(); + Line = NewStrBuf(); + serv_printf("MESG %s", Tokens->Params[0]->Start); + StrBuf_ServGetln(Line); + while (!Done && (StrBuf_ServGetln(Line)>=0)) { + if ( (StrLength(Line)==3) && + !strcmp(ChrPtr(Line), "000")) + Done = 1; + else + { + if (n > 0) + StrBufAppendBufPlain(Buf, "\n", 1, 0); + StrBufAppendBuf(Buf, Line, 0); + } + n++; + } + FlushStrBuf(Line); + FmOut(Line, "center", Buf); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Line, 1); + FreeStrBuf(&Buf); + FreeStrBuf(&Line); +} void InitModule_SERVFUNC (void) { + + RegisterConditional(HKEY("COND:SERV:OPENID"), 2, conditional_serv_supports_openid, CTX_NONE); + RegisterConditional(HKEY("COND:SERV:NEWU"), 2, conditional_serv_newuser_disabled, CTX_NONE); RegisterNamespace("CURRENT_USER", 0, 0, tmplput_current_user, CTX_NONE); RegisterNamespace("CURRENT_ROOM", 0, 0, tmplput_current_room, CTX_NONE); RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, CTX_NONE); RegisterNamespace("SERV:NODENAME", 0, 0, tmplput_serv_nodename, CTX_NONE); RegisterNamespace("SERV:HUMANNODE", 0, 0, tmplput_serv_humannode, CTX_NONE); RegisterNamespace("SERV:FQDN", 0, 0, tmplput_serv_fqdn, CTX_NONE); - RegisterNamespace("SERV:SOFTWARE", 0, 0, tmmplput_serv_software, CTX_NONE); + RegisterNamespace("SERV:SOFTWARE", 0, 0, tmplput_serv_software, CTX_NONE); RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, CTX_NONE); - RegisterNamespace("SERV:BBS_CITY", 0, 0, tmmplput_serv_bbs_city, CTX_NONE); -/// RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmmplput_serv_ldap_enabled, 0); + RegisterNamespace("SERV:BBS_CITY", 0, 0, tmplput_serv_bbs_city, CTX_NONE); + RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, CTX_NONE); +/// RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0); } /*@}*/ diff --git a/webcit/static/t/login.html b/webcit/static/t/login.html index 495e4919e..7afc0edc0 100644 --- a/webcit/static/t/login.html +++ b/webcit/static/t/login.html @@ -1,23 +1,46 @@ - - - + +
+
+ +
+ + + + + + +
- +
- +
- -
+ +
- - - - - + " class="logbutton"> + +
+ " class="logbutton" > +
+ + " class="logbutton">
- + +
+ + + +
+ - + + diff --git a/webcit/static/t/view_message_replyquote.html b/webcit/static/t/view_message_replyquote.html index 2bbb28570..4de24c17e 100644 --- a/webcit/static/t/view_message_replyquote.html +++ b/webcit/static/t/view_message_replyquote.html @@ -2,7 +2,7 @@
- <> + <> ***

diff --git a/webcit/webcit.h b/webcit/webcit.h index 1250676ec..f431ac9e7 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -707,7 +707,7 @@ void cookie_to_stuff(StrBuf *cookie, int *session, void locate_host(char *, int); void become_logged_in(char *, char *, char *); void openid_manual_create(void); -void display_login(char *mesg); +void display_login(); void display_openids(void); void do_welcome(void); void do_logout(void); -- 2.30.2