2 * Displays the "Summary Page"
9 * Display today's date in a friendly format
11 void output_date(void) {
17 localtime_r(&now, &tm);
19 wc_strftime(buf, 32, "%A, %x", &tm);
24 * New messages section
26 void new_messages_section(void) {
30 int number_of_rooms_to_check;
31 char *rooms_to_check = "Mail|Lobby";
34 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
35 if (number_of_rooms_to_check == 0) return;
37 wc_printf("<table border=0 width=100%%>\n");
38 for (i=0; i<number_of_rooms_to_check; ++i) {
39 extract_token(room, rooms_to_check, i, '|', sizeof room);
41 serv_printf("GOTO %s", room);
42 serv_getln(buf, sizeof buf);
44 extract_token(room, &buf[4], 0, '|', sizeof room);
45 wc_printf("<tr><td><a href=\"dotgoto?room=");
49 wc_printf("</a></td><td>%d/%d</td></tr>\n",
50 extract_int(&buf[4], 1),
51 extract_int(&buf[4], 2)
55 wc_printf("</table>\n");
63 void tasks_section(void) {
72 SharedMessageStatus Stat;
74 memset(&Stat, 0, sizeof(SharedMessageStatus));
76 Stat.lowest_found = (-1);
77 Stat.highest_found = (-1);
79 Buf = NewStrBufPlain(HKEY("_TASKS_"));
83 if (WCC->CurRoom.view != VIEW_TASKS) {
87 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
91 at = GetNewHashPos(WCC->summ, 0);
92 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
93 Msg = (message_summary*) vMsg;
94 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
99 if (calendar_summary_view() < 1) {
101 wc_printf(_("(None)"));
102 wc_printf("</i><br />\n");
110 void calendar_section(void) {
117 message_summary *Msg;
121 SharedMessageStatus Stat;
123 memset(&Stat, 0, sizeof(SharedMessageStatus));
124 Stat.maxload = 10000;
125 Stat.lowest_found = (-1);
126 Stat.highest_found = (-1);
128 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
131 if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
135 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
137 calendar_GetParamsGetServerCall(&Stat,
144 at = GetNewHashPos(WCC->summ, 0);
145 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
146 Msg = (message_summary*) vMsg;
147 calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
151 if (calendar_summary_view() < 1) {
153 wc_printf(_("(Nothing)"));
154 wc_printf("</i><br />\n");
156 __calendar_Cleanup(&v);
160 * Server info section (fluff, really)
162 void server_info_section(void) {
166 snprintf(message, sizeof message,
167 _("You are connected to %s, running %s with %s, server build %s and located in %s. Your system administrator is %s."),
168 ChrPtr(WCC->serv_info->serv_humannode),
169 ChrPtr(WCC->serv_info->serv_software),
171 ChrPtr(WCC->serv_info->serv_svn_revision),
172 ChrPtr(WCC->serv_info->serv_bbs_city),
173 ChrPtr(WCC->serv_info->serv_sysadm));
178 * Now let's do three columns of crap. All portals and all groupware
179 * clients seem to want to do three columns, so we'll do three
180 * columns too. Conformity is not inherently a virtue, but there are
181 * a lot of really shallow people out there, and even though they're
182 * not people I consider worthwhile, I still want them to use WebCit.
184 void summary_inner_div(void) {
186 wc_printf("<table width=\"98%%\" cellspacing=\"3\" cellpadding=\"0\">");
187 wc_printf("<tr valign=top>");
192 wc_printf("<td width=33%%>");
193 wc_printf("<div class=\"box\">");
194 wc_printf("<div class=\"boxlabel\">");
195 wc_printf(_("Messages"));
196 wc_printf("</div><div class=\"boxcontent\">");
197 wc_printf("<div id=\"msg_inner\">");
198 new_messages_section();
199 wc_printf("</div></div></div>");
205 wc_printf("<td width=33%%>");
206 wc_printf("<div class=\"box\">");
207 wc_printf("<div class=\"boxlabel\">");
208 wc_printf(_("Tasks"));
209 wc_printf("</div><div class=\"boxcontent\">");
210 wc_printf("<div id=\"tasks_inner\">");
212 wc_printf("</div></div></div>");
218 wc_printf("<td width=33%%>");
219 wc_printf("<div class=\"box\">");
220 wc_printf("<div class=\"boxlabel\">");
221 wc_printf(_("Today on your calendar"));
222 wc_printf("</div><div class=\"boxcontent\">");
223 wc_printf("<div id=\"calendar_inner\">");
225 wc_printf("</div></div></div>");
228 wc_printf("</tr><tr valign=top>");
231 * Row Two - Column One
233 wc_printf("<td colspan=2>");
234 wc_printf("<div class=\"box\">");
235 wc_printf("<div class=\"boxlabel\">");
236 wc_printf(_("Who's online now"));
237 wc_printf("</div><div class=\"boxcontent\">");
238 wc_printf("<div id=\"who_inner\">");
239 do_template("who_summary", NULL);
240 wc_printf("</div></div></div>");
244 * Row Two - Column Two
246 wc_printf("<td width=33%%>");
247 wc_printf("<div class=\"box\">");
248 wc_printf("<div class=\"boxlabel\">");
249 wc_printf(_("About this server"));
250 wc_printf("</div><div class=\"boxcontent\">");
251 wc_printf("<div id=\"info_inner\">");
252 server_info_section();
253 wc_printf("</div></div></div>");
260 wc_printf("</tr></table>");
265 * Display this user's summary page
270 output_headers(1, 1, 2, 0, 0, 0);
271 wc_printf("<div id=\"banner\" class=\"banner\">\n");
272 wc_printf("<table border=0><tr>");
273 wc_printf("<td><img src=\"static/summscreen_48x.gif\"></td>");
274 wc_printf("<td><h1>");
275 snprintf(title, sizeof title, _("Summary page for %s"), ChrPtr(WC->wc_fullname));
277 wc_printf("</h1><h2>");
279 wc_printf("</h2></td></tr></table>");
280 wc_printf("<div id=\"actiondiv\">");
281 wc_printf("<ul class=\"room_actions\">\n");
282 wc_printf("<li class=\"start_page\">");
283 offer_start_page(NULL, &NoCtx);
284 wc_printf("</li></ul>");
285 wc_printf("</div>"); /* actiondiv */
286 wc_printf("</div>"); /* banner */
289 * You guessed it ... we're going to refresh using ajax.
290 * In the future we might consider updating individual sections of the summary
291 * instead of the whole thing.
293 wc_printf("<div id=\"content\" class=\"service\">\n");
295 wc_printf("</div>\n");
298 "<script type=\"text/javascript\"> "
299 " new Ajax.PeriodicalUpdater('msg_inner', 'new_messages_html', "
300 " { method: 'get', frequency: 60 } ); "
301 " new Ajax.PeriodicalUpdater('tasks_inner', 'tasks_inner_html', "
302 " { method: 'get', frequency: 120 } ); "
303 " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html', "
304 " { method: 'get', frequency: 90 } ); "
305 " new Ajax.PeriodicalUpdater('do_template', 'template=who_summary', "
306 " { method: 'get', frequency: 30 } ); "
317 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
318 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
319 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
320 WebcitAddUrlHandler(HKEY("mini_calendar"), "", 0, ajax_mini_calendar, AJAX);
321 WebcitAddUrlHandler(HKEY("summary"), "", 0, summary, 0);
322 WebcitAddUrlHandler(HKEY("summary_inner_div"), "", 0, summary_inner_div, AJAX);