4 * Functions pertaining to rooms with a wiki view
11 * Convert a string to something suitable as a wiki index
13 void str_wiki_index(char *s
)
17 if (s
== NULL
) return;
19 /* First remove all non-alphanumeric characters */
20 for (i
=0; i
<strlen(s
); ++i
) {
22 strcpy(&s
[i
], &s
[i
+1]);
26 /* Then make everything lower case */
27 for (i
=0; i
<strlen(s
); ++i
) {
33 * Display a specific page from a wiki room
35 void display_wiki_page(void)
37 const StrBuf
*roomname
;
42 roomname
= sbstr("room");
43 safestrncpy(pagename
, bstr("page"), sizeof pagename
);
44 str_wiki_index(pagename
);
46 if (StrLength(roomname
) > 0) {
48 /* If we're not in the correct room, try going there. */
49 if (strcasecmp(ChrPtr(roomname
), ChrPtr(WC
->wc_roomname
))) {
53 /* If we're still not in the correct room, it doesn't exist. */
54 if (strcasecmp(ChrPtr(roomname
), ChrPtr(WC
->wc_roomname
))) {
55 snprintf(errmsg
, sizeof errmsg
,
56 _("There is no room called '%s'."),
58 convenience_page("FF0000", _("Error"), errmsg
);
64 if (WC
->wc_view
!= VIEW_WIKI
) {
65 snprintf(errmsg
, sizeof errmsg
,
66 _("'%s' is not a Wiki room."),
68 convenience_page("FF0000", _("Error"), errmsg
);
72 if (IsEmptyStr(pagename
)) {
73 strcpy(pagename
, "home");
76 /* Found it! Now read it. */
77 msgnum
= locate_message_by_uid(pagename
);
79 output_headers(1, 1, 1, 0, 0, 0);
80 read_message(WC
->WBuf
, HKEY("view_message"), msgnum
, 0, NULL
);
85 output_headers(1, 1, 1, 0, 0, 0);
86 wprintf("<br /><br />"
87 "<div align=\"center\">"
88 "<table border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"10\">"
89 "<tr><td align=\"center\">"
92 wprintf(_("There is no page called '%s' here."), pagename
);
93 wprintf("</b><br><br>");
94 wprintf(_("Select the 'Edit this page' link in the room banner "
95 "if you would like to create this page."));
97 wprintf("</td></tr></table></div>\n");
105 WebcitAddUrlHandler(HKEY("wiki"), display_wiki_page
, 0);