From 7e95e80c25e2f35b8a49ebd73f95671b0233be6f Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 17 Jul 2013 10:17:28 -0400 Subject: [PATCH] New theme: XML sitemap generator --- templates/themes/sitemap/info.php | 53 ++++++++++++++++++++++++++++++++++++ templates/themes/sitemap/sitemap.xml | 19 +++++++++++++ templates/themes/sitemap/theme.php | 28 +++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 templates/themes/sitemap/info.php create mode 100644 templates/themes/sitemap/sitemap.xml create mode 100644 templates/themes/sitemap/theme.php diff --git a/templates/themes/sitemap/info.php b/templates/themes/sitemap/info.php new file mode 100644 index 00000000..e16448ee --- /dev/null +++ b/templates/themes/sitemap/info.php @@ -0,0 +1,53 @@ + 'Sitemap Path', + 'name' => 'path', + 'type' => 'text', + 'default' => 'sitemap.xml', + 'size' => '20' + ); + + $theme['config'][] = Array( + 'title' => 'URL prefix', + 'name' => 'url', + 'type' => 'text', + 'comment' => '(with trailing slash)', + 'default' => 'http://' . $_SERVER['HTTP_HOST'] . $config['root'], + 'size' => '20' + ); + + $theme['config'][] = Array( + 'title' => 'Thread change frequency', + 'name' => 'changefreq', + 'type' => 'text', + 'comment' => '(eg. "hourly", "daily", etc.)', + 'default' => 'hourly', + 'size' => '20' + ); + + $__boards = listBoards(); + $__default_boards = Array(); + foreach ($__boards as $__board) + $__default_boards[] = $__board['uri']; + + $theme['config'][] = Array( + 'title' => 'Boards', + 'name' => 'boards', + 'type' => 'text', + 'comment' => '(boards to include; space seperated)', + 'size' => 24, + 'default' => implode(' ', $__default_boards) + ); + + $theme['build_function'] = 'sitemap_build'; diff --git a/templates/themes/sitemap/sitemap.xml b/templates/themes/sitemap/sitemap.xml new file mode 100644 index 00000000..733da607 --- /dev/null +++ b/templates/themes/sitemap/sitemap.xml @@ -0,0 +1,19 @@ +{% filter remove_whitespace %} + + + {% for board in boards %} + + {{ settings.url ~ (config.board_path | format(board)) ~ config.file_index }} + + {% endfor %} + {% for board, thread_list in threads %} + {% for thread in thread_list %} + + {{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ (config.file_page | format(thread.thread_id)) }} + {{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }} + {{ settings.changefreq }} + + {% endfor %} + {% endfor %} + +{% endfilter %} \ No newline at end of file diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php new file mode 100644 index 00000000..372d292d --- /dev/null +++ b/templates/themes/sitemap/theme.php @@ -0,0 +1,28 @@ +fetchAll(PDO::FETCH_ASSOC); + } + + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'threads' => $threads, + 'boards' => $boards, + ))); + }