X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsummary.c;h=172a15486703d700279a37f4ee2abac124a1dee8;hb=4b4dc864ede7c5d8d956febe4a0afb422b78e7c4;hp=ed5bb61e81b7aacb3fe4f6a055c08a8cb59bb01f;hpb=aa8ca3b0af3efdabd8559b886efb3164319bdce1;p=citadel.git diff --git a/webcit/summary.c b/webcit/summary.c index ed5bb61e8..172a15486 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -1,10 +1,27 @@ /* - * $Id$ - * * Displays the "Summary Page" + * + * Copyright (c) 1996-2011 by the citadel.org team + * + * This program is open source software. You can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "webcit.h" +#include "calendar.h" + +extern int calendar_summary_view(void); /* * Display today's date in a friendly format @@ -12,38 +29,27 @@ 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); + wc_printf("%s", buf); } +void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP) +{ + struct tm tm; + time_t now; + char buf[128]; + size_t n; + time(&now); + localtime_r(&now, &tm); - -/* - * Dummy section - */ -void dummy_section(void) { - svprintf("BOXTITLE", WCS_STRING, "(dummy section)"); - do_template("beginbox"); - wprintf("(nothing)"); - do_template("endbox"); + n = wc_strftime(buf, 32, "%A, %x", &tm); + StrBufAppendBufPlain(Target, buf, n, 0); } @@ -57,13 +63,11 @@ 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("
"); + wc_printf("\">"); escputs(room); - wprintf(" | %d/%d | \n", + wc_printf("%d/%d | \n", extract_int(&buf[4], 1), extract_int(&buf[4], 2) ); } } - wprintf("
"); - wholist_section(); - - /* - * Column Two - */ - wprintf(" | ");
- server_info_section();
- wprintf(" "); +void tmplput_tasks_section(StrBuf *Target, WCTemplputParams *TP) { tasks_section(); - - /* - * Column Three - */ - wprintf(" | ");
- new_messages_section();
- wprintf(" "); +} +void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) { calendar_section(); +} + +void +InitModule_SUMMARY +(void) +{ + RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE); + RegisterNamespace("SUMMARY:NEWMESSAGES_SELECTION", 0, 0, tmplput_new_messages_section, NULL, CTX_NONE); + RegisterNamespace("SUMMARY:TASKSSECTION", 0, 0, tmplput_tasks_section, NULL, CTX_NONE); + RegisterNamespace("SUMMARY:CALENDAR_SECTION", 0, 0, tmplput_calendar_section, NULL, CTX_NONE); + + 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); - /* - * End of columns - */ - wprintf(" |