#include "support/debug.h"
#include "support/docstream.h"
#include "support/FileNameList.h"
+#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
<< " citation search pattern: " << lyxrc.citation_search_pattern);
docstring locator;
if (!file.empty()) {
- locator = file;
+ locator = provideScheme(file, from_ascii("file"));
} else if (!doi.empty()) {
- locator = doi;
+ locator = provideScheme(doi, from_ascii("doi"));
} else if (!url.empty()) {
locator = url;
} else {
locator = "EXTERNAL " + titledata;
}
+ LYXERR(Debug::INSETS, "Resolved locator: " << locator);
FuncRequest cmd = FuncRequest(LFUN_CITATION_OPEN, locator);
lyx::dispatch(cmd);
}
#include "support/Systemcall.h"
#include "support/qstring_helpers.h"
#include "support/TempFile.h"
+#include "support/textutils.h"
#include <QDir>
+#include <QUrl>
#include "support/lassert.h"
}
+docstring const provideScheme(docstring const & name, docstring const & scheme)
+{
+ QUrl url(toqstr(name));
+ if (!url.scheme().isEmpty())
+ // Has a scheme. Return as is.
+ return name;
+ if (scheme == from_ascii("doi")) {
+ // check if it is the pure DOI (without URL)
+ if (isDigitASCII(name[1]))
+ return from_ascii("https://doi.org/") + name;
+ }
+ url.setScheme(toqstr(scheme));
+ return qstring_to_ucs4(url.toString());
+}
+
+
string const unzippedFileName(string const & zipped_file)
{
string const ext = getExtension(zipped_file);
/// Return the extension of the file (not including the .)
std::string const getExtension(std::string const & name);
+/// Provide a scheme (such as "file") if not present. Assumes absolute path input.
+docstring const provideScheme(docstring const & name, docstring const & scheme);
+
/** \return the name that LyX will give to the unzipped file \p zipped_file
if the second argument of unzipFile() is empty.
*/