]> code.citadel.org Git - citadel.git/blobdiff - webcit/wiki.c
* split tasks view into its own file
[citadel.git] / webcit / wiki.c
index 9d6a6b59b6da5979c89a50299f287bca4cdc7227..efc3c88902a9b19bbe5bb264799f3b118ae5e546 100644 (file)
@@ -1,21 +1,14 @@
 /*
- * $Id:  $
- */
-/**
- *
- * \defgroup Wiki Wiki; Functions pertaining to rooms with a wiki view
+ * $Id$
  *
+ * 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)
 {
@@ -36,43 +29,48 @@ 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 *Mime;
+       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 we're not in the correct room, try going there. */
-       if (strcasecmp(roomname, WC->wc_roomname)) {
-               gotoroom(roomname);
-       }
+       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))) {
+                       snprintf(errmsg, sizeof errmsg,
+                                _("There is no room called '%s'."),
+                                ChrPtr(roomname));
+                       convenience_page("FF0000", _("Error"), errmsg);
+                       return;
+               }
 
-       /* If we're still not in the correct room, it doesn't exist. */
-       if (strcasecmp(roomname, WC->wc_roomname)) {
-               snprintf(errmsg, sizeof errmsg,
-                       _("There is no room called '%s'."),
-                       roomname);
-               convenience_page("FF0000", _("Error"), errmsg);
-               return;
        }
 
        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");
        }
 
@@ -80,7 +78,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, NULL, &Mime);
                wDumpContent(1);
                return;
        }
@@ -94,13 +92,40 @@ void display_wiki_page(void)
        wprintf("<br><b>");
        wprintf(_("There is no page called '%s' here."), pagename);
        wprintf("</b><br><br>");
-       wprintf("<a href=\"display_enter?wikipage=%s\">", pagename);
-       wprintf(_("Click here if you would like to create this page."));
-       wprintf("</a>");
+       wprintf(_("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");
        wDumpContent(1);
 }
 
+int wiki_GetParamsGetServerCall(SharedMessageStatus *Stat, 
+                                          void **ViewSpecific, 
+                                          long oper, 
+                                          char *cmd, 
+                                          long len)
+{
+       char buf[SIZ];
+       sprintf(buf, "wiki?room=%s&page=home", ChrPtr(WC->wc_roomname));
+       http_redirect(buf);
+       return 300;
+}
+
+void 
+InitModule_WIKI
+(void)
+{
+       RegisterReadLoopHandlerset(
+               VIEW_WIKI,
+               wiki_GetParamsGetServerCall,
+               NULL,
+               NULL,
+               NULL,
+               NULL
+               );
+
+       WebcitAddUrlHandler(HKEY("wiki"), display_wiki_page, 0);
+       return ;
+}
+
 
-/** @} */