Merge branch 'master' of github.com:shish/shimmie2

This commit is contained in:
Shish 2012-03-13 17:53:01 +00:00
commit fa89b166d4
3 changed files with 10 additions and 13 deletions

View File

@ -15,6 +15,8 @@
* <li>[i]<i>italic</i>[/i] * <li>[i]<i>italic</i>[/i]
* <li>[u]<u>underline</u>[/u] * <li>[u]<u>underline</u>[/u]
* <li>[s]<s>strikethrough</s>[/s] * <li>[s]<s>strikethrough</s>[/s]
* <li>[sup]<sup>superscript</sup>[/sup]
* <li>[sub]<sub>subscript</sub>[/sub]
* <li>[[wiki article]] * <li>[[wiki article]]
* <li>[[wiki article|with some text]] * <li>[[wiki article|with some text]]
* <li>[quote]text[/quote] * <li>[quote]text[/quote]
@ -25,20 +27,19 @@
class BBCode extends FormatterExtension { class BBCode extends FormatterExtension {
public function format(/*string*/ $text) { public function format(/*string*/ $text) {
$text = preg_replace_callback("/(\[img\]https?:\/\/.*?\[\/img\])/s", array($this, "unwrap"), $text);
$text = preg_replace_callback("/(\[url=(?:https?|ftp|irc|mailto):\/\/.*?\])/s", array($this, "unwrap"), $text);
$text = preg_replace_callback("/(\[url\](?:https?|ftp|irc|mailto):\/\/.*?\[\/url\])/s", array($this, "unwrap"), $text);
$text = $this->extract_code($text); $text = $this->extract_code($text);
$text = preg_replace("/site:\/\//s", make_http(get_base_href())."/", $text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "<u>\\1</u>", $text); $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "<u>\\1</u>", $text);
$text = preg_replace("/\[s\](.*?)\[\/s\]/s", "<s>\\1</s>", $text); $text = preg_replace("/\[s\](.*?)\[\/s\]/s", "<s>\\1</s>", $text);
$text = preg_replace("/\[sup\](.*?)\[\/sup\]/s", "<sup>\\1</sup>", $text);
$text = preg_replace("/\[sub\](.*?)\[\/sub\]/s", "<sub>\\1</sub>", $text);
$text = preg_replace("/&gt;&gt;(\d+)(#c?(\d+))?/s", "<a class='comment_link' href=\"".make_link("post/view/\\1#c\\3")."\" onclick=\"$('#c\\3').effect('highlight', {}, 5000);\">&gt;&gt;\\1\\2</a>", $text); $text = preg_replace("/&gt;&gt;(\d+)(#c?(\d+))?/s", "<a class='comment_link' href=\"".make_link("post/view/\\1#c\\3")."\" onclick=\"$('#c\\3').effect('highlight', {}, 5000);\">&gt;&gt;\\1\\2</a>", $text);
$text = preg_replace("/(^|\s)#(\d+)/s", "\\1<a href=\"#\\2\">#\\2</a>", $text); $text = preg_replace("/(^|\s)#(\d+)/s", "\\1<a href=\"#\\2\">#\\2</a>", $text);
$text = preg_replace("/&gt;&gt;([^\d].+)/", "<blockquote><small>\\1</small></blockquote>", $text); $text = preg_replace("/&gt;&gt;([^\d].+)/", "<blockquote><small>\\1</small></blockquote>", $text);
$text = preg_replace("/\[url=((?:https?|ftp|irc|mailto):\/\/.*?)\](.*?)\[\/url\]/s", "<a href=\"\\1\">\\2</a>", $text); $text = preg_replace("/\[url=((?:https?|ftp|irc|mailto|site):\/\/.*?)\](.*?)\[\/url\]/s", "<a href=\"\\1\">\\2</a>", $text);
$text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto):\/\/.*?)\[\/url\]/s", "<a href=\"\\1\">\\1</a>", $text); $text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto|site):\/\/.*?)\[\/url\]/s", "<a href=\"\\1\">\\1</a>", $text);
$text = preg_replace("/\[email\](.*?)\[\/email\]/s", "<a href=\"mailto:\\1\">\\1</a>", $text); $text = preg_replace("/\[email\](.*?)\[\/email\]/s", "<a href=\"mailto:\\1\">\\1</a>", $text);
$text = preg_replace("/\[img\](https?:\/\/.*?)\[\/img\]/s", "<img src=\"\\1\">", $text); $text = preg_replace("/\[img\](https?:\/\/.*?)\[\/img\]/s", "<img src=\"\\1\">", $text);
$text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "<a href=\"".make_link("wiki/\\1")."\">\\2</a>", $text); $text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "<a href=\"".make_link("wiki/\\1")."\">\\2</a>", $text);
@ -66,10 +67,6 @@ class BBCode extends FormatterExtension {
return $text; return $text;
} }
private function unwrap($matches) {
return str_replace(' ', '', $matches[1]);
}
public function strip(/*string*/ $text) { public function strip(/*string*/ $text) {
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);

View File

@ -203,7 +203,7 @@ class CommentListTheme extends Themelet {
$hash = md5(strtolower($comment->owner_email)); $hash = md5(strtolower($comment->owner_email));
$h_avatar = "<img src=\"http://www.gravatar.com/avatar/$hash.jpg\"><br>"; $h_avatar = "<img src=\"http://www.gravatar.com/avatar/$hash.jpg\"><br>";
} }
$h_reply = " - <a href='javascript: replyTo($i_image_id, $i_comment_id)'>Reply</a>"; $h_reply = " - <a href='javascript: replyTo($i_image_id, $i_comment_id, \"$h_name\")'>Reply</a>";
$h_ip = $user->can("view_ip") ? "<br>".show_ip($comment->poster_ip, "Comment posted {$comment->posted}") : ""; $h_ip = $user->can("view_ip") ? "<br>".show_ip($comment->poster_ip, "Comment posted {$comment->posted}") : "";
$h_del = $user->can("delete_comment") ? $h_del = $user->can("delete_comment") ?
' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '. ' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '.

View File

@ -164,9 +164,9 @@ function deleteCookie( name, path, domain ) {
";expires=Thu, 01-Jan-1970 00:00:01 GMT"; ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
} }
function replyTo(imageId, commentId) { function replyTo(imageId, commentId, userId) {
var box = $("#comment_on_"+imageId); var box = $("#comment_on_"+imageId);
var text = ">>"+imageId+"#c"+commentId+": "; var text = "[url=site://post/view/"+imageId+"#c"+commentId+"]@"+userId+"[/url]: ";
box.focus(); box.focus();
box.val(box.val() + text); box.val(box.val() + text);