-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improved experience on DNSLink websites (#826)
- Loading branch information
Showing
13 changed files
with
160 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const browser = require('webextension-polyfill') | ||
const { findValueForContext } = require('./context-menus') | ||
const { pathAtHttpGateway } = require('./ipfs-path') | ||
|
||
function createInspector (notify, ipfsPathValidator, getState) { | ||
return { | ||
async viewOnGateway (context, contextType) { | ||
const url = await findValueForContext(context, contextType) | ||
const ipfsPath = ipfsPathValidator.resolveToIpfsPath(url) | ||
const gateway = getState().pubGwURLString | ||
const gatewayUrl = pathAtHttpGateway(ipfsPath, gateway) | ||
await browser.tabs.create({ url: gatewayUrl }) | ||
} | ||
// TODO: view in WebUI's Files | ||
// TODO: view in WebUI's IPLD Explorer | ||
} | ||
} | ||
|
||
module.exports = createInspector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use strict' | ||
/* eslint-env browser, webextensions */ | ||
|
||
const browser = require('webextension-polyfill') | ||
const html = require('choo/html') | ||
const switchToggle = require('../../pages/components/switch-toggle') | ||
|
||
function dnslinkForm ({ | ||
dnslinkPolicy, | ||
dnslinkRedirect, | ||
onOptionChange | ||
}) { | ||
const onDnslinkPolicyChange = onOptionChange('dnslinkPolicy') | ||
const onDnslinkRedirectChange = onOptionChange('dnslinkRedirect') | ||
|
||
return html` | ||
<form> | ||
<fieldset> | ||
<legend>${browser.i18n.getMessage('option_header_dnslink')}</legend> | ||
<div> | ||
<label for="dnslinkPolicy"> | ||
<dl> | ||
<dt>${browser.i18n.getMessage('option_dnslinkPolicy_title')}</dt> | ||
<dd> | ||
${browser.i18n.getMessage('option_dnslinkPolicy_description')} | ||
<p><a href="https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/dnslink.md#dnslink-support-in-ipfs-companion" target="_blank"> | ||
${browser.i18n.getMessage('option_legend_readMore')} | ||
</a></p> | ||
</dd> | ||
</dl> | ||
</label> | ||
<select id="dnslinkPolicy" name='dnslinkPolicy' onchange=${onDnslinkPolicyChange}> | ||
<option | ||
value='false' | ||
selected=${String(dnslinkPolicy) === 'false'}> | ||
${browser.i18n.getMessage('option_dnslinkPolicy_disabled')} | ||
</option> | ||
<option | ||
value='best-effort' | ||
selected=${dnslinkPolicy === 'best-effort'}> | ||
${browser.i18n.getMessage('option_dnslinkPolicy_bestEffort')} | ||
</option> | ||
<option | ||
value='enabled' | ||
selected=${dnslinkPolicy === 'enabled'}> | ||
${browser.i18n.getMessage('option_dnslinkPolicy_enabled')} | ||
</option> | ||
</select> | ||
</div> | ||
<div> | ||
<label for="dnslinkRedirect"> | ||
<dl> | ||
<dt>${browser.i18n.getMessage('option_dnslinkRedirect_title')}</dt> | ||
<dd> | ||
${browser.i18n.getMessage('option_dnslinkRedirect_description')} | ||
${dnslinkRedirect ? html`<p class="red i">${browser.i18n.getMessage('option_dnslinkRedirect_warning')}</p>` : null} | ||
<p><a href="https://github.com/ipfs-shipyard/ipfs-companion/issues/667" target="_blank"> | ||
${browser.i18n.getMessage('option_legend_readMore')} | ||
</a></p> | ||
</dd> | ||
</dl> | ||
</label> | ||
<div>${switchToggle({ id: 'dnslinkRedirect', checked: dnslinkRedirect, onchange: onDnslinkRedirectChange })}</div> | ||
</div> | ||
</fieldset> | ||
</form> | ||
` | ||
} | ||
|
||
module.exports = dnslinkForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.