mirror of
https://github.com/amark/gun.git
synced 2025-06-09 23:56:43 +00:00
react
This commit is contained in:
commit
223c1f7029
@ -149,7 +149,7 @@ Designed with ♥ by Mark Nadal, the gun team, and many amazing contributors. L
|
||||
|
||||
Thanks to the following people who have contributed to GUN, via code, issues, or conversation (this list has quickly become tremendously behind! We'll probably turn this into a dedicated wiki page so you can add yourself):
|
||||
|
||||
[agborkowski](https://github.com/agborkowski); **:star:[alanmimms](https://github.com/alanmimms)**; [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); **[BrockAtkinson](https://github.com/BrockAtkinson) ([brunch config](https://github.com/BrockAtkinson/brunch-gun))**; [bromagosa](https://github.com/bromagosa); [coolaj86](https://github.com/coolaj86); [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan); **[forrestjt](https://github.com/forrestjt) ([file.js](https://github.com/amark/gun/blob/master/lib/file.js))**; [gedw99](https://github.com/gedw99); [HelloCodeMing](https://github.com/HelloCodeMing); **[JosePedroDias](https://github.com/josepedrodias) ([graph visualizer](http://acor.sl.pt:9966))**; **[JuniperChicago](https://github.com/JuniperChicago) ([cycle.js bindings](https://github.com/JuniperChicago/cycle-gun))**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc))**; [ndarilek](https://github.com/ndarilek); [onetom](https://github.com/onetom); [phpnode](https://github.com/phpnode); [PsychoLlama](https://github.com/PsychoLlama); **[RangerMauve](https://github.com/RangerMauve) ([schema](https://github.com/gundb/gun-schema))**; **[robertheessels](https://github.com/swifty) ([gun-p2p-auth](https://github.com/swifty/gun-p2p-auth))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [sbeleidy](https://github.com/sbeleidy); **:star:[Sean Matheson](https://github.com/ctrlplusb) ([Observable/RxJS/Most.js bindings](https://github.com/ctrlplusb/gun-most))**; [ssr1ram](https://github.com/ssr1ram); **[Stefdv](https://github.com/stefdv) ([Polymer/web components](http://stefdv.github.io/gun-collection/components/gun-collection/))**; [Xe](https://github.com/Xe); [zot](https://github.com/zot); [ayurmedia](https://github.com/ayurmedia);
|
||||
[agborkowski](https://github.com/agborkowski); **:star:[alanmimms](https://github.com/alanmimms)**; [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); **[BrockAtkinson](https://github.com/BrockAtkinson) ([brunch config](https://github.com/BrockAtkinson/brunch-gun))**; [bromagosa](https://github.com/bromagosa); [coolaj86](https://github.com/coolaj86); [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan); **[forrestjt](https://github.com/forrestjt) ([file.js](https://github.com/amark/gun/blob/master/lib/file.js))**; [gedw99](https://github.com/gedw99); [HelloCodeMing](https://github.com/HelloCodeMing); **[JosePedroDias](https://github.com/josepedrodias) ([graph visualizer](http://acor.sl.pt:9966))**; **[JuniperChicago](https://github.com/JuniperChicago) ([cycle.js bindings](https://github.com/JuniperChicago/cycle-gun))**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc))**; **[kristianmandrup](https://github.com/kristianmandrup) ([edge](https://github.com/kristianmandrup/gun-edge))**; [ndarilek](https://github.com/ndarilek); [onetom](https://github.com/onetom); [phpnode](https://github.com/phpnode); [PsychoLlama](https://github.com/PsychoLlama); **[RangerMauve](https://github.com/RangerMauve) ([schema](https://github.com/gundb/gun-schema))**; **[robertheessels](https://github.com/swifty) ([gun-p2p-auth](https://github.com/swifty/gun-p2p-auth))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [sbeleidy](https://github.com/sbeleidy); **:star:[Sean Matheson](https://github.com/ctrlplusb) ([Observable/RxJS/Most.js bindings](https://github.com/ctrlplusb/gun-most))**; [ssr1ram](https://github.com/ssr1ram); **[Stefdv](https://github.com/stefdv) ([Polymer/web components](http://stefdv.github.io/gun-collection/components/gun-collection/))**; [Xe](https://github.com/Xe); [zot](https://github.com/zot); [ayurmedia](https://github.com/ayurmedia);
|
||||
|
||||
This list of contributors was manually compiled and alphabetically sorted. If we missed you, please submit an issue so we can get you added!
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
</script>
|
||||
<script>
|
||||
($.model = $('ul li').clone(true)).removeAttribute('class');
|
||||
var gun = Gun(location.origin + '/gun');
|
||||
var gun = Gun(location.origin);
|
||||
var chat = gun.get('example/chat/data');
|
||||
chat.map().val(function(msg, field){
|
||||
console.log("msg", field, msg);
|
||||
|
@ -1,24 +1,13 @@
|
||||
console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080;
|
||||
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080;
|
||||
var express = require('express');
|
||||
var http = require('http');
|
||||
var app = express();
|
||||
var server = http.createServer(app);
|
||||
|
||||
var Gun = require('../');
|
||||
var gun = Gun({
|
||||
file: 'data.json',
|
||||
web: server,
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}
|
||||
});
|
||||
var Gun = require('..');
|
||||
|
||||
var app = express();
|
||||
app.use(Gun.serve);
|
||||
app.use(express.static(__dirname));
|
||||
server.listen(port);
|
||||
|
||||
var server = app.listen(port);
|
||||
Gun({ file: 'data.json', web: server });
|
||||
|
||||
console.log('Server started on port ' + port + ' with /gun');
|
||||
|
29
examples/hapi.js
Normal file
29
examples/hapi.js
Normal file
@ -0,0 +1,29 @@
|
||||
const Hapi = require('hapi')
|
||||
const Inert = require('inert')
|
||||
const Gun = require('..')
|
||||
|
||||
const server = new Hapi.Server
|
||||
server.connection({ port: 8080 })
|
||||
server.connections.forEach(c => Gun({ web: c.listener, file: 'data.json' }))
|
||||
|
||||
server.register(Inert, () => {});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/gun.js',
|
||||
handler: (request, reply) => reply.file('../gun.js', { confine: false })
|
||||
})
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{param*}',
|
||||
handler: {
|
||||
directory: {
|
||||
path: __dirname,
|
||||
redirectToSlash: true,
|
||||
index: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
server.start()
|
@ -36,7 +36,7 @@ wss.on('connection',acceptConnection )
|
||||
var gunPeers = []; // used as a list of connected clients.
|
||||
|
||||
Gun.on('out', function(msg){
|
||||
msg = JSON.stringify({headers:{},body:msg});
|
||||
msg = JSON.stringify(msg);
|
||||
gunPeers.forEach( function(peer){ peer.send( msg ) })
|
||||
})
|
||||
function acceptConnection( connection ) {
|
||||
@ -46,7 +46,7 @@ function acceptConnection( connection ) {
|
||||
gunPeers.push( connection );
|
||||
connection.on( 'error',function(error){console.log( "WebSocket Error:", error) } );
|
||||
|
||||
connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg).body)})
|
||||
connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg))})
|
||||
connection.on( 'close', function(reason,desc){
|
||||
// gunpeers gone.
|
||||
var i = gunPeers.findIndex( function(p){return p===connection} );
|
||||
|
@ -26,7 +26,7 @@
|
||||
function clean(text){ return String(text).replace(/\</ig, '<') }
|
||||
</script>
|
||||
<script>
|
||||
var gun = Gun(location.origin + '/gun');
|
||||
var gun = Gun(location.origin);
|
||||
var ref = gun.get('example/json/data');
|
||||
$('#form').onsubmit = function(e){
|
||||
return ref.path( clean($('#field').value) ).put("value"), false; // add a new field, and cancel the form submit.
|
||||
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
"react",
|
||||
"env",
|
||||
"stage-0"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-decorators-legacy",
|
||||
"transform-eval"
|
||||
]
|
||||
}
|
21
examples/react/.gitignore
vendored
21
examples/react/.gitignore
vendored
@ -1,3 +1,18 @@
|
||||
data.json
|
||||
node_modules
|
||||
npm-debug.log
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
||||
import React, { Component } from 'react'
|
||||
import { render } from 'react-dom'
|
||||
import Todos from './todos'
|
||||
import Chat from './chat'
|
||||
import Json from './json'
|
||||
|
||||
const App = _ =>
|
||||
<div>
|
||||
<h1>React Examples</h1>
|
||||
<h2>Todo</h2>
|
||||
<Todos />
|
||||
<br />
|
||||
<hr />
|
||||
<h2>Chat</h2>
|
||||
<Chat />
|
||||
<br />
|
||||
<hr />
|
||||
<h2>Json</h2>
|
||||
<Json />
|
||||
</div>
|
||||
|
||||
render(<App />, document.getElementById('app'))
|
||||
|
@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Gun - React Examples</title>
|
||||
<meta charset="utf-8" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,38 +1,22 @@
|
||||
{
|
||||
"name": "gun-react-examples",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"start": "node start",
|
||||
"dev": "nodemon --config .nodemon.json start"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"babel": "^6.5.2",
|
||||
"babel-core": "^6.21.0",
|
||||
"babel-loader": "^6.2.10",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-plugin-transform-eval": "^6.8.0",
|
||||
"babel-preset-env": "^1.2.0",
|
||||
"babel-preset-react": "^6.16.0",
|
||||
"babel-preset-stage-0": "^6.16.0",
|
||||
"css-loader": "^0.26.1",
|
||||
"file-loader": "^0.9.0",
|
||||
"html-webpack-plugin": "^2.26.0",
|
||||
"json-loader": "^0.5.4",
|
||||
"style-loader": "^0.13.1",
|
||||
"url-loader": "^0.5.7",
|
||||
"webpack": "^1.14.0"
|
||||
},
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"babel": "^6.5.2",
|
||||
"babel-polyfill": "^6.20.0",
|
||||
"express": "^4.14.1",
|
||||
"lodash": "^4.17.4",
|
||||
"gun": "file:../..",
|
||||
"react": "^15.4.2",
|
||||
"react-dom": "^15.4.2",
|
||||
"webpack-dev-middleware": "^1.9.0"
|
||||
"react-dom": "^15.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.15.2",
|
||||
"express-http-proxy": "^0.11.0",
|
||||
"react-scripts": "0.9.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject",
|
||||
"server": "PORT=8081 node ./server.js"
|
||||
}
|
||||
}
|
||||
|
BIN
examples/react/public/favicon.ico
Normal file
BIN
examples/react/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
32
examples/react/public/index.html
Normal file
32
examples/react/public/index.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tag above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Gun - React Examples</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start`.
|
||||
To create a production bundle, use `npm run build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
@ -1,18 +1,26 @@
|
||||
import express from 'express'
|
||||
import Gun from '../..'
|
||||
import webpack from 'webpack'
|
||||
import WebpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import config from './webpack.config'
|
||||
console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8081;
|
||||
var host = process.env.OPENSHIFT_NODEJS_HOST || process.env.VCAP_APP_HOST || process.env.HOST || 'localhost';
|
||||
|
||||
const app = express()
|
||||
const gun = Gun()
|
||||
var express = require('express');
|
||||
var proxy = require('express-http-proxy');
|
||||
var http = require('http');
|
||||
var app = express();
|
||||
var server = http.createServer(app);
|
||||
|
||||
Gun({web: app})
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
file: 'data.json',
|
||||
web: server,
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}
|
||||
});
|
||||
|
||||
const compiler = webpack(config)
|
||||
app.use(Gun.serve);
|
||||
app.use(proxy(host + ':8080'));
|
||||
server.listen(port);
|
||||
|
||||
const devMiddleware = WebpackDevMiddleware(compiler)
|
||||
|
||||
app.use(devMiddleware)
|
||||
|
||||
app.listen(4000)
|
||||
console.log('Server started on port ' + port + ' with /gun');
|
||||
|
31
examples/react/src/App.js
Normal file
31
examples/react/src/App.js
Normal file
@ -0,0 +1,31 @@
|
||||
import React, { Component } from 'react';
|
||||
import Todos from './Todos'
|
||||
import Chat from './Chat'
|
||||
import Json from './Json'
|
||||
|
||||
class App extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.gun = Gun(location.origin + '/gun')
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<h1>React Examples</h1>
|
||||
<h2>Todo</h2>
|
||||
<Todos gun={this.gun} />
|
||||
<br />
|
||||
<hr />
|
||||
<h2>Chat</h2>
|
||||
<Chat gun={this.gun} />
|
||||
<br />
|
||||
<hr />
|
||||
<h2>Json</h2>
|
||||
<Json gun={this.gun} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
8
examples/react/src/App.test.js
Normal file
8
examples/react/src/App.test.js
Normal file
@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(<App />, div);
|
||||
});
|
@ -1,7 +1,6 @@
|
||||
import React, { Component } from 'react'
|
||||
import Gun from '../../gun'
|
||||
import Gun from 'gun'
|
||||
|
||||
const gun = Gun().get('chat')
|
||||
const formatMsgs = msgs => Object.keys(msgs)
|
||||
.map(key => ({ key, ...msgs[key] }))
|
||||
.filter(m => Boolean(m.when) && m.key !== '_')
|
||||
@ -9,8 +8,9 @@ const formatMsgs = msgs => Object.keys(msgs)
|
||||
.map(m => ((m.whenFmt = new Date(m.when).toLocaleString().toLowerCase()), m))
|
||||
|
||||
export default class Chat extends Component {
|
||||
constructor() {
|
||||
constructor({gun}) {
|
||||
super()
|
||||
this.gun = gun.get('chat');
|
||||
this.state = {
|
||||
newMsg: '',
|
||||
name: (document.cookie.match(/alias\=(.*?)(\&|$|\;)/i)||[])[1]||'',
|
||||
@ -19,7 +19,7 @@ export default class Chat extends Component {
|
||||
}
|
||||
componentWillMount() {
|
||||
const tmpState = {}
|
||||
gun.map().val((msg, key) => {
|
||||
this.gun.map().val((msg, key) => {
|
||||
tmpState[key] = msg
|
||||
this.setState({msgs: Object.assign({}, this.state.msgs, tmpState)})
|
||||
})
|
||||
@ -32,7 +32,7 @@ export default class Chat extends Component {
|
||||
document.cookie = ('alias=' + who)
|
||||
const when = Gun.time.is()
|
||||
const key = `${when}_${Gun.text.random(4)}`
|
||||
gun.path(key).put({
|
||||
this.gun.path(key).put({
|
||||
who,
|
||||
when,
|
||||
what: this.state.newMsg,
|
@ -1,30 +1,29 @@
|
||||
import React, { Component } from 'react'
|
||||
import Gun from '../../gun'
|
||||
|
||||
const gun = Gun().get('json')
|
||||
const formatJson = json =>
|
||||
Object.keys(json)
|
||||
.map(key => ({ key, val: json[key]}))
|
||||
.filter(el => el.key !== '_')
|
||||
|
||||
export default class Json extends Component {
|
||||
constructor() {
|
||||
constructor({gun}) {
|
||||
super()
|
||||
this.gun = gun.get('json');
|
||||
this.state = { newField: '', json: [] }
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
gun.on(json => this.setState({ json: formatJson(json) }))
|
||||
this.gun.on(json => this.setState({ json: formatJson(json) }))
|
||||
}
|
||||
|
||||
edit = key => e => {
|
||||
e.preventDefault()
|
||||
gun.path(key).put(e.target.value)
|
||||
this.gun.path(key).put(e.target.value)
|
||||
}
|
||||
|
||||
add = e => {
|
||||
e.preventDefault()
|
||||
gun.path(this.state.newField).put('value')
|
||||
this.gun.path(this.state.newField).put('value')
|
||||
this.setState({newField: ''})
|
||||
}
|
||||
|
@ -1,28 +1,28 @@
|
||||
import './style.css'
|
||||
import React, { Component } from 'react'
|
||||
import Gun from '../../gun'
|
||||
import Gun from 'gun'
|
||||
|
||||
const gun = Gun().get('todos')
|
||||
const formatTodos = todos => Object.keys(todos)
|
||||
.map(key => ({ key, val: todos[key] }))
|
||||
.filter(t => Boolean(t.val) && t.key !== '_')
|
||||
|
||||
export default class Todos extends Component {
|
||||
constructor() {
|
||||
constructor({gun}) {
|
||||
super()
|
||||
this.gun = gun.get('todos');
|
||||
this.state = {newTodo: '', todos: []}
|
||||
}
|
||||
componentWillMount() {
|
||||
gun.on(todos => this.setState({
|
||||
this.gun.on(todos => this.setState({
|
||||
todos: formatTodos(todos)
|
||||
}))
|
||||
}
|
||||
add = e => {
|
||||
e.preventDefault()
|
||||
gun.path(Gun.text.random()).put(this.state.newTodo)
|
||||
this.gun.path(Gun.text.random()).put(this.state.newTodo)
|
||||
this.setState({newTodo: ''})
|
||||
}
|
||||
del = key => gun.path(key).put(null)
|
||||
del = key => this.gun.path(key).put(null)
|
||||
handleChange = e => this.setState({ newTodo: e.target.value})
|
||||
render() {
|
||||
return <div>
|
5
examples/react/src/index.css
Normal file
5
examples/react/src/index.css
Normal file
@ -0,0 +1,5 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
9
examples/react/src/index.js
Normal file
9
examples/react/src/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
import './index.css';
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('root')
|
||||
);
|
@ -1,3 +0,0 @@
|
||||
require('source-map-support').install()
|
||||
require('babel-register')
|
||||
require('./server')
|
@ -1,38 +0,0 @@
|
||||
var webpack = require('webpack')
|
||||
var path = require('path')
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
module.exports = {
|
||||
entry: './app.js',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
filename: '[name].js?[hash]',
|
||||
path: path.join(__dirname, 'public'),
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
loader: 'style!css',
|
||||
},
|
||||
{
|
||||
test: /\.(png|gif|jpg|jpeg|woff)$/,
|
||||
loader: 'url',
|
||||
},
|
||||
{
|
||||
test: /\.(eot|ttf|svg|ico)$/,
|
||||
loader: 'file',
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel',
|
||||
exclude: /node_modules/,
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './index.html'
|
||||
})
|
||||
],
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
function clean(text){ return String(text).replace(/\</ig, '<') }
|
||||
</script>
|
||||
<script> // by Forrest Tait! Edited by Mark Nadal.
|
||||
var gun = Gun(location.origin + '/gun');
|
||||
var gun = Gun(location.origin);
|
||||
var todo = gun.get('example/todo/data');
|
||||
$("#add").onsubmit = function(){
|
||||
todo.path(Gun.text.random()).put(clean($("#todo").value)); // add the HTML input's value to a random ID in the todo.
|
||||
|
9
gun.js
9
gun.js
@ -935,6 +935,7 @@
|
||||
if(!obj_is(at.opt.peers)){ at.opt.peers = {}}
|
||||
at.opt.peers = obj_to(tmp, at.opt.peers);
|
||||
}
|
||||
at.opt.wsc = at.opt.wsc || {protocols:null}
|
||||
at.opt.peers = at.opt.peers || {};
|
||||
obj_to(opt, at.opt); // copies options on to `at.opt` only if not already taken.
|
||||
Gun.on('opt', at);
|
||||
@ -2343,8 +2344,10 @@
|
||||
if(!cat.udrain){ return }
|
||||
var tmp = cat.udrain;
|
||||
cat.udrain = null;
|
||||
message = JSON.stringify(tmp);
|
||||
Gun.obj.map(cat.opt.peers, send, cat);
|
||||
if( tmp.length ) {
|
||||
message = JSON.stringify(tmp);
|
||||
Gun.obj.map(cat.opt.peers, send, cat);
|
||||
}
|
||||
},1);
|
||||
wsp.count = 0;
|
||||
Gun.obj.map(cat.opt.peers, send, cat);
|
||||
@ -2381,7 +2384,7 @@
|
||||
function open(peer, as){
|
||||
if(!peer || !peer.url){ return }
|
||||
var url = peer.url.replace('http', 'ws');
|
||||
var wire = peer.wire = new WebSocket(url);
|
||||
var wire = peer.wire = new WebSocket(url, as.opt.wsc.protocols, as.opt.wsc );
|
||||
wire.onclose = function(){
|
||||
reconnect(peer, as);
|
||||
};
|
||||
|
@ -54,10 +54,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "~>4.13.4",
|
||||
"hapi": "^16.1.0",
|
||||
"inert": "^4.1.0",
|
||||
"ip": "^1.1.4",
|
||||
"mocha": "~>1.9.0",
|
||||
"uglify-js": "~>2.2.0",
|
||||
"panic-manager": "^1.2.0",
|
||||
"panic-server": "^1.1.0",
|
||||
"ip": "^1.1.4"
|
||||
"uglify-js": "~>2.2.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user