X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwiki.c;h=b1822e951a0ee17d5df2bcc5b63d6df8cb467977;hb=HEAD;hp=c6904c2bdca8463cd66d8d9434bf5c34be182480;hpb=4d0a622d2d3ae20770258981c6062f58c9fc01a3;p=citadel.git diff --git a/webcit/wiki.c b/webcit/wiki.c index c6904c2bd..390bf3cbe 100644 --- a/webcit/wiki.c +++ b/webcit/wiki.c @@ -1,7 +1,7 @@ /* * Functions pertaining to rooms with a wiki view * - * Copyright (c) 2009-2012 by the citadel.org team + * Copyright (c) 2009-2021 by the citadel.org team * * This program is open source software. You can redistribute it and/or * modify it under the terms of the GNU General Public License, version 3. @@ -18,23 +18,10 @@ /* * Convert a string to something suitable as a wiki index */ -void str_wiki_index(char *s) +void str_wiki_index(StrBuf *s) { - int i; - - if (s == NULL) return; - - /* First remove all non-alphanumeric characters */ - for (i=0; iCurRoom.view != VIEW_WIKI) && - (WCC->CurRoom.view != VIEW_WIKIMD)) { - wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WCC->CurRoom.name) ); + if (WC->CurRoom.view != VIEW_WIKI) { + wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name) ); return; } - if (IsEmptyStr(pagename)) { - strcpy(pagename, "home"); + if (StrLength(pagename) == 0) { + StrBufPlain(pagename, HKEY("home")); } str_wiki_index(pagename); /* convert index name to lowercase and numeric only */ if ((rev != NULL) && (strlen(rev) > 0)) { /* read an older revision */ - serv_printf("WIKI rev|%s|%s|%s", pagename, rev, (do_revert ? "revert" : "fetch") ); + serv_printf("WIKI rev|%s|%s|%s", ChrPtr(pagename), rev, (do_revert ? "revert" : "fetch") ); serv_getln(buf, sizeof buf); if (buf[0] == '2') { msgnum = extract_long(&buf[4], 0); @@ -72,26 +57,15 @@ void display_wiki_page_backend(char *pagename, char *rev, int do_revert) } else { /* read the current revision */ - msgnum = locate_message_by_uid(pagename); + msgnum = locate_message_by_uid(ChrPtr(pagename)); } if (msgnum >= 0L) { - read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL); + read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL); return; } - - wc_printf("

" - "
" - "" - "
" - ); - wc_printf("
"); - wc_printf(_("There is no page called '%s' here."), pagename); - wc_printf("

"); - wc_printf(_("Select the 'Edit this page' link in the room banner " - "if you would like to create this page.")); - wc_printf("

"); - wc_printf("
\n"); + putbstr("pagename", pagename); + do_template("wiki_empty"); } @@ -100,12 +74,12 @@ void display_wiki_page_backend(char *pagename, char *rev, int do_revert) */ void display_wiki_page(void) { - char pagename[128]; + StrBuf *pagename; char rev[128]; int do_revert = 0; output_headers(1, 1, 1, 0, 0, 0); - safestrncpy(pagename, bstr("page"), sizeof pagename); + pagename = NewStrBufDup(sbstr("page")); str_wiki_index(pagename); safestrncpy(rev, bstr("rev"), sizeof rev); do_revert = atoi(bstr("revert")); @@ -119,14 +93,14 @@ void display_wiki_page(void) */ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP) { - char pagename[128]; + StrBuf *pagename; StrBuf *Buf; int row = 0; - safestrncpy(pagename, bstr("page"), sizeof pagename); + pagename = NewStrBufDup(sbstr("page")); str_wiki_index(pagename); - serv_printf("WIKI history|%s", pagename); + serv_printf("WIKI history|%s", ChrPtr(pagename)); Buf = NewStrBuf(); StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 1) { @@ -150,19 +124,11 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP) wc_printf("", ((row%2) ? "#FFFFFF" : "#DDDDDD")); wc_printf("%s", rev_date_displayed); - if (!strcasecmp(ChrPtr(node), (char *)WC->serv_info->serv_nodename)) { - escputs(ChrPtr(author)); - wc_printf(" @ "); - escputs(ChrPtr(node)); - } - else { - wc_printf(""); - escputs(ChrPtr(author)); - wc_printf(""); - } - wc_printf(""); + wc_printf(""); + escputs(ChrPtr(author)); + wc_printf(""); if (row == 0) { wc_printf("Hdr->HR.ReqLine), pch) != NULL; + return bmstrcasestr((char *)ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL; } @@ -350,18 +315,6 @@ InitModule_WIKI NULL ); - RegisterReadLoopHandlerset( - VIEW_WIKIMD, - wiki_GetParamsGetServerCall, - wiki_PrintHeaderPage, - NULL, - NULL, - NULL, - NULL, - wiki_Cleanup, - NULL - ); - WebcitAddUrlHandler(HKEY("wiki"), "", 0, display_wiki_page, 0); WebcitAddUrlHandler(HKEY("wiki_history"), "", 0, display_wiki_history, 0); WebcitAddUrlHandler(HKEY("wiki_pagelist"), "", 0, display_wiki_pagelist, 0);