From cd827ef5d3410096a2048d42d73f47a39c6761f6 Mon Sep 17 00:00:00 2001 From: ayurmedia Date: Tue, 29 Dec 2015 08:41:42 +0100 Subject: [PATCH 1/3] Update README.md add ayurmedia as contributor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d282fea2..4b264a0b 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ as it enables us where to refine GUN. So drop us a line in the [![Gitter](https: 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); [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); [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)**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc) [live demo](http://todos.loqali.com/))**; [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))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [ssr1ram](https://github.com/ssr1ram); [Xe](https://github.com/Xe); [zot](https://github.com/zot); +[ayurmedia](https://github.com/ayurmedia); This list of contributors was manually compiled, alphabetically sorted. If we missed you, please submit an issue so we can get you added! From 3240ab882637643305250873c46cd52b0e7620f4 Mon Sep 17 00:00:00 2001 From: PenguinMan98 Date: Tue, 29 Dec 2015 01:07:32 -0700 Subject: [PATCH 2/3] allow_prefix_override This change should (untested) let the user pass in a prefix option to put, get, and key, operations that will override the prefix set in the instance without clobbering it. --- gun.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/gun.js b/gun.js index 0b8bac67..b13997d8 100644 --- a/gun.js +++ b/gun.js @@ -980,8 +980,8 @@ }({})); if(typeof window !== "undefined"){ window.Gun = Gun; - } - if(typeof module !== 'undefined' && module.exports){ + } + if(typeof module !== 'undefined' && module.exports){ module.exports = Gun; } var root = this || {}; // safe for window, global, root, and 'use strict'. @@ -1016,10 +1016,11 @@ } else { opt.url.pathname = '/' + key; } + var getPrefix = (opt.prefix) ? opt.prefix: tab.prefix; // allows users to provide a prefix for the get operation Gun.log("tab get --->", key); (function local(key, cb){ - var path = (path = Gun.is.soul(key))? tab.prefix + tab.prenode + path - : tab.prefix + tab.prekey + key, node = tab.store.get(path), graph, soul; + var path = (path = Gun.is.soul(key))? getPrefix + tab.prenode + path + : getPrefix + tab.prekey + key, node = tab.store.get(path), graph, soul; if(Gun.is.node(node)){ (cb.graph = cb.graph || {} )[soul = Gun.is.soul.on(node)] = (graph = {})[soul] = cb.node = node; @@ -1050,14 +1051,15 @@ cb.peers = true; }); } tab.peers(cb); - } + }; tab.put = tab.put || function(graph, cb, opt){ cb = cb || function(){}; opt = opt || {}; + var putPrefix = (opt.prefix) ? opt.prefix: tab.prefix; // allows users to provide a prefix for the put operation Gun.is.graph(graph, function(node, soul){ if(!opt.local){ gun.__.on(soul).emit(node) } // TODO: Should this be in core? if(!gun.__.graph[soul]){ return } - tab.store.put(tab.prefix + tab.prenode + soul, gun.__.graph[soul]); + tab.store.put(putPrefix + tab.prenode + soul, gun.__.graph[soul]); }); if(!(cb.local = opt.local)){ Gun.obj.map(opt.peers || gun.__.opt.peers, function(peer, url){ @@ -1065,16 +1067,17 @@ cb.peers = true; }); } tab.peers(cb); - } + }; tab.key = tab.key || function(key, soul, cb, opt){ var meta = {}; opt = opt || {}; cb = cb || function(){}; + var keyPrefix = (opt.prefix) ? opt.prefix: tab.prefix; // allows users to provide a prefix for the key operation meta[Gun._.soul] = soul = Gun.is.soul(soul) || soul; if(!soul){ return cb({err: Gun.log("No soul!")}) } (function(souls){ - (souls = tab.store.get(tab.prefix + tab.prekey + key) || {})[soul] = meta; - tab.store.put(tab.prefix + tab.prekey + key, souls); + (souls = tab.store.get(keyPrefix + tab.prekey + key) || {})[soul] = meta; + tab.store.put(keyPrefix + tab.prekey + key, souls); }()); if(!(cb.local = opt.local || opt.soul)){ Gun.obj.map(opt.peers || gun.__.opt.peers, function(peer, url){ @@ -1082,7 +1085,7 @@ cb.peers = true; }); } tab.peers(cb); - } + }; tab.error = function(cb, error, fn){ return function(err, reply){ reply.body = reply.body || reply.chunk || reply.end || reply.write; From 0c58245a2af93d69085fb49f0bdcdc909f4f6145 Mon Sep 17 00:00:00 2001 From: Jesse Gibson Date: Wed, 30 Dec 2015 13:32:00 -0700 Subject: [PATCH 3/3] Remove unused "formidable" dependency in wsp.js Formidable is only used in http.js, and although it is required by wsp.js, it's never used. --- lib/wsp.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/wsp.js b/lib/wsp.js index 095ac997..cdb151fa 100644 --- a/lib/wsp.js +++ b/lib/wsp.js @@ -1,6 +1,5 @@ ;(function(wsp){ - var Gun = require('../gun') - , formidable = require('formidable') + var Gun = require('../gun') , ws = require('ws').Server , http = require('./http') , url = require('url');