From bdb6001f3f7e93e0b9655c0491bbef6f1df8a5fa Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 12:48:59 +0100 Subject: support for slugified links; may introduce a few bugs --- templates/themes/catalog/theme.php | 2 +- templates/themes/recent/theme.php | 4 ++-- templates/themes/sitemap/sitemap.xml | 4 ++-- templates/themes/sitemap/theme.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'templates/themes') diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 9ba2d27a..b3b7caf7 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -42,7 +42,7 @@ $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])); + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post)); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index b1153477..2ea6a7b9 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -62,7 +62,7 @@ // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] - . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + . link_for($post) . '#' . $post['id']; if ($files) { if ($files[0]->thumb == 'spoiler') { @@ -92,7 +92,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id']; if ($post['body'] != "") $post['snippet'] = pm_snippet($post['body'], 30); else diff --git a/templates/themes/sitemap/sitemap.xml b/templates/themes/sitemap/sitemap.xml index 733da607..95dfdd26 100644 --- a/templates/themes/sitemap/sitemap.xml +++ b/templates/themes/sitemap/sitemap.xml @@ -9,11 +9,11 @@ {% 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)) }} + {{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }} {{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }} {{ settings.changefreq }} {% endfor %} {% endfor %} -{% endfilter %} \ No newline at end of file +{% endfilter %} diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 3e048dd5..1cebcdb6 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -26,7 +26,7 @@ $threads = array(); foreach ($boards as $board) { - $query = query(sprintf("SELECT `id` AS `thread_id`, (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()); + $query = query(sprintf("SELECT `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); } -- cgit v1.3