make links in comments bookmark-able

This commit is contained in:
friendica 2014-02-04 19:39:56 -08:00
parent 9f439c3248
commit 8a11c29413
4 changed files with 11 additions and 5 deletions

View File

@ -7,6 +7,10 @@ function bookmark_add($channel,$sender,$taxonomy,$private) {
$iarr = array(); $iarr = array();
$channel_id = $channel['channel_id']; $channel_id = $channel['channel_id'];
if($private) if($private)
$iarr['contact_allow'] = array($channel['channel_hash']); $iarr['contact_allow'] = array($channel['channel_hash']);
$iarr['mitem_link'] = $taxonomy['url']; $iarr['mitem_link'] = $taxonomy['url'];

View File

@ -604,7 +604,7 @@ function get_tags($s) {
// bookmarks // 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) { foreach($match as $mtch) {
$ret[] = $mtch[0]; $ret[] = $mtch[0];
} }

View File

@ -896,9 +896,9 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
//is it a hash tag? //is it a hash tag?
if(strpos($tag,'#') === 0) { if(strpos($tag,'#') === 0) {
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]; $basetag = $match[3];
$url = $match[2]; $url = ((substr($match[2],0,1) === '=') ? substr($match[2],1) : $match[3]);
$replaced = true; $replaced = true;
} }

View File

@ -55,6 +55,8 @@
if(typeof(insertFormatting) != 'undefined') if(typeof(insertFormatting) != 'undefined')
return(insertFormatting(comment,BBcode,id)); return(insertFormatting(comment,BBcode,id));
var urlprefix = ((BBcode == 'url') ? '#^' : '');
var tmpStr = $("#comment-edit-text-" + id).val(); var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == comment) { if(tmpStr == comment) {
tmpStr = ""; tmpStr = "";
@ -68,11 +70,11 @@
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = urlprefix+"["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; 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; return true;
} }