wiki
[citadel.git] / webcit / wiki.c
1 /*
2  * $Id:  $
3  */
4 /**
5  *
6  * \defgroup Wiki Wiki; Functions pertaining to rooms with a wiki view
7  *
8  */
9
10 /*@{*/
11 #include "webcit.h"
12
13
14
15 /** 
16  * \brief Convert a string to something suitable as a wiki index
17  *
18  * \param s The string to be converted.
19  */
20 void str_wiki_index(char *s)
21 {
22         int i;
23
24         if (s == NULL) return;
25
26         /* First remove all non-alphanumeric characters */
27         for (i=0; i<strlen(s); ++i) {
28                 if (!isalnum(s[i])) {
29                         strcpy(&s[i], &s[i+1]);
30                 }
31         }
32
33         /* Then make everything lower case */
34         for (i=0; i<strlen(s); ++i) {
35                 s[i] = tolower(s[i]);
36         }
37 }
38
39 /**
40  * \brief Display a specific page from a wiki room
41  */
42 void display_wiki_page(void)
43 {
44         char roomname[128];
45         char pagename[128];
46
47         safestrncpy(roomname, bstr("room"), sizeof roomname);
48         safestrncpy(pagename, bstr("page"), sizeof pagename);
49         str_wiki_index(pagename);
50
51         wprintf("roomname=%s<br>pagename=%s<br>\n", roomname, pagename);
52
53         if (strcasecmp(roomname, WC->roomname)) {
54                 gotoroom(roomname);
55         }
56
57         if (strcasecmp(roomname, WC->roomname)) {
58                 /* can't find the room */
59                 convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext);
60         }
61
62         output_headers(1, 1, 1, 0, 0, 0);
63         wDumpContent(1);
64 }
65
66
67 /** @} */