From: Art Cancro Date: Fri, 10 Sep 2010 22:22:00 +0000 (-0400) Subject: Sitemaps! X-Git-Tag: v8.01~721 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=27894d501e017e45172cae54097693b46bce86c4 Sitemaps! --- diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 9189c9096..2b1ba5de4 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -53,7 +53,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ calendar.o calendar_tools.o calendar_view.o tasks.o event.o smtpqueue.o \ availability.o iconbar.o crypto.o inetconf.o notes.o wiki.o \ groupdav_main.o groupdav_get.o groupdav_propfind.o fmt_date.o \ - groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o \ + groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o sitemap.o \ groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \ downloads.o addressbook_popup.o pushemail.o sysdep.o openid.o \ decode.o modules_init.o paramhandling.o utils.o \ @@ -69,7 +69,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ summary.o calendar.o calendar_tools.o calendar_view.o tasks.o event.o wiki.o \ availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \ groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \ - groupdav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o \ + groupdav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o sitemap.o \ groupdav_put.o http_datestring.o setup_wizard.o fmt_date.o modules_init.o \ gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o decode.o \ paramhandling.o utils.o ical_maps.o ical_subst.o static.o feed_generator.o \ diff --git a/webcit/sitemap.c b/webcit/sitemap.c new file mode 100644 index 000000000..0bc394b98 --- /dev/null +++ b/webcit/sitemap.c @@ -0,0 +1,102 @@ +/* + * XML sitemap generator + * + * Copyright (c) 2010 by the citadel.org team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "webcit.h" +#include "webserver.h" + + +/* + * XML sitemap generator -- go through the message list + */ +void sitemap_do_messages(void) { + wcsession *WCC = WC; + int num_msgs = 0; + int i; + SharedMessageStatus Stat; + message_summary *Msg = NULL; + + memset(&Stat, 0, sizeof Stat); + Stat.maxload = INT_MAX; + Stat.lowest_found = (-1); + Stat.highest_found = (-1); + num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL); + if (num_msgs < 1) return; + + for (i=0; isumm); + if (Msg != NULL) { + wc_printf("%s/readfwd", ChrPtr(site_prefix)); + wc_printf("?gotofirst="); + urlescputs(ChrPtr(WC->CurRoom.name)); + wc_printf("?start_reading_at=%ld", Msg->msgnum); + wc_printf("\r\n"); + } + } +} + + +/* + * Entry point for RSS feed generator + */ +void sitemap(void) { + + output_headers(0, 0, 0, 0, 1, 0); + hprintf("Content-type: text/xml\r\n"); + hprintf( + "Server: %s / %s\r\n" + "Connection: close\r\n" + , + PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software) + ); + begin_burst(); + + wc_printf("\r\n"); + wc_printf("\r\n"); + + HashList *roomlist = GetRoomListHashLKRA(NULL, NULL); + HashPos *it = GetNewHashPos(roomlist, 0); + long HKlen; + const char *HashKey; + folder *room; + + while (GetNextHashPos(roomlist, it, &HKlen, &HashKey, (void *)&room)) + { + /* Output the messages in this room only if it's a message board */ + if (room->defview == VIEW_BBS) + { + gotoroom(room->name); + sitemap_do_messages(); + } + } + + DeleteHashPos(&it); + DeleteHash(&roomlist); + + wc_printf("\r\n"); + wDumpContent(0); +} + + +void +InitModule_SITEMAP +(void) +{ + WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED); +} diff --git a/webcit/webcit.h b/webcit/webcit.h index 054ed3000..6b3de478d 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -809,6 +809,7 @@ long guess_calhourformat(void); int get_time_format_cached (void); const char *get_selected_language(void); void display_wiki_pagelist(void); +HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP); #define DATEFMT_FULL 0 #define DATEFMT_BRIEF 1