From ff30b54130909205d3d7832a3fedf7d766f8128d Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 22 Feb 2012 15:13:05 +0000 Subject: [PATCH] better solution, replace /post/view/123#456 with #456 if #456 exists --- ext/bbcode/main.php | 2 +- lib/shimmie.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 1c0e76e1..f4157bab 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -38,7 +38,7 @@ class BBCode extends FormatterExtension { $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text); $text = preg_replace("/\[s\](.*?)\[\/s\]/s", "\\1", $text); - $text = preg_replace("/>>(\d+)(#c?(\d+))?/s", ">>\\1\\2", $text); + $text = preg_replace("/>>(\d+)(#c?(\d+))?/s", ">>\\1\\2", $text); $text = preg_replace("/(^|\s)#(\d+)/s", "\\1#\\2", $text); $text = preg_replace("/>>([^\d].+)/", "
\\1
", $text); $text = preg_replace("/\[url=((?:https?|ftp|irc|mailto):\/\/.*?)\](.*?)\[\/url\]/s", "\\2", $text); diff --git a/lib/shimmie.js b/lib/shimmie.js index 35c55fb4..727e1b26 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -56,7 +56,10 @@ $(document).ready(function() { var target_id = $(elm).text().match(/#c?(\d+)/); if(target_id && $("#c"+target_id[1])) { var target_name = $("#c"+target_id[1]+" .username").html(); - $(elm).html("@"+target_name); + if(target_name) { + $(elm).attr("href", "#c"+target_id[1]); + $(elm).html("@"+target_name); + } } }); });