Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
refactor & change html pages
Browse files Browse the repository at this point in the history
  • Loading branch information
pldespaigne committed May 4, 2019
1 parent 987e58d commit 2d58cfc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 154 deletions.
52 changes: 0 additions & 52 deletions app/404.html

This file was deleted.

79 changes: 0 additions & 79 deletions app/error.html

This file was deleted.

1 change: 1 addition & 0 deletions app/images/enslogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 4 additions & 9 deletions app/loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 256px;
text-align: center;
}
#logo {
width: 100%;
width: 256px;
animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
Expand All @@ -33,13 +33,8 @@
</head>
<body>
<div id="div-logo">
<img id="logo" src="./images/loginglogo.svg">
<img id="logo" src="./images/enslogo.svg">
<h1 class="center">MetaMask is querying ENS ...</h1>
</div>
<script type="text/javascript">
// redirect to 404 after one minute
setTimeout(() => {
location.href = './404.html'
}, 60000)
</script>
</body>
</html>
20 changes: 6 additions & 14 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,25 @@ function setupEnsIpfsResolver ({ provider }) {

async function attemptResolve ({ tabId, name, path, search }) {
extension.tabs.update(tabId, { url: `loading.html` })
let url = `https://manager.ens.domains/name/${name}`
try {
let url = '400.html'
const {type, hash} = await resolveEnsToIpfsContentId({ provider, name })
if (type === 'ipfs-ns') {
url = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}`
const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}`
try {
// check if ipfs gateway has result
const response = await fetch(url, { method: 'HEAD' })
// if failure, redirect to 404 page
if (response.status !== 200) {
extension.tabs.update(tabId, { url: '404.html' })
return
}
// otherwise redirect to the correct page
extension.tabs.update(tabId, { url })
const response = await fetch(resolvedUrl, { method: 'HEAD' })
if (response.status === 200) url = resolvedUrl
} catch (err) {
console.warn(err)
// if HEAD fetch failed, redirect so user can see relevant error page
extension.tabs.update(tabId, { url })
}
} else if (type === 'swarm-ns') {
url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}`
}
extension.tabs.update(tabId, { url })
} catch (err) {
console.warn(err)
extension.tabs.update(tabId, { url: `error.html?name=${name}` })
} finally {
extension.tabs.update(tabId, { url })
}
}
}

0 comments on commit 2d58cfc

Please sign in to comment.