Skip to content

Commit

Permalink
feat: js-ipfs works inside a service worker!
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed May 22, 2017
1 parent 9f98384 commit 476e4fb
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 155,737 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ jspm_packages

# Optional REPL history
.node_repl_history
examples/use-from-another-page/public+sw/service-worker-bundle.js
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# ipfs-service-worker
Run an IPFS node inside a service worker and serve all your IPFS Urls directly from IPFS!
# Use `js-ipfs` within a service worker

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![Build Status](https://travis-ci.org/ipfs/ipfs-service-worker.svg?style=flat-square)](https://travis-ci.org/ipfs/ipfs-service-worker)
[![Coverage Status](https://coveralls.io/repos/github/ipfs/ipfs-service-worker/badge.svg?branch=master)](https://coveralls.io/github/ipfs/ipfs-service-worker?branch=master)
[![Dependency Status](https://david-dm.org/ipfs/ipfs-service-worker.svg?style=flat-square)](https://david-dm.org/ipfs/ipfs-service-worker)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)

> Run an IPFS node inside a service worker and serve all your IPFS Urls directly from IPFS!
# BEWARE BEWARE there may be dragons! 🐉

This module is still experimental because it is indeed an experiment part of the https://github.com/ipfs/in-web-browsers endeavour.

# Usage

This module requires `js-ipfs v0.24.0 or higher`
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
</head>
<body>
<h1>js-ipfs in a service worker</h1>
<textarea id="input"></textarea>
<textarea id="input" cols="100"></textarea>
<button id="show">Fetch</button>
<div id="display"></div>
<script src="index.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ if ('serviceWorker' in navigator) {
document.querySelector('#show').addEventListener('click', () => {
const multihash = document.querySelector('#input').value
let imgElement = document.createElement('img')

// imgElement.src = multihash
imgElement.src = '/ipfs/' + multihash
// imgElement.src = 'https://ipfs.io/ipfs/' + multihash
document.querySelector('#display').appendChild(imgElement)
Expand Down
Loading

0 comments on commit 476e4fb

Please sign in to comment.