X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsummary.c;h=a5db298b030bf8cbec17e3f0b9cf31e9c54257b5;hb=6ec73d6906542ea2f8cca2e62f7625ee2e17ae03;hp=f6e884aefe08a88805dcc502d3c071065e12bf9c;hpb=7836de1a004d9353cadb71885e360715884d1601;p=citadel.git diff --git a/webcit/summary.c b/webcit/summary.c index f6e884aef..a5db298b0 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -4,27 +4,8 @@ * Displays the "Summary Page" */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "webcit.h" +#include "calendar.h" /* * Display today's date in a friendly format @@ -32,25 +13,13 @@ void output_date(void) { struct tm tm; time_t now; - - static char *wdays[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" - }; - static char *months[] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" - }; + char buf[128]; time(&now); localtime_r(&now, &tm); - wprintf("%s, %s %d, %d", - wdays[tm.tm_wday], - months[tm.tm_mon], - tm.tm_mday, - tm.tm_year + 1900 - ); + wc_strftime(buf, 32, "%A, %x", &tm); + wprintf("%s", buf); } @@ -60,10 +29,10 @@ void output_date(void) { * Dummy section */ void dummy_section(void) { - svprintf("BOXTITLE", WCS_STRING, "(dummy section)"); - do_template("beginbox"); - wprintf("(nothing)"); - do_template("endbox"); + svput("BOXTITLE", WCS_STRING, "(dummy section)"); + do_template("beginboxx", NULL); + wprintf(_("(nothing)")); + do_template("endbox", NULL); } @@ -77,53 +46,30 @@ void new_messages_section(void) { int number_of_rooms_to_check; char *rooms_to_check = "Mail|Lobby"; - svprintf("BOXTITLE", WCS_STRING, "Messages"); - do_template("beginbox"); number_of_rooms_to_check = num_tokens(rooms_to_check, '|'); if (number_of_rooms_to_check == 0) return; - wprintf("\n"); + wprintf("
\n"); for (i=0; i\n", + wprintf("\n", extract_int(&buf[4], 1), extract_int(&buf[4], 2) ); } } - wprintf("
"); escputs(room); - wprintf("%d/%d
%d/%d
\n"); - do_template("endbox"); - -} + wprintf("\n"); - -/* - * Wholist section - */ -void wholist_section(void) { - char buf[SIZ]; - char user[SIZ]; - - svprintf("BOXTITLE", WCS_STRING, "Who's online now"); - do_template("beginbox"); - serv_puts("RWHO"); - serv_gets(buf); - if (buf[0] == '1') while(serv_gets(buf), strcmp(buf, "000")) { - extract(user, buf, 1); - escputs(user); - wprintf("
\n"); - } - do_template("endbox"); } @@ -131,37 +77,45 @@ void wholist_section(void) { * Task list section */ void tasks_section(void) { -#ifdef WEBCIT_WITH_CALENDAR_SERVICE int num_msgs = 0; - int i; -#endif - - svprintf("BOXTITLE", WCS_STRING, "Tasks"); - do_template("beginbox"); -#ifdef WEBCIT_WITH_CALENDAR_SERVICE - gotoroom("Tasks"); - if (strcasecmp(WC->wc_roomname, "Tasks")) { + HashPos *at; + const char *HashKey; + long HKLen; + void *vMsg; + message_summary *Msg; + wcsession *WCC = WC; + StrBuf *Buf; + SharedMessageStatus Stat; + + memset(&Stat, 0, sizeof(SharedMessageStatus)); + Stat.maxload = 10000; + Stat.lowest_found = (-1); + Stat.highest_found = (-1); + + Buf = NewStrBufPlain(HKEY("_TASKS_")); + gotoroom(Buf); + FreeStrBuf(&Buf); + if (WCC->wc_view != VIEW_TASKS) { num_msgs = 0; } else { - num_msgs = load_msg_ptrs("MSGS ALL"); + num_msgs = load_msg_ptrs("MSGS ALL", &Stat); } - if (num_msgs < 1) { - wprintf("(None)
\n"); - } - else { - for (i=0; imsgarr[i]); + if (num_msgs > 0) { + at = GetNewHashPos(WCC->summ, 0); + while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { + Msg = (message_summary*) vMsg; + tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0); } + DeleteHashPos(&at); } - calendar_summary_view(); - -#else /* WEBCIT_WITH_CALENDAR_SERVICE */ - wprintf("(This server does not support task lists)\n"); -#endif /* WEBCIT_WITH_CALENDAR_SERVICE */ - do_template("endbox"); + if (calendar_summary_view() < 1) { + wprintf(""); + wprintf(_("(None)")); + wprintf("
\n"); + } } @@ -169,114 +123,217 @@ void tasks_section(void) { * Calendar section */ void calendar_section(void) { -#ifdef WEBCIT_WITH_CALENDAR_SERVICE + char cmd[SIZ]; int num_msgs = 0; - int i; -#endif - - svprintf("BOXTITLE", WCS_STRING, "Today on your calendar"); - do_template("beginbox"); -#ifdef WEBCIT_WITH_CALENDAR_SERVICE - gotoroom("Calendar"); - if (strcasecmp(WC->wc_roomname, "Calendar")) { + HashPos *at; + const char *HashKey; + long HKLen; + void *vMsg; + message_summary *Msg; + wcsession *WCC = WC; + StrBuf *Buf; + void *v = NULL; + SharedMessageStatus Stat; + + memset(&Stat, 0, sizeof(SharedMessageStatus)); + Stat.maxload = 10000; + Stat.lowest_found = (-1); + Stat.highest_found = (-1); + + Buf = NewStrBufPlain(HKEY("_CALENDAR_")); + gotoroom(Buf); + FreeStrBuf(&Buf); + if ( (WC->wc_view != VIEW_CALENDAR) && (WC->wc_view != VIEW_CALBRIEF) ) { num_msgs = 0; } else { - num_msgs = load_msg_ptrs("MSGS ALL"); - } - - if (num_msgs < 1) { - wprintf("(Nothing)
\n"); + num_msgs = load_msg_ptrs("MSGS ALL", &Stat); } - else { - for (i=0; imsgarr[i]); + calendar_GetParamsGetServerCall(&Stat, + &v, + readnew, + cmd, + sizeof(cmd)); + + if (num_msgs > 0) { + at = GetNewHashPos(WCC->summ, 0); + while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { + Msg = (message_summary*) vMsg; + calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0); } - calendar_summary_view(); + DeleteHashPos(&at); } - -#else /* WEBCIT_WITH_CALENDAR_SERVICE */ - wprintf("(This server does not support calendars)\n"); -#endif /* WEBCIT_WITH_CALENDAR_SERVICE */ - do_template("endbox"); + if (calendar_summary_view() < 1) { + wprintf(""); + wprintf(_("(Nothing)")); + wprintf("
\n"); + } + __calendar_Cleanup(&v); } - /* * Server info section (fluff, really) */ void server_info_section(void) { - svprintf("BOXTITLE", WCS_STRING, "About this server"); - do_template("beginbox"); - wprintf("You are connected to "); - escputs(serv_info.serv_humannode); - wprintf(", running "); - escputs(serv_info.serv_software); - wprintf(", and located in "); - escputs(serv_info.serv_bbs_city); - wprintf(".
\nYour system administrator is "); - escputs(serv_info.serv_sysadm); - wprintf(".\n"); - do_template("endbox"); + char message[512]; + wcsession *WCC = WC; + + snprintf(message, sizeof message, + _("You are connected to %s, running %s with %s, server build %s and located in %s. Your system administrator is %s."), + ChrPtr(WCC->serv_info->serv_humannode), + ChrPtr(WCC->serv_info->serv_software), + PACKAGE_STRING, + ChrPtr(WCC->serv_info->serv_svn_revision), + ChrPtr(WCC->serv_info->serv_bbs_city), + ChrPtr(WCC->serv_info->serv_sysadm)); + escputs(message); } - /* - * Display this user's summary page + * Now let's do three columns of crap. All portals and all groupware + * clients seem to want to do three columns, so we'll do three + * columns too. Conformity is not inherently a virtue, but there are + * a lot of really shallow people out there, and even though they're + * not people I consider worthwhile, I still want them to use WebCit. */ -void summary(void) { - - output_headers(1, 1, 2, 0, 1, 0, 0); - wprintf("
\n"); - wprintf("" - "
" - "" - "Summary page for "); - escputs(WC->wc_username); - wprintf("\n"); - wprintf(""); - output_date(); - wprintf("
"); - offer_start_page(); - wprintf("
\n"); - wprintf("
\n
\n"); - - /* - * Now let's do three columns of crap. All portals and all groupware - * clients seem to want to do three columns, so we'll do three - * columns too. Conformity is not inherently a virtue, but there are - * a lot of really shallow people out there, and even though they're - * not people I consider worthwhile, I still want them to use WebCit. - */ - - wprintf(""); +void summary_inner_div(void) { + wprintf("
" + "
" + ""); /* * Column One */ wprintf(""); /* - * Column Two + * Column Two */ - wprintf(""); /* * Column Three */ - wprintf(""); + + wprintf(""); + + /* + * Row Two - Column One + */ + wprintf(""); + + /* + * Row Two - Column Two + */ + wprintf(""); + /* * End of columns */ - wprintf("
"); - wholist_section(); + wprintf("
"); + wprintf("
"); + wprintf(_("Messages")); + wprintf("
"); + wprintf("
"); + new_messages_section(); + wprintf("
"); + wprintf("
"); - server_info_section(); - wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf(_("Tasks")); + wprintf("
"); + wprintf("
"); tasks_section(); + wprintf("
"); + wprintf("
"); - new_messages_section(); - wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf(_("Today on your calendar")); + wprintf("
"); + wprintf("
"); calendar_section(); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf(_("Who's online now")); + wprintf("
"); + wprintf("
"); + do_template("wholistsummarysection", NULL); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf("
"); + wprintf(_("About this server")); + wprintf("
"); + wprintf("
"); + server_info_section(); + wprintf("
"); + wprintf("
\n"); + wprintf(""); +} + + +/* + * Display this user's summary page + */ +void summary(void) { + char title[256]; + + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf("

"); + snprintf(title, sizeof title, _("Summary page for %s"), ChrPtr(WC->wc_fullname)); + escputs(title); + wprintf("

"); + output_date(); + wprintf("

"); + wprintf("
"); + wprintf("
    \n"); + wprintf("
  • "); + offer_start_page(NULL, &NoCtx); + wprintf("
"); + wprintf("
"); + wprintf("
"); + + /* + * You guessed it ... we're going to refresh using ajax. + * In the future we might consider updating individual sections of the summary + * instead of the whole thing. + */ + wprintf("
\n"); + summary_inner_div(); + wprintf("
\n"); + + wprintf( + " \n" + ); wDumpContent(1); } + +void +InitModule_SUMMARY +(void) +{ + WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX); + WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX); + WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX); + WebcitAddUrlHandler(HKEY("mini_calendar"), "", 0, ajax_mini_calendar, AJAX); + WebcitAddUrlHandler(HKEY("summary"), "", 0, summary, 0); + WebcitAddUrlHandler(HKEY("summary_inner_div"), "", 0, summary_inner_div, AJAX); +} +