diff --git a/src/doc/user/usermanual.xml b/src/doc/user/usermanual.xml index a5e26a96..b10d87c5 100644 --- a/src/doc/user/usermanual.xml +++ b/src/doc/user/usermanual.xml @@ -2421,6 +2421,10 @@ fs.inotify.max_user_watches=32768 %Nresult Number inside the result page + %PParent folder + Url. In the case of an embedded document, this is the parent folder + for the top level container file. + %RRelevance percentage @@ -2445,6 +2449,14 @@ fs.inotify.max_user_watches=32768 where docnum (%N) expands to the document number inside the result page). + It is also possible to use a "F%N" value + as a link target. This will open the document corresponding to the + %P parent folder expansion, usually creating a + file manager window on the folder where the container file + resides. E.g.: + <a href="F%N">%P</a> + + In addition to the predefined values above, all strings like %(fieldname) will be replaced by the value of the field named fieldname for this @@ -5863,11 +5875,6 @@ x-my-tag = mailmytag from a container). - %F - Original file name. Same as %f except if a temporary - file is used. - - %i Internal path, for subdocuments of containers. The format depends on the container type. If this appears in the @@ -5895,7 +5902,7 @@ x-my-tag = mailmytag highlighting of the term. - %U, %u + %u Url. diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index 26a43d6d..b249011b 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -876,6 +876,22 @@ void ResList::linkWasClicked(const QUrl &url) } break; + // Open parent folder + case 'F': + { + int i = atoi(ascurl.c_str()+1) - 1; + Rcl::Doc doc; + if (!getDoc(i, doc)) { + LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i)); + return; + } + Rcl::Doc pdoc; + pdoc.url = url_parentfolder(doc.url); + pdoc.mimetype = "inode/directory"; + emit editRequested(pdoc); + } + break; + // Show query details case 'H': { diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 14320d5f..4a1317a8 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -764,6 +764,16 @@ void ResTable::linkWasClicked(const QUrl &url) m_rclmain->newDupsW(m_detaildoc, dups); } } + // Open parent folder + case 'F': + { + Rcl::Doc pdoc; + pdoc.url = url_parentfolder(m_detaildoc.url); + pdoc.mimetype = "inode/directory"; + emit editRequested(pdoc); + } + break; + case 'P': case 'E': { diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp index 7d999f92..f10c4e8b 100644 --- a/src/query/reslistpager.cpp +++ b/src/query/reslistpager.cpp @@ -179,6 +179,8 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc, titleOrFilename = utf8fn; } + string parenturl = url_parentfolder(url); + // Result number char numbuf[20]; int docnumforlinks = m_winfirst + 1 + i; @@ -286,6 +288,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc, subs["L"] = linksbuf.str(); subs["N"] = numbuf; subs["M"] = doc.mimetype; + subs["P"] = parenturl; subs["R"] = doc.meta[Rcl::Doc::keyrr]; subs["S"] = sizebuf; subs["T"] = maybeEscapeHtml(titleOrFilename); diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index e61ba2e5..22fa3c7d 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -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; diff --git a/src/utils/pathut.h b/src/utils/pathut.h index 873e8dcf..0e8b6777 100644 --- a/src/utils/pathut.h +++ b/src/utils/pathut.h @@ -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