mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 01:10:51 +01:00
sitemap theme for smart_build
This commit is contained in:
parent
61d2729a40
commit
e273111340
@ -105,6 +105,11 @@ function sb_recent() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sb_sitemap() {
|
||||||
|
rebuildTheme("sitemap", "all");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$entrypoints = array();
|
$entrypoints = array();
|
||||||
|
|
||||||
$entrypoints['/%b/'] = 'sb_board';
|
$entrypoints['/%b/'] = 'sb_board';
|
||||||
@ -130,6 +135,7 @@ $entrypoints['/*/'] = 'sb_ukko';
|
|||||||
$entrypoints['/*/index.html'] = 'sb_ukko';
|
$entrypoints['/*/index.html'] = 'sb_ukko';
|
||||||
$entrypoints['/recent.html'] = 'sb_recent';
|
$entrypoints['/recent.html'] = 'sb_recent';
|
||||||
$entrypoints['/%b/catalog.html'] = 'sb_catalog';
|
$entrypoints['/%b/catalog.html'] = 'sb_catalog';
|
||||||
|
$entrypoints['/sitemap.xml'] = 'sb_sitemap';
|
||||||
|
|
||||||
$reached = false;
|
$reached = false;
|
||||||
|
|
||||||
@ -185,6 +191,9 @@ if ($reached) {
|
|||||||
elseif (preg_match('/\.js$/', $request)) {
|
elseif (preg_match('/\.js$/', $request)) {
|
||||||
header("Content-Type", "text/javascript; charset=utf-8");
|
header("Content-Type", "text/javascript; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
elseif (preg_match('/\.xml$/', $request)) {
|
||||||
|
header("Content-Type", "application/xml");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
header("Content-Type", "text/html; charset=utf-8");
|
header("Content-Type", "text/html; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
@ -11,29 +11,36 @@
|
|||||||
// - post (a post has been made)
|
// - post (a post has been made)
|
||||||
// - thread (a thread has been made)
|
// - thread (a thread has been made)
|
||||||
|
|
||||||
if ($action != 'post-thread' && $action != 'post-delete')
|
if ($action != 'all') {
|
||||||
return;
|
if ($action != 'post-thread' && $action != 'post-delete')
|
||||||
|
return;
|
||||||
|
|
||||||
if (isset($settings['regen_time']) && $settings['regen_time'] > 0) {
|
if (isset($settings['regen_time']) && $settings['regen_time'] > 0) {
|
||||||
if ($last_gen = @filemtime($settings['path'])) {
|
if ($last_gen = @filemtime($settings['path'])) {
|
||||||
if (time() - $last_gen < (int)$settings['regen_time'])
|
if (time() - $last_gen < (int)$settings['regen_time'])
|
||||||
return; // Too soon
|
return; // Too soon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$boards = explode(' ', $settings['boards']);
|
if ($config['smart_build']) {
|
||||||
|
file_unlink($settings['path']);
|
||||||
$threads = array();
|
|
||||||
|
|
||||||
foreach ($boards as $board) {
|
|
||||||
$query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error());
|
|
||||||
$threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$boards = explode(' ', $settings['boards']);
|
||||||
|
|
||||||
file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array(
|
$threads = array();
|
||||||
'settings' => $settings,
|
|
||||||
'config' => $config,
|
foreach ($boards as $board) {
|
||||||
'threads' => $threads,
|
$query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error());
|
||||||
'boards' => $boards,
|
$threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
)));
|
}
|
||||||
|
|
||||||
|
file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array(
|
||||||
|
'settings' => $settings,
|
||||||
|
'config' => $config,
|
||||||
|
'threads' => $threads,
|
||||||
|
'boards' => $boards,
|
||||||
|
)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user