From 8a11c2941395bdd325ac076bd22ad011fe41f3c7 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 19:39:56 -0800 Subject: make links in comments bookmark-able --- include/bookmarks.php | 4 ++++ include/text.php | 2 +- mod/item.php | 4 ++-- view/js/main.js | 6 ++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/bookmarks.php b/include/bookmarks.php index 3ca8ee1c1..3a4c5c5d6 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -7,6 +7,10 @@ function bookmark_add($channel,$sender,$taxonomy,$private) { $iarr = array(); $channel_id = $channel['channel_id']; + + + + if($private) $iarr['contact_allow'] = array($channel['channel_hash']); $iarr['mitem_link'] = $taxonomy['url']; diff --git a/include/text.php b/include/text.php index dc7d94b6d..266d8952b 100755 --- a/include/text.php +++ b/include/text.php @@ -604,7 +604,7 @@ function get_tags($s) { // bookmarks - if(preg_match_all('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$s,$match,PREG_SET_ORDER)) { + if(preg_match_all('/#\^\[(url|zrl)(.*?)\](.*?)\[\/(url|zrl)\]/',$s,$match,PREG_SET_ORDER)) { foreach($match as $mtch) { $ret[] = $mtch[0]; } diff --git a/mod/item.php b/mod/item.php index 68bb75897..c8c0e3762 100644 --- a/mod/item.php +++ b/mod/item.php @@ -896,9 +896,9 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) { //is it a hash tag? if(strpos($tag,'#') === 0) { if(strpos($tag,'#^[') === 0) { - if(preg_match('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) { + if(preg_match('/#\^\[(url|zrl)(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) { $basetag = $match[3]; - $url = $match[2]; + $url = ((substr($match[2],0,1) === '=') ? substr($match[2],1) : $match[3]); $replaced = true; } diff --git a/view/js/main.js b/view/js/main.js index c8e9fc9a2..44cb79949 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -55,6 +55,8 @@ if(typeof(insertFormatting) != 'undefined') return(insertFormatting(comment,BBcode,id)); + var urlprefix = ((BBcode == 'url') ? '#^' : ''); + var tmpStr = $("#comment-edit-text-" + id).val(); if(tmpStr == comment) { tmpStr = ""; @@ -68,11 +70,11 @@ if (document.selection) { textarea.focus(); selected = document.selection.createRange(); - selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + selected.text = urlprefix+"["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; } else if (textarea.selectionStart || textarea.selectionStart == "0") { var start = textarea.selectionStart; var end = textarea.selectionEnd; - textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + textarea.value = textarea.value.substring(0, start) + urlprefix+"["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); } return true; } -- cgit v1.2.3