Mercurial > psgxs
annotate backends/directory.js @ 58:b98e545a94f7 default tip
Always use children instead of tags. Might break something.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 13 Sep 2011 00:54:55 +0200 |
parents | 99bd1d1ac071 |
children |
rev | line source |
---|---|
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 /* |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 * |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 * This file is part of PSĜS, a PubSub server written in JavaScript. |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 * |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 * PSĜS is free software: you can redistribute it and/or modify |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 * it under the terms of the GNU Affero General Public License as |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 * License. |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 * |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 * PSĜS is distributed in the hope that it will be useful, |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 * GNU Affero General Public License for more details. |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 * |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Affero General Public License |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 */ |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
20 'use strict'; |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
21 |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 var fs = require('fs'); |
29
e007a6364bf0
Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
28
diff
changeset
|
23 var Node = require('../nodes').Node; |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 var backend = exports; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 backend.save = function(dir) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 if (!dir) |
55
fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
28 dir = 'data'; |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 fs.stat(dir, function(err, stats) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 if (err) |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
32 fs.mkdir(dir, 509); // 0755 in decimal |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 else if (!stats.isDirectory()) { |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
34 console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m'); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 process.exit(1); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 fs.readdir(dir, function(err, files) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 function sanitize(o) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 var n = {}; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 for (var i in o) { |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
42 if (i == 'content' || o[i].setFromISO8601) |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 n[i] = o[i].toString(); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 else if (o[i] instanceof Array) |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 n[i] = o[i]; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 else if (typeof o[i] == 'object') |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 n[i] = sanitize(o[i]); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 else if (typeof o[i] == 'function') |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 ; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 else |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 n[i] = o[i]; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 return n; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 var data = sanitize(backend.list); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 var inspect = require('sys').inspect; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
59 for (var nodeID in data) |
55
fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
60 fs.writeFile(dir+'/'+encodeURI(nodeID).replace('/', '%2f')+'.json', inspect(data[nodeID], false, null)); |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
61 |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 var toDelete = []; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 for (var i in files) { |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
65 var file = files[i]; |
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
66 if (!(file.replace(/\.json$/, '') in data)) |
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
67 toDelete.push(file); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
70 for (var nodeID in toDelete) |
55
fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
71 fs.unlink(dir+'/'+encodeURI(toDelete[nodeID]).replace('/', '%2f')); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 }); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 }); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 backend.load = function(dir) { |
56
99bd1d1ac071
Migration to node-xmpp, done!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
77 var parse = require('ltx').parse; |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 if (!dir) |
55
fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
79 dir = 'data'; |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 fs.stat(dir, function(err, stats) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 if (err) |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
83 fs.mkdir(dir, 509); // 0755 in decimal |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 else if (!stats.isDirectory()) { |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
85 console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m'); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 process.exit(1); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 fs.readdir(dir, function(err, files) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 function endParsing(o) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 var regexp = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ/; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 for (var i in o) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 if (typeof o[i] == 'string' && i == 'content') |
56
99bd1d1ac071
Migration to node-xmpp, done!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
94 o[i] = parse(o[i]); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 else if (typeof o[i] == 'string' && regexp(o[i])) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 var today = new Date(); |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
97 today.setFromISO8601(o[i]); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 o[i] = today; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 } else if (typeof o[i] == 'object') |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 endParsing(o[i]); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 return o; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 backend.list = {}; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 for (var i in files) { |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 var file = files[i]; |
34
dcf1f09f8cee
Add message to publish module and various fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
33
diff
changeset
|
109 if (/^\./.test(file)) |
dcf1f09f8cee
Add message to publish module and various fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
33
diff
changeset
|
110 continue; |
dcf1f09f8cee
Add message to publish module and various fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
33
diff
changeset
|
111 |
56
99bd1d1ac071
Migration to node-xmpp, done!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
112 if (!/\.json$/.test(file)) |
99bd1d1ac071
Migration to node-xmpp, done!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
113 continue; |
99bd1d1ac071
Migration to node-xmpp, done!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
114 |
55
fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
115 var nodeID = decodeURI(file.replace(/\.json$/, '').replace('%2f', '/')); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 |
33
62cbb1c49bc5
Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
117 var data = fs.readFileSync(dir+'/'+file).toString(); |
27
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 var obj = eval('('+data+')'); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 backend.list[nodeID] = endParsing(obj); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 for (var j in Node.prototype) |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 backend.list[nodeID][j] = Node.prototype[j]; |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 } |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 }); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 }); |
a36a514e8be8
Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 } |