support for slugified links; may introduce a few bugs

This commit is contained in:
czaks 2015-03-10 12:48:59 +01:00
parent eb245c2970
commit bdb6001f3f
18 changed files with 145 additions and 43 deletions

View file

@ -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)) {

View file

@ -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

View file

@ -9,11 +9,11 @@
{% for board, thread_list in threads %}
{% for thread in thread_list %}
<url>
<loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ (config.file_page | format(thread.thread_id)) }}</loc>
<loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }}</loc>
<lastmod>{{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}</lastmod>
<changefreq>{{ settings.changefreq }}</changefreq>
</url>
{% endfor %}
{% endfor %}
</urlset>
{% endfilter %}
{% endfilter %}

View file

@ -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);
}