* move some more vars from the session context to strbuf (the use of StrBufAppendTemp...
[citadel.git] / webcit / wiki.c
index 0f35b6150a2a8b00e8b689c138fbf613ec9bd034..1bbb38dbe88711dc7733187081a24c6e839a2a27 100644 (file)
@@ -1,22 +1,14 @@
 /*
- * $Id:  $
- */
-/**
+ * $Id$
  *
- * \defgroup Wiki Wiki; Functions pertaining to rooms with a wiki view
- * \ingroup WebcitDisplayItems
+ * Functions pertaining to rooms with a wiki view
  */
 
-/*@{*/
 #include "webcit.h"
 #include "groupdav.h"
 
-
-
-/** 
- * \brief Convert a string to something suitable as a wiki index
- *
- * \param s The string to be converted.
+/* 
+ * Convert a string to something suitable as a wiki index
  */
 void str_wiki_index(char *s)
 {
@@ -37,32 +29,32 @@ void str_wiki_index(char *s)
        }
 }
 
-/**
- * \brief Display a specific page from a wiki room
+/*
+ * Display a specific page from a wiki room
  */
 void display_wiki_page(void)
 {
-       char roomname[128];
+       const StrBuf *roomname;
        char pagename[128];
        char errmsg[256];
        long msgnum = (-1L);
 
-       safestrncpy(roomname, bstr("room"), sizeof roomname);
+       roomname = sbstr("room");
        safestrncpy(pagename, bstr("page"), sizeof pagename);
        str_wiki_index(pagename);
 
-       if (strlen(roomname) > 0) {
+       if (StrLength(roomname) > 0) {
 
                /* If we're not in the correct room, try going there. */
-               if (strcasecmp(roomname, WC->wc_roomname)) {
+               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(roomname, WC->wc_roomname)) {
+               if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
                        snprintf(errmsg, sizeof errmsg,
-                               _("There is no room called '%s'."),
-                               roomname);
+                                _("There is no room called '%s'."),
+                                ChrPtr(roomname));
                        convenience_page("FF0000", _("Error"), errmsg);
                        return;
                }
@@ -72,12 +64,12 @@ void display_wiki_page(void)
        if (WC->wc_view != VIEW_WIKI) {
                snprintf(errmsg, sizeof errmsg,
                        _("'%s' is not a Wiki room."),
-                       roomname);
+                        ChrPtr(roomname));
                convenience_page("FF0000", _("Error"), errmsg);
                return;
        }
 
-       if (strlen(pagename) == 0) {
+       if (IsEmptyStr(pagename)) {
                strcpy(pagename, "home");
        }
 
@@ -85,7 +77,7 @@ void display_wiki_page(void)
        msgnum = locate_message_by_uid(pagename);
        if (msgnum >= 0L) {
                output_headers(1, 1, 1, 0, 0, 0);
-               read_message(msgnum, 0, "");
+               read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, NULL);
                wDumpContent(1);
                return;
        }
@@ -106,5 +98,10 @@ void display_wiki_page(void)
        wDumpContent(1);
 }
 
-
-/** @} */
+void 
+InitModule_WIKI
+(void)
+{
+       WebcitAddUrlHandler(HKEY("wiki"), display_wiki_page, 0);
+       return ;
+}