Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/assets/js/reprodb-profile-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
document.getElementById('inst-profile').classList.add('rdb-hidden');
}

function normalizeUrl(u) {
if (u && !u.match(/^https?:\/\//i) && /^10\.\d{4,}\//.test(u)) return 'https://doi.org/' + u;
return u;
}

function availTag(url) {
if (!url) return '';
var n = url.replace(/\/+$/, '');
Expand Down Expand Up @@ -79,7 +84,7 @@
columns: [
{ title: '#', formatter: 'rownum', width: 50, headerSort: false },
{ title: 'Title', field: 'title', formatter: function(cell) {
var d = cell.getData(), t = d.title.replace(/\.+$/, ''), u = artifactUrlMap[t] || '';
var d = cell.getData(), t = d.title.replace(/\.+$/, '').toLowerCase(), u = artifactUrlMap[t] || '';
return (u ? '<a href="' + escHtml(u) + '" target="_blank" rel="noopener">' + escHtml(d.title) + '</a>' : escHtml(d.title)) + availTag(u);
}, headerSort: false },
{ title: 'Conference', field: 'conference' },
Expand Down Expand Up @@ -246,7 +251,7 @@
(p.papers || []).forEach(function(paper) {
if (!paperMap[paper.title]) {
var t = paper.title.replace(/\.+$/, '');
paperMap[paper.title] = { title: paper.title, authors: [], conference: paper.conference, year: paper.year, badges: paper.badges, url: artifactUrlMap[t] || '' };
paperMap[paper.title] = { title: paper.title, authors: [], conference: paper.conference, year: paper.year, badges: paper.badges, url: artifactUrlMap[t.toLowerCase()] || '' };
}
paperMap[paper.title].authors.push(p.name);
});
Expand Down Expand Up @@ -441,11 +446,11 @@
citedArtifactsMap = res[2] || {};
authorRankHistory = res[3] || [];

// Build artifact URL map
// Build artifact URL map (lowercase keys for case-insensitive lookup)
(res[4] || []).forEach(function(a) {
var urls = a.artifact_urls || [];
var u = urls.length ? urls[0] : (a.artifact_url || a.repository_url || '');
if (a.title && u) artifactUrlMap[a.title.replace(/\.+$/, '')] = u;
if (a.title && u) artifactUrlMap[a.title.replace(/\.+$/, '').toLowerCase()] = normalizeUrl(u);
});

// Build paper index
Expand Down
17 changes: 11 additions & 6 deletions src/assets/js/reprodb-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

var escHtml = ReproDB.escHtml;

function normalizeUrl(u) {
if (u && !u.match(/^https?:\/\//i) && /^10\.\d{4,}\//.test(u)) return 'https://doi.org/' + u;
return u;
}

function normalizeText(s) {
return (s || '').toLowerCase().replace(/[^a-z0-9 ]/g, ' ');
}
Expand Down Expand Up @@ -199,8 +204,8 @@
entry.className = 'rdb-result-entry';

// Line 1: Bold title (linked to artifact)
var artUrls = d.artifact_urls || [];
var titleLink = artUrls.length > 0 ? artUrls[0] : (d.repository_url || d.artifact_url || '');
var artUrls = (d.artifact_urls || []).map(normalizeUrl);
var titleLink = artUrls.length > 0 ? artUrls[0] : normalizeUrl(d.repository_url || d.artifact_url || '');
var titleHtml = titleLink
? '<a href="' + escHtml(titleLink) + '" target="_blank" rel="noopener">' + escHtml(d.title) + '</a>'
: escHtml(d.title);
Expand All @@ -224,12 +229,12 @@
var links = [];
// Paper link: prefer doi_url, fall back to paper_url
if (d.doi_url) {
links.push('<a href="' + escHtml(d.doi_url) + '" target="_blank" rel="noopener">📄 Paper</a>');
links.push('<a href="' + escHtml(normalizeUrl(d.doi_url)) + '" target="_blank" rel="noopener">📄 Paper</a>');
} else if (d.paper_url) {
links.push('<a href="' + escHtml(d.paper_url) + '" target="_blank" rel="noopener">📄 Paper</a>');
links.push('<a href="' + escHtml(normalizeUrl(d.paper_url)) + '" target="_blank" rel="noopener">📄 Paper</a>');
}
// Artifact URLs (unified list)
var artUrlList = d.artifact_urls || [];
var artUrlList = artUrls;
if (artUrlList.length === 1) {
var isGH = artUrlList[0].indexOf('github.com') !== -1;
var lbl = isGH ? '💻 GitHub' : '📦 Artifact';
Expand All @@ -246,7 +251,7 @@
}
});
}
if (d.appendix_url) links.push('<a href="' + escHtml(d.appendix_url) + '" target="_blank" rel="noopener">📋 Appendix</a>');
if (d.appendix_url) links.push('<a href="' + escHtml(normalizeUrl(d.appendix_url)) + '" target="_blank" rel="noopener">📋 Appendix</a>');
var linksLine = links.length > 0 ? links.join(' &middot; ') : '';

entry.innerHTML =
Expand Down