* History template
authorArt Cancro <ajc@citadel.org>
Sat, 24 Oct 2009 05:50:19 +0000 (05:50 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 24 Oct 2009 05:50:19 +0000 (05:50 +0000)
webcit/static/t/wiki_history_inner.html
webcit/wiki.c

index 9d6cf4b7fb68bb475a73b1e536a68faf9cb5ed71..c4a41d0d4801d55fe101f0df3d8cd075654625ed 100644 (file)
@@ -1 +1 @@
-FIXME
+<?WIKI:DISPLAYHISTORY>
index a8a2d12f32d896c1885e7875ad2b3ae2d3f4f5b8..87d8cf94e3023f652ef4cf3f71ebf4ef979c723d 100644 (file)
@@ -102,19 +102,56 @@ void display_wiki_page(void)
 
 
 /*
- * Display the revision history for a wiki page
+ * Display the revision history for a wiki page (template callback)
  */
-void display_wiki_history(void)
+void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
 {
        const StrBuf *roomname;
        char pagename[128];
+       StrBuf *Buf;
 
-       output_headers(1, 1, 1, 0, 0, 0);
        roomname = sbstr("room");
        safestrncpy(pagename, bstr("page"), sizeof pagename);
+       str_wiki_index(pagename);
 
-       do_template("wiki_history", NULL);
+       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);
 }
 
@@ -143,6 +180,5 @@ InitModule_WIKI
 
        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);
 }
-
-