Last active
July 14, 2022 14:18
-
-
Save michel47/e8441fb73bf506d69320967324a9b5c6 to your computer and use it in GitHub Desktop.
wbly (hostless websites)
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
wbly.ml |
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
<meta charset=utf8> | |
<title>Websites by Doctor IT</title> | |
<style> | |
body{background-color:#415} | |
body > div:first-child {margin-top:10vw} | |
body > div {background-color:white;max-width:720px;padding:0.8rem;margin:auto;box-shadow: 5px 5px 15px 2px rgba(4,3,5,0.9);} | |
</style> | |
<div> | |
<img src=logo.webp align=right width=80 height=80> | |
<h3>wbly.ml</h3> | |
<p>Welcome to Doctor I·T hostless websites ... | |
<p>This page is in fact located on the <a href="https://duckduckgo.com/?q=IPFS+network">IPFS network</a> and | |
there is no specific host to serve. | |
If you are running an IPFS <a href="https://duckduckgo.com/?q=installing+IPFS+on+your+computer">node</a> (which I strongly recommend) | |
you can simply check this page here <a href=https://gateway.ipfs.io/ipns/wbly.ml/>/ipns/wbly.ml/</a> | |
<p> | |
Any website can be deployed the same way by using the script | |
<a href="https://gist.github.com/michel47/e8441fb73bf506d69320967324a9b5c6#file-webpush-sh">webpush.sh</a> | |
below, running the following command : | |
<code><pre>cd mywebsite-folder | |
sh webpush.sh | |
</pre></code> | |
<p> | |
In all cases I can setup your website for <b><span>€</span>5.--</b> ! | |
<br>contact: <a href="mailto:michelc%40drit.ml">michelc@drit.ml</a> | |
<br>phone: <a href="tel:+41767609400">+41 7676 0 9400</a> | |
<br>website: <a href="https://www.drit.ml/">www.drit.ml</a> | |
<br>-- | |
<br>Michel C. (aka Dr I·T) | |
</div><br><div> | |
<p>Bash code for deploying a website | |
from <a href="https://gist.github.com/e8441fb73bf506d69320967324a9b5c6.git">gist:e8441fb73bf506d69320967324a9b5c6</a> | |
(git repository : <a href="https://hologit-ml.ipns.dweb.link/michelc/webly.ml.git">git:hologit:michelc/webly.ml.git<a> | |
<p>You will need a domain with a CNAME record and a TXT one | |
<ul> | |
<li><code> _dnslink.your.website.domain TXT in 600 "dnslink=/ipns//your.website.domain"</code> | |
<li><code>your.website.domain CNAME website.ml</code> | |
<li> ask me to add your site in the authorzied list | |
</ul> | |
</p> | |
<script src="https://gist.github.com/michel47/e8441fb73bf506d69320967324a9b5c6.js?file=webpush.sh"></script> | |
<p>--<br> | |
<a href=https://www.drit.ml>Dr I·T</a> | |
</div> | |
<script> | |
let promise = fetch('https://ip2c.org/self'). | |
then( resp => resp.text() ). | |
then( string => { | |
// console.log('string:',string); | |
let countrycode = string.split(';')[1]; | |
console.log('countrycode:',countrycode); | |
let cur; | |
switch (countrycode) { | |
case 'CH': | |
cur = 'CHF'; break | |
case 'US': | |
cur = 'USD'; break; | |
default: | |
cur = 'EUR'; | |
} | |
document.getElementsByTagName('span')[0].innerText = cur; | |
}). | |
catch(console.error); | |
</script> |
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
# | |
# intent add a website to the cloud ... (under $url) | |
# usage: | |
# webpush.sh wbly.ml | |
# | |
# how it works it makes a (d)nslookup and extract the dnslink | |
gateway=$(ipfs config Addresses.Gateway) | |
gw_port=$(echo $gateway | cut -d/ -f 5) | |
gw_host=$(echo $gateway | cut -d/ -f 3) | |
gw_url=http://${gw_host}:${gw_port} | |
domain="$1" | |
if [ "z$domain" = 'z' ]; then domain=$(cat CNAME); fi | |
if [ "z$domain" = 'z' ]; then domain=${PWD##*/}; fi | |
echo "--- # ${0##*/} for $domain" | |
dnslink=$(nslookup -type=TXT _dnslink.$domain | grep dnslink= | sed -e 's/.*"dnslink=\(.*\)"/\1/') | |
echo domain: $domain | |
echo dnslink: $dnslink | |
if [ "z$dnslink" = 'z' ]; then echo "error: please add a TXT record to _dnslink.$domain domain"; exit 252; fi | |
# ----------------------------------- | |
find . -name "*~1" -delete | |
# computes the qm for the site ... | |
if [ -d _site ]; then | |
qm=$(ipfs add -r _site -Q) | |
else | |
if [ -d public_html ]; then | |
qm=$(ipfs add -r public_html -Q) | |
else | |
qm=$(ipfs add -r . -Q) | |
fi | |
fi | |
# ----------------------------------- | |
key=${dnslink#*/ipns/} | |
key=${key%%/*} | |
site=${dnslink##*/} | |
echo site: $site | |
echo key: $key | |
parent=${dnslink%/*} | |
echo parent: $parent | |
ppath=$(ipfs resolve $parent) | |
qmparent=${ppath##*/ipfs/} | |
echo "qmparent: $qmparent (old)" | |
# remove previous site | |
qmtemp=$(ipfs object patch rm-link $qmparent $site 2>/dev/null); | |
if [ "e$qmtemp" != 'e' ]; then qmparent=$qmtemp; fi | |
# add new site | |
qmtemp=$(ipfs object patch add-link $qmparent $site $qm); | |
if [ "e$qmtemp" != 'e' ]; then qmparent=$qmtemp; fi | |
echo "qmparent: $qmparent (new)" | |
echo 'www:' | |
ipfs ls /ipfs/$qmparent | sed -e 's/^/ /' -e 's/ -/:/' | |
echo url: $gw_url/ipfs/$qmparent | |
ipfs name publish --ipns-base b58mh --key $key /ipfs/$qmparent --allow-offline | sed -e 's/Published to //' | |
echo url: $gw_url/ipns/$key/$site | |
echo url: $gw_url/ipns/$domain | |
exit; | |
if false; then | |
# replace update mfs:/root | |
peerid=$(ipfs config Identity.PeerID) | |
root=$(ipfs name resolve $peerid) | |
qmroot=${root##*/} | |
echo qmroot: $qmroot | |
# remove www | |
qmtemp=$(ipfs object patch rm-link $qmroot 'www'); | |
if [ "e$qmtemp" != 'e' ]; then qmroot=$qmtemp; fi | |
# add new www | |
qmtemp=$(ipfs object patch add-link $qmroot 'www' $qmparent); | |
if [ "e$qmtemp" != 'e' ]; then qmroot=$qmtemp; fi | |
curl -sI https://ipfs.blockring™.ml/ipfs/$qmroot | grep -v -e access-control | grep -i -e ipfs | |
echo url: https://gateway.pinata.cloud/ipfs/$qmroot/www/$site | |
# update mfs ... | |
# TODO: not done yet | |
fi | |
true; # $Source: /my/shell/scripts/webpush $ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment