Skip to content

Instantly share code, notes, and snippets.

Last active Apr 27, 2021
What would you like to do?
an (editable) one-page hostless static website
<!DOCTYPE html><meta charset="utf8">
<div id=container contenteditable oninput="update(event);">
<img id=logo src=https://ipfs.blockring™.ml/ipfs/QmVFJEec5cD9nCmzx9ic6rGJSe8hDzMWEchcoxnZtG1QK8/drit-pin-logo.svg>
<h3>I believe this page is super cool ...</h3>
<p>You can write anything you want on it,
hit the publish button, and you have a free online webpage to you to send a message across the world.
<i>Requirement you need to have an IPFS node running on your machine at
<a href="" contenteditable=false></a> /
<a href="#" data-href="" onclick="post(this.dataset.href);"
and you must have <span id=origin>:origin</span> in the "Allow-Origins" list.</i>
<button onclick="publish(event);">publish</button>
to push this page to the <a href=https://ipfs.blockring™.ml/ipfs/:qm/ contenteditable=false>IPFS</a> network.
You can share this page using the
<a target=_ipfs href= contenteditable=false>permalink</a> below:
<input name=permalink title=permalink value="https://ipfs.blockring™.ml/ipfs/:qm/" style="border:0; width:100%; background-color: white;">
<button onclick="copy(event);" contenteditable=false><img class=button alt="copy url" src=></button>
<p><code><span value=https://ipfs.blockring™.ml/ipfs/:qm/>dnslink=/ipfs/:qm/</span></code>
<p>--&nbsp;<br><span contenteditable=false>This page is provided by <a href="">Doctor I·T</a></span>
body {
background-color: #300233;
background-image: URL(https://ipfs.blockring™.ml/ipfs/QmSoyQm59v121sGy75ReMZNe4GaMvVWvr3C87khfWiZjee/z-background.svg);
background-size: 100% 100%;
min-height: 100vh;
.button { width: 1rem; height: 1rem; padding: 0; }
#container {
max-width: 680px;
margin: auto;
margin-bottom: 1vh;
padding: 1.2rem;
background-color: white;
opacity: 0.90;
box-shadow: 5px 5px 15px 2px rgba(4,3,5,0.9);
i { color: grey }
#logo { float: right; max-width: 140px; }
img[alt=gonohost] { max-width: 80%; margin: auto; }
var prevhash = ':qm';
let el = document.getElementById('origin');
el.innerText = el.innerText.replace(/:origin/,location.origin);
var html = document.getElementsByTagName('html')[0];
var templ = html.innerHTML;
function post(url) {
return fetch(url,{method:'POST'}).then(resp => resp.text()).then(buf => { document.writeln(buf); return void(0); }).catch(console.warn);
function copy(ev) {
let el=document.getElementsByName('permalink')[0];
el.setSelectionRange(0, 99999); // for mobile devices
function publish(ev) {
const api_url = '';
//const api_url = 'https://ipfs.blockring™.ml/api/v0/'
//return fetch(location.href).then(resp => resp.text()).then(buf => { console.log('buf:',buf); });
var html = document.getElementsByTagName('html')[0];
let innerHTML = html.innerHTML.replace(RegExp(prevhash,'g'),':qm');
html.innerHTML = innerHTML;
var buf = `<!DOCTYPE html>${innerHTML}`;
let form = new FormData();
let headers = new Headers();
return fetch(api_url+'add?pin=true',{method:'POST', body:form}).
then(resp => resp.json()).
then(obj => {
if (typeof(obj.Code) == 'undefined') {
let sc = document.getElementsByTagName('script')[0];
sc.innerHTML = sc.innerHTML.replace(RegExp(prevhash,'g'),obj.Hash);
let el = document.getElementById('container');
el.innerHTML = el.innerHTML.replace(/:qm/g,obj.Hash);
prevhash = obj.Hash
then(resp => {'resp:',resp); return resp; }).
return obj.Hash;
} else {
// ipfs add -w -r index.html style.css js img --pin=true -Q
return Promise.reject('QmeQVu3NGEcjmzx1rVytrSV9Ht9sc3KgavnpyhaE8gBip1')
function update(ev) {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment