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/main.js | 1 +
templates/mod/debug/recent_posts.html | 2 +-
templates/mod/search_results.html | 4 ++--
templates/post_reply.html | 4 ++--
templates/post_thread.html | 10 +++++-----
templates/posts.sql | 1 +
templates/themes/catalog/theme.php | 2 +-
templates/themes/recent/theme.php | 4 ++--
templates/themes/sitemap/sitemap.xml | 4 ++--
templates/themes/sitemap/theme.php | 2 +-
10 files changed, 18 insertions(+), 16 deletions(-)
(limited to 'templates')
diff --git a/templates/main.js b/templates/main.js
index ead852fe..e948fd82 100644
--- a/templates/main.js
+++ b/templates/main.js
@@ -146,6 +146,7 @@ function changeStyle(styleName, link) {
{% endraw %}
{% if config.stylesheets_board %}
{# This is such an unacceptable mess. There needs to be an easier way. #}
+ {# Needs fix for slugify #}
var matches = document.URL.match(/\/(\w+)\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }})/);
{% raw %}
if (matches) {
diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html
index e4eb4f3a..ce4cffc4 100644
--- a/templates/mod/debug/recent_posts.html
+++ b/templates/mod/debug/recent_posts.html
@@ -63,7 +63,7 @@
{% else %}
{% set thread = post.id %}
{% endif %}
-
+
{{ post.id }}
diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html
index 0d3c2a10..186ee5db 100644
--- a/templates/mod/search_results.html
+++ b/templates/mod/search_results.html
@@ -195,7 +195,7 @@
{% else %}
{% set thread = post.id %}
{% endif %}
-
+
{{ post.id }}
@@ -265,4 +265,4 @@
[{{ i + 1 }}]
{% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/templates/post_reply.html b/templates/post_reply.html
index e7343230..451ff1b9 100644
--- a/templates/post_reply.html
+++ b/templates/post_reply.html
@@ -12,8 +12,8 @@
{% include 'post/time.html' %}
{% include 'post/poster_id.html' %}
- No.
- {{ post.id }}
+ No.
+ {{ post.id }}
{% include 'post/fileinfo.html' %}
{% include 'post/post_controls.html' %}
diff --git a/templates/post_thread.html b/templates/post_thread.html
index 08b4c4c1..61146491 100644
--- a/templates/post_thread.html
+++ b/templates/post_thread.html
@@ -15,8 +15,8 @@
{% include 'post/time.html' %}
{% include 'post/poster_id.html' %}
- No.
- {{ post.id }}
+ No.
+ {{ post.id }}
{% if post.sticky %}
{% if config.font_awesome %}
@@ -39,14 +39,14 @@
{% endif %}
{% endif %}
{% if index %}
- [{% trans %}Reply{% endtrans %}]
+ [{% trans %}Reply{% endtrans %}]
{% endif %}
{% if isnoko50 %}
- [{% trans %}View All{% endtrans %}]
+ [{% trans %}View All{% endtrans %}]
{% endif %}
{% if hasnoko50 and not isnoko50 %}
{% set lastcount = config.noko50_count %}
- [{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}]
+ [{% trans %}Last 1 Post{% plural lastcount %}Last {{ count }} Posts{% endtrans %}]
{% endif %}
{% include 'post/post_controls.html' %}
diff --git a/templates/posts.sql b/templates/posts.sql
index 9a47c6ad..6b2249ef 100644
--- a/templates/posts.sql
+++ b/templates/posts.sql
@@ -19,6 +19,7 @@ CREATE TABLE IF NOT EXISTS ``posts_{{ board }}`` (
`locked` int(1) NOT NULL,
`sage` int(1) NOT NULL,
`embed` text,
+ `slug` varchar(256) DEFAULT NULL,
UNIQUE KEY `id` (`id`),
KEY `thread_id` (`thread`,`id`),
KEY `filehash` (`filehash`(40)),
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