make tag autocomplete less scary looking in the editor. If this works out we can simplify and get rid of a huge amount of spaghetti tag logic.
This commit is contained in:
parent
a6c42e8756
commit
8face5a66c
@ -354,7 +354,7 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||||||
"name" => $g['name'] . (($type === 'f') ? '' : '+'),
|
"name" => $g['name'] . (($type === 'f') ? '' : '+'),
|
||||||
"id" => urlencode($g['id']) . (($type === 'f') ? '' : '+'),
|
"id" => urlencode($g['id']) . (($type === 'f') ? '' : '+'),
|
||||||
"xid" => $g['hash'],
|
"xid" => $g['hash'],
|
||||||
"link" => $g['nick'],
|
"link" => (($g['nick']) ? $g['nick'] : $g['url']),
|
||||||
"nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
|
"nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
|
||||||
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
|
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
|
||||||
"taggable" => 'taggable',
|
"taggable" => 'taggable',
|
||||||
@ -368,7 +368,7 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||||||
"name" => $g['name'],
|
"name" => $g['name'],
|
||||||
"id" => urlencode($g['id']),
|
"id" => urlencode($g['id']),
|
||||||
"xid" => $g['hash'],
|
"xid" => $g['hash'],
|
||||||
"link" => $g['nick'],
|
"link" => (($g['nick']) ? $g['nick'] : $g['url']),
|
||||||
"nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']),
|
"nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']),
|
||||||
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
|
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
|
||||||
"taggable" => '',
|
"taggable" => '',
|
||||||
|
@ -822,6 +822,14 @@ function get_tags($s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// match bracket mentions
|
||||||
|
|
||||||
|
if(preg_match_all('/([@!]\{.*?\})/',$s,$match)) {
|
||||||
|
foreach($match[1] as $mtch) {
|
||||||
|
$ret[] = $mtch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Match full names against @tags including the space between first and last
|
// Match full names against @tags including the space between first and last
|
||||||
// We will look these up afterward to see if they are full names or not recognisable.
|
// We will look these up afterward to see if they are full names or not recognisable.
|
||||||
|
|
||||||
@ -2029,17 +2037,32 @@ function undo_post_tagging($s) {
|
|||||||
$cnt = preg_match_all('/([@#])(\!*)\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$s,$matches,PREG_SET_ORDER);
|
$cnt = preg_match_all('/([@#])(\!*)\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$s,$matches,PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
|
$x = q("select xchan_addr, xchan_url from xchan where xchan_url = '%s' limit 1",
|
||||||
|
dbesc($mtch[3])
|
||||||
|
);
|
||||||
|
if($x) {
|
||||||
|
$s = str_replace($mtch[0], $mtch[1] . $mtch[2] . '{' . (($x[0]['xchan_addr']) ? $x[0]['xchan_addr'] : $x[0]['xchan_url']) . '}', $s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$s = str_replace($mtch[0], $mtch[1] . $mtch[2] . quote_tag($mtch[4]),$s);
|
$s = str_replace($mtch[0], $mtch[1] . $mtch[2] . quote_tag($mtch[4]),$s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// undo forum tags
|
// undo forum tags
|
||||||
$cnt = preg_match_all('/\!\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$s,$matches,PREG_SET_ORDER);
|
$cnt = preg_match_all('/\!\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$s,$matches,PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
|
$x = q("select xchan_addr, xchan_url from xchan where xchan_url = '%s' limit 1",
|
||||||
|
dbesc($mtch[1])
|
||||||
|
);
|
||||||
|
if($x) {
|
||||||
|
$s = str_replace($mtch[0], '!' . '{' . (($x[0]['xchan_addr']) ? $x[0]['xchan_addr'] : $x[0]['xchan_url']) . '}', $s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$s = str_replace($mtch[0], '!' . quote_tag($mtch[2]),$s);
|
$s = str_replace($mtch[0], '!' . quote_tag($mtch[2]),$s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
@ -2615,6 +2638,18 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
|
|||||||
$forum = false;
|
$forum = false;
|
||||||
$trailing_plus_name = false;
|
$trailing_plus_name = false;
|
||||||
|
|
||||||
|
if(substr($name,0,1) === '{' && substr($name,-1,1) === '}') {
|
||||||
|
$newname = substr($name,1);
|
||||||
|
$newname = substr($newname,0,-1);
|
||||||
|
|
||||||
|
$r = q("select * from xchan where xchan_addr = '%s' or xchan_url = '%s' limit 1",
|
||||||
|
dbesc($newname),
|
||||||
|
dbesc($newname)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! $r) {
|
||||||
|
|
||||||
// @channel+ is a forum or network delivery tag
|
// @channel+ is a forum or network delivery tag
|
||||||
|
|
||||||
if(substr($newname,-1,1) === '+') {
|
if(substr($newname,-1,1) === '+') {
|
||||||
@ -2664,6 +2699,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
|
|
||||||
|
@ -84,13 +84,8 @@ function editor_replace(item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// $2 ensures that prefix (@,@!) is preserved
|
// $2 ensures that prefix (@,@!) is preserved
|
||||||
var id = item.id;
|
|
||||||
// 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
|
|
||||||
// 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id).
|
|
||||||
if(id.length > 16)
|
|
||||||
id = item.id.substring(0,16);
|
|
||||||
|
|
||||||
return '$1$2' + item.nick.replace(' ', '') + '+' + id + ' ';
|
return '$1$2{' + item.link + '} ';
|
||||||
}
|
}
|
||||||
|
|
||||||
function basic_replace(item) {
|
function basic_replace(item) {
|
||||||
|
Reference in New Issue
Block a user