/*
* Display a specific page from a wiki room
*/
-void display_wiki_page(void)
+void display_wiki_page_backend(const StrBuf *roomname, char *pagename)
{
const StrBuf *Mime;
- const StrBuf *roomname;
- char pagename[128];
- char errmsg[256];
long msgnum = (-1L);
- roomname = sbstr("room");
- safestrncpy(pagename, bstr("page"), sizeof pagename);
str_wiki_index(pagename);
if (StrLength(roomname) > 0) {
/* If we're still not in the correct room, it doesn't exist. */
if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
- snprintf(errmsg, sizeof errmsg,
- _("There is no room called '%s'."),
- ChrPtr(roomname));
- convenience_page("FF0000", _("Error"), errmsg);
+ wc_printf(_("There is no room called '%s'."), ChrPtr(roomname));
return;
}
}
if (WC->wc_view != VIEW_WIKI) {
- snprintf(errmsg, sizeof errmsg,
- _("'%s' is not a Wiki room."),
- ChrPtr(roomname));
- convenience_page("FF0000", _("Error"), errmsg);
+ wc_printf(_("'%s' is not a Wiki room."), ChrPtr(roomname));
return;
}
/* Found it! Now read it. */
msgnum = locate_message_by_uid(pagename);
if (msgnum >= 0L) {
- output_headers(1, 1, 1, 0, 0, 0);
read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
- wDumpContent(1);
return;
}
- output_headers(1, 1, 1, 0, 0, 0);
- wprintf("<br /><br />"
+ wc_printf("<br /><br />"
"<div align=\"center\">"
"<table border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"10\">"
"<tr><td align=\"center\">"
);
- wprintf("<br><b>");
- wprintf(_("There is no page called '%s' here."), pagename);
- wprintf("</b><br><br>");
- wprintf(_("Select the 'Edit this page' link in the room banner "
+ wc_printf("<br><b>");
+ wc_printf(_("There is no page called '%s' here."), pagename);
+ wc_printf("</b><br><br>");
+ wc_printf(_("Select the 'Edit this page' link in the room banner "
"if you would like to create this page."));
- wprintf("<br><br>");
- wprintf("</td></tr></table></div>\n");
+ wc_printf("<br><br>");
+ wc_printf("</td></tr></table></div>\n");
+}
+
+
+/*
+ * Display a specific page from a wiki room
+ */
+void display_wiki_page(void)
+{
+ const StrBuf *roomname;
+ char pagename[128];
+
+ output_headers(1, 1, 1, 0, 0, 0);
+ roomname = sbstr("room");
+ safestrncpy(pagename, bstr("page"), sizeof pagename);
+ display_wiki_page_backend(roomname, pagename);
+ wDumpContent(1);
+}
+
+
+/*
+ * Display the revision history for a wiki page (template callback)
+ */
+void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
+{
+ const StrBuf *roomname;
+ char pagename[128];
+ StrBuf *Buf;
+
+ roomname = sbstr("room");
+ safestrncpy(pagename, bstr("page"), sizeof pagename);
+ str_wiki_index(pagename);
+
+ if (StrLength(roomname) > 0) {
+
+ /* If we're not in the correct room, try going there. */
+ if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
+ gotoroom(roomname);
+ }
+
+ /* If we're still not in the correct room, it doesn't exist. */
+ if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
+ wc_printf(_("There is no room called '%s'."), ChrPtr(roomname));
+ return;
+ }
+
+ }
+
+ serv_printf("WIKI history|%s", pagename);
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 1) {
+ while(StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) {
+ wc_printf("<tt>%s</tt><br>\n", ChrPtr(Buf));
+ }
+ }
+ else {
+ wc_printf("%s", ChrPtr(Buf));
+ }
+
+ FreeStrBuf(&Buf);
+}
+
+
+/*
+ * Display the revision history for a wiki page
+ */
+void display_wiki_history(void)
+{
+ output_headers(1, 1, 1, 0, 0, 0);
+ do_template("wiki_history", NULL);
+ wDumpContent(1);
+}
+
+
+int wiki_Cleanup(void **ViewSpecific)
+{
+ char pagename[5];
+ safestrncpy(pagename, "home", sizeof pagename);
+ display_wiki_page_backend(WC->wc_roomname, pagename);
wDumpContent(1);
+ return 0;
}
void
InitModule_WIKI
(void)
{
- WebcitAddUrlHandler(HKEY("wiki"), display_wiki_page, 0);
- return ;
+ RegisterReadLoopHandlerset(
+ VIEW_WIKI,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ wiki_Cleanup
+ );
+
+ WebcitAddUrlHandler(HKEY("wiki"), "", 0, display_wiki_page, 0);
+ WebcitAddUrlHandler(HKEY("wiki_history"), "", 0, display_wiki_history, 0);
+ RegisterNamespace("WIKI:DISPLAYHISTORY", 0, 0, tmplput_display_wiki_history, NULL, CTX_NONE);
}