From f8f375ec302e0fb8de334d0d6c2ffc85d35ebb1a Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 28 Aug 2013 18:30:01 +1000 Subject: [PATCH] Sitemap theme: Minimum time between generating, and only generate on post-thread and post-delete --- templates/themes/sitemap/info.php | 9 +++++++++ templates/themes/sitemap/theme.php | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/templates/themes/sitemap/info.php b/templates/themes/sitemap/info.php index 43b529fa..0ea2ba9d 100644 --- a/templates/themes/sitemap/info.php +++ b/templates/themes/sitemap/info.php @@ -35,6 +35,15 @@ 'default' => 'hourly', 'size' => '20' ); + + $theme['config'][] = Array( + 'title' => 'Minimum time between regenerating', + 'name' => 'regen_time', + 'type' => 'text', + 'comment' => '(in seconds)', + 'default' => '0', + 'size' => '8' + ); $__boards = listBoards(); $__default_boards = Array(); diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 7e5b1984..1e36422d 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -11,9 +11,16 @@ // - post (a post has been made) // - thread (a thread has been made) - if ($action != 'post' && $action != 'post-thread' && $action != 'post-delete') + if ($action != 'post-thread' && $action != 'post-delete') return; + if ($settings['regen_time'] > 0) { + if ($last_gen = @filemtime($settings['path'])) { + if (time() - $last_gen < (int)$settings['regen_time']) + return; // Too soon + } + } + $boards = explode(' ', $settings['boards']); $threads = array();