Generate links to hyperlinked source code on Hackage instead of links to documentation

This commit is contained in:
alexwl 2018-10-06 01:15:16 +03:00
parent a221abf41c
commit 579a0f16c4
3 changed files with 10 additions and 19 deletions

View File

@ -9,21 +9,14 @@ function exactLocationToUrl(exactLocation) {
}
function hackageUrl(packageId,locationInfo) {
const dasherizedModuleName = locationInfo.moduleName.replace(/\./g,'-');
let key;
if(locationInfo.entity === "Val") {
key = "v";
} else {
key = "t";
}
let hash = "";
if(locationInfo.entity === "Val" || locationInfo.entity === "Typ") {
hash = "#"+key+":"+locationInfo.haddockAnchorId;
}
return "https://hackage.haskell.org/package/"+packageId+"/docs/"+dasherizedModuleName+".html"+hash;
if (locationInfo.entity !== "Mod") {
hash = "#" + encodeURIComponent(locationInfo.name);
}
return "https://hackage.haskell.org/package/"+packageId+"/docs/src/"+locationInfo.moduleName+".html"+hash;
}
function openUrl(buttonId,url) {
function openUrl(buttonId,url) {
if(buttonId === 2) {//middle mouse button
window.open(url, '_blank');
} else if(buttonId == 1) {//left mouse button

View File

@ -174,10 +174,8 @@ var o=document.querySelector("style#color-theme")
o&&o.parentElement.removeChild(o),document.getElementsByTagName("head")[0].appendChild(n)}Object.defineProperty(e,"__esModule",{value:!0})
var o={id:"darkTheme",name:"Dark theme",description:"Dark theme (Monokai based)",defaultColor:"#F8F8F2",backgroundColor:"#272822",typeColor:"#66D9EF",literalColor:"#E6DB74",topLevelIdFromCurrentModule:"#A6E22E",localIdentifierColor:["#F0A3FF","#0075DC","#993F00","#2BCE48","#FFCC99","#808080","#94FFB5","#8F7C00","#C20088","#FFA405","#FFA8BB","#426600","#FF0010","#5EF1F2","#00998F","#E0FF66","#FFFF80","#FFFF00","#FF5005"],menuColor:"#3c3b37",menuLinkColor:"#F8F8F2",infoWindowColor:"#3c3b37",navigationPanelColor:"#3c3b37",linkColor:"#0366d6",borderColor:"#535557",highlightedLineColor:"#4a4a4a"},r={id:"lightTheme",name:"Light theme",description:"Light theme (Github based)",defaultColor:"#24292e",backgroundColor:"#ffffff",typeColor:"#005cc5",literalColor:"#032f62",topLevelIdFromCurrentModule:"#6f42c1",localIdentifierColor:["#005C31","#2BCE48","#808080","#8F7C00","#C20088","#FFA405","#ffa8bb","#426600","#FF0010","#09d7d8","#00998F","#990000","#FF5005"],menuColor:"#f2f4f8",menuLinkColor:"#24292e",infoWindowColor:"#f2f4f8",navigationPanelColor:"#f2f4f8",linkColor:"#0366d6",borderColor:"#e1e4e8",highlightedLineColor:"#eaeaea"},i={darkTheme:o,lightTheme:r}
e.updateColorThemeCss=n,e.colorThemeToCss=t,e.themes=i}),define("haskell-code-explorer/utils/go-to-definition",["exports"],function(e){function t(e){var t=e.modulePath,n=e.packageId.name+"-"+e.packageId.version,o=""
return 1!=e.startLine&&(o="#L"+e.startLine),"/package/"+n+"/show/"+t+o}function n(e,t){var n=t.moduleName.replace(/\./g,"-"),o=void 0
o="Val"===t.entity?"v":"t"
var r=""
return"Val"!==t.entity&&"Typ"!==t.entity||(r="#"+o+":"+t.haddockAnchorId),"https://hackage.haskell.org/package/"+e+"/docs/"+n+".html"+r}function o(e,t){return 2===e?window.open(t,"_blank"):1==e&&(window.location=t),!1}function r(e){if(e){var t=window.location.origin+window.location.pathname+"#L"+e
return 1!=e.startLine&&(o="#L"+e.startLine),"/package/"+n+"/show/"+t+o}function n(e,t){var n=""
return"Mod"!==t.entity&&(n="#"+encodeURIComponent(t.name)),"https://hackage.haskell.org/package/"+e+"/docs/src/"+t.moduleName+".html"+n}function o(e,t){return 2===e?window.open(t,"_blank"):1==e&&(window.location=t),!1}function r(e){if(e){var t=window.location.origin+window.location.pathname+"#L"+e
location.href!=t&&(window.location.hash="#L"+e)}}function i(e,i,l,s){if("ExactLocation"===i.tag){var a=t(i)
i.startLine!==s&&r(s),o(l,a)}else if("ApproximateLocation"===i.tag){var c=i.packageId.name+"-"+i.packageId.version
"Mod"===i.entity?e.loadDefinitionSite(c,i.moduleName,i.componentId,i.entity,i.moduleName).then(function(e){var t=e.location.packageId.name+"-"+e.location.packageId.version
@ -203,4 +201,4 @@ return c&&o(c,e),[a]}}}function o(e,t){e.parentNode.scrollIntoView()
var n=t.parentNode.parentNode,o=n.offsetHeight
t.offsetHeight-n.scrollTop>o&&(n.scrollTop=n.scrollTop-(o/2-20))}function r(e,t,n){Array.prototype.slice.call(e.querySelectorAll("td.line-content")).forEach(function(e){var o=parseInt(e.id.substring(2))
o>=t&&o<=n?e.classList.add("highlighted-line"):e.classList.remove("highlighted-line")})}Object.defineProperty(e,"__esModule",{value:!0}),e.initializeLineSelection=t,e.highlightLines=r,e.highlightSelectedLines=n}),define("haskell-code-explorer/config/environment",[],function(){try{var e="haskell-code-explorer/config/environment",t=document.querySelector('meta[name="'+e+'"]').getAttribute("content"),n=JSON.parse(unescape(t)),o={default:n}
return Object.defineProperty(o,"__esModule",{value:!0}),o}catch(t){throw new Error('Could not read config from meta tag with name "'+e+'".')}}),runningTests||require("haskell-code-explorer/app").default.create({staticUrlPrefix:"/files",apiUrlPrefix:"/api",haskellCodeExplorerDirectory:".haskell-code-explorer",title:"Haskell code explorer",name:"haskell-code-explorer",version:"0.0.1+d2b1a420"})
return Object.defineProperty(o,"__esModule",{value:!0}),o}catch(t){throw new Error('Could not read config from meta tag with name "'+e+'".')}}),runningTests||require("haskell-code-explorer/app").default.create({staticUrlPrefix:"/files",apiUrlPrefix:"/api",haskellCodeExplorerDirectory:".haskell-code-explorer",title:"Haskell code explorer",name:"haskell-code-explorer",version:"0.0.1+a221abf4"})

File diff suppressed because one or more lines are too long