Bring the saved search feature in line with the spec, and publish the feature spec.

This commit is contained in:
redmatrix 2016-09-28 20:55:15 -07:00
parent 245c2d4eed
commit 5b6c2c32bf
2 changed files with 73 additions and 35 deletions

View File

@ -18,49 +18,68 @@ class Search_ac extends \Zotlabs\Web\Controller {
$search = $_REQUEST['query'];
}
$do_people = true;
$do_tags = true;
if(substr($search,0,1) === '@') {
$do_tags = false;
$search = substr($search,1);
}
if(substr($search,0,1) === '#') {
$do_people = false;
$search = substr($search,1);
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%". dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%". dbesc($search) . "%' ");
$people_sql_extra = protect_sprintf(" AND xchan_name LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$results = [];
if($do_people) {
$r = q("SELECT abook_id, xchan_name, xchan_photo_s, xchan_url, xchan_addr FROM abook
left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
$people_sql_extra
ORDER BY xchan_name ASC ",
intval(local_channel())
);
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
$people_sql_extra
ORDER BY `xchan_name` ASC ",
intval(local_channel())
);
$results = array();
if($r) {
foreach($r as $g) {
$results[] = array(
"photo" => $g['xchan_photo_s'],
"name" => '@'.$g['xchan_name'],
"id" => $g['abook_id'],
"link" => $g['xchan_url'],
"label" => '',
"nick" => '',
);
if($r) {
foreach($r as $g) {
$results[] = [
'photo' => $g['xchan_photo_s'],
'name' => '@' . $g['xchan_name'],
'id' => $g['abook_id'],
'link' => $g['xchan_url'],
'label' => '',
'nick' => '',
];
}
}
}
if($do_tags) {
$r = q("select distinct term, tid, url from term
where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc",
intval(TERM_HASHTAG),
intval(TERM_COMMUNITYTAG)
);
$r = q("select distinct term, tid, url from term where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc",
intval(TERM_HASHTAG),
intval(TERM_COMMUNITYTAG)
);
if(count($r)) {
foreach($r as $g) {
$results[] = array(
"photo" => z_root() . '/images/hashtag.png',
"name" => '#'.$g['term'],
"id" => $g['tid'],
"link" => $g['url'],
"label" => '',
"nick" => '',
);
if($r) {
foreach($r as $g) {
$results[] = [
'photo' => z_root() . '/images/hashtag.png',
'name' => '#' . $g['term'],
'id' => $g['tid'],
'link' => $g['url'],
'label' => '',
'nick' => '',
];
}
}
}
@ -72,7 +91,7 @@ class Search_ac extends \Zotlabs\Web\Controller {
);
echo json_encode($o);
logger('search_ac: ' . print_r($x,true),LOGGER_ALL,LOG_INFO);
logger('search_ac: ' . print_r($x,true),LOGGER_DATA,LOG_INFO);
killme();
}

View File

@ -0,0 +1,19 @@
[h2]Saved Searches[/h2]
In order to quickly find information, the 'saved search' widget may be used. This widget may be presented as a sidebar tool on your network page and possibly from your channel page. It is differentiated from the 'navigation bar' search tool in that it does not search the entire site, but only the subset of information available to your channel.
Additionally the search terms you provide may activate a one-tme search or be saved in a list for re-use. Saving the search item also invokes the search in addition to adding it to the saved list (which is displayed below the search text entry box). Any item in the list may be discarded if it is no longer needed.
The saved search widget will provide autocompletion of channels (the results are prefixed with '@'), and hashtags (prefixed with '#'). You do not need to enter these tags; although entering the desired tag will reduce the autocomplete results to only hold the relevant information. The behaviour maps as follows:
[ul]
[li]@name - search your network stream for posts or comments written by 'name'. This will also change the post editor permissions to include only 'name'; as if it was a privacy group.[/li]
[li]#hashtag - search you network stream for posts containing #hashtag.[/li]
[li]text - search your network stream for posts containing 'text'.[/li]
[/li]