+void BibTeXInfo::getLocators(docstring & doi, docstring & url, docstring & file) const
+{
+ if (is_bibtex_) {
+ // get "doi" entry from citation record
+ doi = operator[]("doi");
+ if (!doi.empty() && !prefixIs(doi,from_ascii("http")))
+ doi = "https://doi.org/" + doi;
+ // get "url" entry from citation record
+ url = operator[]("url");
+ // get "file" entry from citation record
+ file = operator[]("file");
+
+ // Jabref case, "file" field has a format (depending on exporter):
+ // Description:Location:Filetype;Description:Location:Filetype...
+ // or simply:
+ // Location;Location;...
+ // We will strip out the locations and return an \n-separated list
+ if (!file.empty()) {
+ docstring filelist;
+ vector<docstring> files = getVectorFromString(file, from_ascii(";"));
+ for (auto const & f : files) {
+ // first try if we have Description:Location:Filetype
+ docstring ret, filedest, tmp;
+ ret = split(f, tmp, ':');
+ tmp = split(ret, filedest, ':');
+ if (filedest.empty())
+ // we haven't, so use the whole string
+ filedest = f;
+ // TODO howto deal with relative directories?
+ FileName fn(to_utf8(filedest));
+ if (fn.exists()) {
+ if (!filelist.empty())
+ filelist += '\n';
+ filelist += "file:///" + filedest;
+ }
+ }
+ if (!filelist.empty())
+ file = filelist;
+ }
+
+ // kbibtex case, "localfile" field with format:
+ // file1.pdf;file2.pdf
+ // We will strip out the locations and return an \n-separated list
+ docstring kfile;
+ if (file.empty())
+ kfile = operator[]("localfile");
+ if (!kfile.empty()) {
+ docstring filelist;
+ vector<docstring> files = getVectorFromString(kfile, from_ascii(";"));
+ for (auto const & f : files) {
+ // TODO howto deal with relative directories?
+ FileName fn(to_utf8(f));
+ if (fn.exists()) {
+ if (!filelist.empty())
+ filelist += '\n';
+ filelist = "file:///" + f;
+ }
+ }
+ if (!filelist.empty())
+ file = filelist;
+ }
+
+ if (!url.empty())
+ return;
+
+ // try biblatex specific fields, see its manual
+ // 3.13.7 "Electronic Publishing Informationl"
+ docstring eprinttype = operator[]("eprinttype");
+ docstring eprint = operator[]("eprint");
+ if (eprint.empty())
+ return;
+
+ if (eprinttype == "arxiv")
+ url = "https://arxiv.org/abs/" + eprint;
+ if (eprinttype == "jstor")
+ url = "https://www.jstor.org/stable/" + eprint;
+ if (eprinttype == "pubmed")
+ url = "http://www.ncbi.nlm.nih.gov/pubmed/" + eprint;
+ if (eprinttype == "hdl")
+ url = "https://hdl.handle.net/" + eprint;
+ if (eprinttype == "googlebooks")
+ url = "http://books.google.com/books?id=" + eprint;
+
+ return;
+ }
+
+ // Here can be handled the bibliography environment. All one could do
+ // here is let LyX scan the entry for URL or HRef insets.
+}
+
+