* Got a primitive version of the wiki system in place. Needs a lot of fine
authorArt Cancro <ajc@citadel.org>
Tue, 24 Jan 2006 03:51:59 +0000 (03:51 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 24 Jan 2006 03:51:59 +0000 (03:51 +0000)
  tuning but it basically works.

webcit/ChangeLog
webcit/messages.c
webcit/roomops.c
webcit/webcit.h
webcit/wiki.c

index ff2b02f9d3314f66dd93043e66e83cc55882637c..7fabeaed4e1402f6a9d680d366a8d617af2f2ed9 100644 (file)
@@ -1,5 +1,9 @@
 $Id$
 
+Mon Jan 23 22:51:11 EST 2006 ajc
+* Got a primitive version of the wiki system in place.  Needs a lot of fine
+  tuning but it basically works.
+
 Fri Jan 20 21:03:25 CET 2006 dothebart
 * finished doxygen style comments.
 
index 23a1e2ef6c3725c24c31ff6152ec7c5d76b2c8c5..9dc54cfcd6afa6f7727cda8aa410715e9c7c3939 100644 (file)
@@ -2527,12 +2527,13 @@ void post_message(void)
                        _("Automatically cancelled because you have already "
                        "saved this message."));
        } else {
-               sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s",
+               sprintf(buf, "ENT0 1|%s|%d|4|%s|||%s|%s|%s",
                        bstr("recp"),
                        is_anonymous,
                        bstr("subject"),
                        bstr("cc"),
-                       bstr("bcc")
+                       bstr("bcc"),
+                       bstr("wikipage")
                );
                serv_puts(buf);
                serv_getln(buf, sizeof buf);
@@ -2575,6 +2576,7 @@ void display_enter(void)
        int recipient_bad = 0;
        int i;
        int is_anonymous = 0;
+       long existing_page = (-1L);
 
        if (strlen(bstr("force_room")) > 0) {
                gotoroom(bstr("force_room"));
@@ -2638,7 +2640,8 @@ void display_enter(void)
 
        /** Now check our actual recipients if there are any */
        if (recipient_required) {
-               sprintf(buf, "ENT0 0|%s|%d|0||||%s|%s", bstr("recp"), is_anonymous, bstr("cc"), bstr("bcc"));
+               sprintf(buf, "ENT0 0|%s|%d|0||||%s|%s|%s", bstr("recp"), is_anonymous,
+                       bstr("cc"), bstr("bcc"), bstr("wikipage"));
                serv_puts(buf);
                serv_getln(buf, sizeof buf);
 
@@ -2676,6 +2679,9 @@ void display_enter(void)
                "name=\"enterform\""
                ">\n");
        wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
+       if (WC->wc_view == VIEW_WIKI) {
+               wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
+       }
 
        wprintf("<img src=\"static/newmess3_24x.gif\" align=middle alt=\" \">");
        wprintf("%s\n", buf);   /** header bar */
@@ -2773,6 +2779,16 @@ void display_enter(void)
                wprintf("</blockquote>\n\n");
        }
 
+       /** If we're editing a wiki page, insert the existing page here... */
+       else if (WC->wc_view == VIEW_WIKI) {
+               safestrncpy(buf, bstr("wikipage"), sizeof buf);
+               str_wiki_index(buf);
+               existing_page = locate_message_by_uid(buf);
+               if (existing_page >= 0L) {
+                       pullquote_message(existing_page, 1);
+               }
+       }
+
        /** Insert our signature if appropriate... */
        if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) {
                get_preference("use_sig", buf, sizeof buf);
index aa38db4db7fb0fe0f9aef0f1dcde84b3fe27a30d..68476bfb5f20f99af0d813bb8fba1b4cf9bab5c9 100644 (file)
@@ -352,7 +352,7 @@ void embed_view_o_matic(void) {
  * \param navbar_style
  */
 void embed_room_banner(char *got, int navbar_style) {
-       char fakegot[SIZ];
+       char buf[256];
 
        /**
         * We need to have the information returned by a GOTO server command.
@@ -360,8 +360,8 @@ void embed_room_banner(char *got, int navbar_style) {
         */
        if (got == NULL) {
                serv_printf("GOTO %s", WC->wc_roomname);
-               serv_getln(fakegot, sizeof fakegot);
-               got = fakegot;
+               serv_getln(buf, sizeof buf);
+               got = buf;
        }
 
        /** The browser needs some information for its own use */
@@ -538,7 +538,15 @@ void embed_room_banner(char *got, int navbar_style) {
                                        );
                                        break;
                                case VIEW_WIKI:
-                                       /* Don't let users create unlinked pages. */
+                                       safestrncpy(buf, bstr("page"), sizeof buf);
+                                       str_wiki_index(buf);
+                                       wprintf(
+                                               "<td><a href=\"display_enter?wikipage=%s\">"
+                                               "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
+                                               "border=\"0\"><span class=\"navbar_link\">"
+                                               "%s"
+                                               "</span></a></td>\n", buf, _("Edit this page")
+                                       );
                                        break;
                                default:
                                        wprintf(
index df8e2be113e770db20eaca688801ad89e3e02a30..93ec4e3d20643533da1e3700fce31c4c13b0b530 100644 (file)
@@ -672,6 +672,7 @@ void httplang_to_locale(char *LocaleString);
 void tabbed_dialog(int num_tabs, char *tabnames[]);
 void begin_tab(int tabnum, int num_tabs);
 void end_tab(int tabnum, int num_tabs);
+void str_wiki_index(char *s);
 void display_wiki_page(void);
 
 void embed_room_banner(char *, int);
index 9d6a6b59b6da5979c89a50299f287bca4cdc7227..852650cb643a0b2dbca81ffce929aa8c9d7fe14f 100644 (file)
@@ -50,18 +50,22 @@ void display_wiki_page(void)
        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 (strlen(roomname) > 0) {
+
+               /* If we're not in the correct room, try going there. */
+               if (strcasecmp(roomname, WC->wc_roomname)) {
+                       gotoroom(roomname);
+               }
+       
+               /* 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 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) {