Gui result list: add %P substitution for parent folder and F link target for opening the parent folder
This commit is contained in:
@@ -525,6 +525,20 @@ string url_gpath(const string& url)
|
||||
return path_canon(url.substr(colon+1));
|
||||
}
|
||||
|
||||
string url_parentfolder(const string& url)
|
||||
{
|
||||
// In general, the parent is the directory above the full path
|
||||
string parenturl = path_getfather(url_gpath(url));
|
||||
// But if this is http, make sure to keep the host part. Recoll
|
||||
// only has file or http urls for now.
|
||||
bool isfileurl = urlisfileurl(url);
|
||||
if (!isfileurl && parenturl == "/") {
|
||||
parenturl = url_gpath(url);
|
||||
}
|
||||
return isfileurl ? string("file://") + parenturl :
|
||||
string("http://") + parenturl;
|
||||
}
|
||||
|
||||
// Convert to file path if url is like file:
|
||||
// Note: this only works with our internal pseudo-urls which are not
|
||||
// encoded/escaped
|
||||
@@ -540,6 +554,7 @@ string fileurltolocalpath(string url)
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
bool urlisfileurl(const string& url)
|
||||
{
|
||||
return url.find("file://") == 0;
|
||||
|
||||
@@ -60,6 +60,8 @@ extern bool printableUrl(const std::string &fcharset,
|
||||
extern std::string fileurltolocalpath(std::string url);
|
||||
/// Test for file:/// url
|
||||
extern bool urlisfileurl(const std::string& url);
|
||||
///
|
||||
extern std::string url_parentfolder(const std::string& url);
|
||||
|
||||
/// Return the host+path part of an url. This is not a general
|
||||
/// routine, it does the right thing only in the recoll context
|
||||
|
||||
Reference in New Issue
Block a user