From e5565ddcab9de0af337e084c925548a2ccf370e4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 11 Aug 2008 21:16:00 -0400 Subject: fix some errors in sitemaps Only show notices that don't have a remote URL. That should include only local notices. Also, don't do an avatar sitemap; apparently nobody indexes these anyways. darcs-hash:20080812011600-84dde-680d39ef8379605febd16ed52c529711e8e1ccc9.gz --- sitemap.php | 51 ++++++++------------------------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) (limited to 'sitemap.php') diff --git a/sitemap.php b/sitemap.php index ca1819658..8480207be 100644 --- a/sitemap.php +++ b/sitemap.php @@ -11,7 +11,6 @@ $output_paths = parse_args(); standard_map(); notices_map(); user_map(); -avatar_map(); index_map(); # ------------------------------------------------------------------------------ @@ -83,7 +82,7 @@ function notices_map() { $notices = DB_DataObject::factory('notice'); - $notices->query('SELECT uri, modified FROM notice'); + $notices->query('SELECT uri, url, modified FROM notice'); $notice_count = 0; $map_count = 1; @@ -96,16 +95,19 @@ function notices_map() { $map_count++; } - $notice = array( + # remote notices have an URL + + if (!$notices->url) { + $notice = array( 'url' => $notices->uri, 'lastmod' => common_date_w3dtf($notices->modified), 'changefreq' => 'daily', 'priority' => '1', ); - $notice_list[$map_count] .= url($notice); - - $notice_count++; + $notice_list[$map_count] .= url($notice); + $notice_count++; + } } # Make full sitemaps from the lists and save them. @@ -201,43 +203,6 @@ function user_map() { array_to_map($foaf_list, 'foaf'); } -# Generate sitemaps of all avatars. -function avatar_map() { - global $output_paths; - - $avatars = new Avatar(); - $avatars->whereAdd('original = 1', "OR"); - $avatars->whereAdd('width = ' . AVATAR_MINI_SIZE, 'OR'); - - if (!$avatars->find()) { - return 0; - } - - $avatar_count = 0; - $map_count = 1; - - while ($avatars->fetch()) { - - # Maximum 50,000 URLs per sitemap file. - if ($avatar_count == 50000) { - $avatar_count = 0; - $map_count++; - } - $image = array( - 'url' => common_avatar_display_url($avatars), - 'lastmod' => common_date_w3dtf($avatars->modified), - 'changefreq' => 'never', - 'priority' => '0.2', - ); - - # Construct a element for each avatar and add it - # to our existing list of those. - $avatar_list[$map_count] .= url($image); - } - - array_to_map($avatar_list, 'avatars'); -} - # ------------------------------------------------------------------------------ # XML generation functions # ------------------------------------------------------------------------------ -- cgit v1.2.3-54-g00ecf