Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 84165 invoked from network); 27 Dec 2008 05:05:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Dec 2008 05:05:13 -0000 Received: (qmail 36506 invoked by uid 500); 27 Dec 2008 05:05:13 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 36442 invoked by uid 500); 27 Dec 2008 05:05:13 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 36433 invoked by uid 99); 27 Dec 2008 05:05:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Dec 2008 21:05:13 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Dec 2008 05:05:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 54C24238895F; Fri, 26 Dec 2008 21:04:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r729595 - in /httpd/sandbox/mod_mbox-3: SConstruct module-2.0/mod_mbox.h module-2.0/mod_mbox_index.c module-2.0/mod_mbox_sitemap.c Date: Sat, 27 Dec 2008 05:04:47 -0000 To: cvs@httpd.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081227050447.54C24238895F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pquerna Date: Fri Dec 26 21:04:46 2008 New Revision: 729595 URL: http://svn.apache.org/viewvc?rev=729595&view=rev Log: Add support for generating Sitemaps of mail archives. Added: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c (with props) Modified: httpd/sandbox/mod_mbox-3/SConstruct httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox.h httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c Modified: httpd/sandbox/mod_mbox-3/SConstruct URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/SConstruct?rev=729595&r1=729594&r2=729595&view=diff ============================================================================== --- httpd/sandbox/mod_mbox-3/SConstruct (original) +++ httpd/sandbox/mod_mbox-3/SConstruct Fri Dec 26 21:04:46 2008 @@ -51,6 +51,7 @@ mod_mbox_index.c mod_mbox_cte.c mod_mbox_mime.c + mod_mbox_sitemap.c """)] module = env.LoadableModule(target = "mod_mbox.so", source = [modsources, libsources]) Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox.h URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox.h?rev=729595&r1=729594&r2=729595&view=diff ============================================================================== --- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox.h (original) +++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox.h Fri Dec 26 21:04:46 2008 @@ -99,6 +99,7 @@ /* Handlers */ int mbox_atom_handler(request_rec *r, mbox_cache_info *mli); +int mbox_sitemap_handler(request_rec *r, mbox_cache_info *mli); int mbox_file_handler(request_rec *r); int mbox_index_handler(request_rec *r); Modified: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c?rev=729595&r1=729594&r2=729595&view=diff ============================================================================== --- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c (original) +++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_index.c Fri Dec 26 21:04:46 2008 @@ -176,6 +176,10 @@ return mbox_atom_handler(r, mli); } + if (r->args && strstr(r->args, "format=sitemap") != NULL) { + return mbox_sitemap_handler(r, mli); + } + /* Only allow GETs */ r->allowed |= (AP_METHOD_BIT << M_GET); if (r->method_number != M_GET) { Added: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c?rev=729595&view=auto ============================================================================== --- httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c (added) +++ httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c Fri Dec 26 21:04:46 2008 @@ -0,0 +1,123 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * This file contains functions for generating a Sitemap, to make indexing + * by search engines easier on both them, and us: + * + */ + +#include "mod_mbox.h" + +static void mbox2sitemap(request_rec *r, const char *mboxfile, + mbox_cache_info *mli) +{ + char *filename; + char *origfilename; + MBOX_LIST *head; + Message *m; + apr_pool_t *tpool; + + filename = apr_pstrcat(r->pool, r->filename, mboxfile, NULL); + origfilename = r->filename; + + r->filename = filename; + + head = mbox_load_index(r, NULL, NULL); + + r->filename = origfilename; + + apr_pool_create(&tpool, r->pool); + while (head != NULL) { + char dstr[100]; + apr_size_t dlen; + apr_time_exp_t extime; + + m = (Message *) head->value; + ap_rputs("\n", r); + + ap_rprintf(r, "%s%s/%s\n", + ap_construct_url(tpool, r->uri, r), + mboxfile, URI_ESCAPE_OR_BLANK(tpool, m->msgID)); + + apr_time_exp_gmt(&extime, m->date); + apr_strftime(dstr, &dlen, sizeof(dstr), "%G-%m-%d", &extime); + + ap_rprintf(r, "%s\n", dstr); + ap_rputs("never\n", r); + ap_rputs("\n", r); + head = head->next; + apr_pool_clear(tpool); + } +} + +static void mbox_sitemap_entries(request_rec *r, mbox_cache_info *mli) +{ + mbox_file_t *fi; + apr_array_header_t *files; + int i; + + files = mbox_fetch_boxes_list(r, mli, r->filename); + if (!files) { + return; + } + + fi = (mbox_file_t *) files->elts; + for (i = 0; i < files->nelts; i++) { + if (!fi[i].count) { + continue; + } + mbox2sitemap(r, fi[i].filename, mli); + } +} + +int mbox_sitemap_handler(request_rec *r, mbox_cache_info *mli) +{ + int errstatus; + char *etag; + + /* Only allow GETs */ + r->allowed |= (AP_METHOD_BIT << M_GET); + if (r->method_number != M_GET) { + return HTTP_METHOD_NOT_ALLOWED; + } + + ap_set_content_type(r, "text/xml; charset=utf-8"); + + /* Try to make the index page more cache friendly */ + ap_update_mtime(r, mli->mtime); + ap_set_last_modified(r); + etag = ap_make_etag(r, 1); + apr_table_setn(r->headers_out, "ETag", etag); + + if (r->header_only) { + return OK; + } + + if ((errstatus = ap_meets_conditions(r)) != OK) { + r->status = errstatus; + return r->status; + } + + ap_rputs("\n", r); + ap_rputs("\n", r); + mbox_sitemap_entries(r, mli); + ap_rputs("\n", r); + + return OK; +} + Propchange: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: httpd/sandbox/mod_mbox-3/module-2.0/mod_mbox_sitemap.c ------------------------------------------------------------------------------ svn:mime-type = text/plain