summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Discussions/Lib.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNWeb/Discussions/Lib.pm')
-rw-r--r--lib/VNWeb/Discussions/Lib.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/VNWeb/Discussions/Lib.pm b/lib/VNWeb/Discussions/Lib.pm
index 88f6cac6..4ab1900c 100644
--- a/lib/VNWeb/Discussions/Lib.pm
+++ b/lib/VNWeb/Discussions/Lib.pm
@@ -3,7 +3,14 @@ package VNWeb::Discussions::Lib;
use VNWeb::Prelude;
use Exporter 'import';
-our @EXPORT = qw/sql_visible_threads enrich_boards threadlist_ boardsearch_ boardtypes_/;
+our @EXPORT = qw/post_url sql_visible_threads enrich_boards threadlist_ boardsearch_ boardtypes_/;
+
+
+# Returns the URL to the thread page holding the given post (with optional location.hash)
+sub post_url {
+ my($id, $num, $hash) = @_;
+ "/t$id".($num > 25 ? '/'.ceil($num/25) : '').($hash ? "#$hash" : '');
+}
# Returns a WHERE condition to filter threads that the current user is allowed to see.
@@ -94,7 +101,7 @@ sub threadlist_ {
td_ class => 'tc4', sub {
user_ $l, 'lastpost_';
txt_ ' @ ';
- a_ href => "/t$l->{id}.$l->{count}", fmtdate $l->{lastpost_date}, 'full';
+ a_ href => post_url($l->{id}, $l->{count}, 'last'), fmtdate $l->{lastpost_date}, 'full';
};
} for @$lst;
}