Feature: support any tag separator
So it allows to have multiple words tags. Breaking change: commas ',' are no longer a default separator. Fixes #594
This commit is contained in:
parent
48df9f45b8
commit
b3bd8c3e8d
38 changed files with 585 additions and 114 deletions
application/http
|
@ -29,14 +29,16 @@ class HttpAccess
|
|||
&$title,
|
||||
&$description,
|
||||
&$keywords,
|
||||
$retrieveDescription
|
||||
$retrieveDescription,
|
||||
$tagsSeparator
|
||||
) {
|
||||
return get_curl_download_callback(
|
||||
$charset,
|
||||
$title,
|
||||
$description,
|
||||
$keywords,
|
||||
$retrieveDescription
|
||||
$retrieveDescription,
|
||||
$tagsSeparator
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -550,7 +550,8 @@ function get_curl_download_callback(
|
|||
&$title,
|
||||
&$description,
|
||||
&$keywords,
|
||||
$retrieveDescription
|
||||
$retrieveDescription,
|
||||
$tagsSeparator
|
||||
) {
|
||||
$currentChunk = 0;
|
||||
$foundChunk = null;
|
||||
|
@ -568,6 +569,7 @@ function get_curl_download_callback(
|
|||
*/
|
||||
return function ($ch, $data) use (
|
||||
$retrieveDescription,
|
||||
$tagsSeparator,
|
||||
&$charset,
|
||||
&$title,
|
||||
&$description,
|
||||
|
@ -598,10 +600,10 @@ function get_curl_download_callback(
|
|||
if (! empty($keywords)) {
|
||||
$foundChunk = $currentChunk;
|
||||
// Keywords use the format tag1, tag2 multiple words, tag
|
||||
// So we format them to match Shaarli's separator and glue multiple words with '-'
|
||||
$keywords = implode(' ', array_map(function($keyword) {
|
||||
return implode('-', preg_split('/\s+/', trim($keyword)));
|
||||
}, explode(',', $keywords)));
|
||||
// So we split the result with `,`, then if a tag contains the separator we replace it by `-`.
|
||||
$keywords = tags_array2str(array_map(function(string $keyword) use ($tagsSeparator): string {
|
||||
return tags_array2str(tags_str2array($keyword, $tagsSeparator), '-');
|
||||
}, tags_str2array($keywords, ',')), $tagsSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ class MetadataRetriever
|
|||
$title = null;
|
||||
$description = null;
|
||||
$tags = null;
|
||||
$retrieveDescription = $this->conf->get('general.retrieve_description');
|
||||
|
||||
// Short timeout to keep the application responsive
|
||||
// The callback will fill $charset and $title with data from the downloaded page.
|
||||
|
@ -52,7 +51,8 @@ class MetadataRetriever
|
|||
$title,
|
||||
$description,
|
||||
$tags,
|
||||
$retrieveDescription
|
||||
$this->conf->get('general.retrieve_description'),
|
||||
$this->conf->get('general.tags_separator', ' ')
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue