Mercurial > psgxs
annotate configuration.js @ 41:bc717575e66a
Much better handling of modules.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 20 Feb 2011 15:51:12 +0100 |
parents | f2e9365bc8ec |
children | 07ca0263a53f |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
3 * | |
4 * This file is part of PSĜS, a PubSub server written in JavaScript. | |
5 * | |
6 * PSĜS is free software: you can redistribute it and/or modify | |
7 * it under the terms of the GNU Affero General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License. | |
10 * | |
11 * PSĜS is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU Affero General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Affero General Public License | |
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. | |
18 */ | |
19 | |
20 var config = exports; | |
21 | |
22 config.jid = 'pubsub.example.org'; | |
1
c2954a9e5665
Add a super-owner that has power over all nodes; add support for
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
23 config.password = 'hellohello'; |
c2954a9e5665
Add a super-owner that has power over all nodes; add support for
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
24 config.superOwner = ['you@example.com']; |
c2954a9e5665
Add a super-owner that has power over all nodes; add support for
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
25 config.version = '0.1'; |
c2954a9e5665
Add a super-owner that has power over all nodes; add support for
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
26 config.os = 'GNU/Linux'; |
7
781ac4f1e304
Allow others JIDs than super-owners to create nodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
1
diff
changeset
|
27 config.allowCreateNode = [/@example\.com$/]; // value is an array of RegExp JIDs. If only super-owner should be able to create nodes, use []. |
26
f2e9365bc8ec
Can use differents backends for node storage. Writing directory-based backend in top of file-based backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
14
diff
changeset
|
28 config.backend = 'directory'; // Put backends in “backends” directory. |
13
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
29 config.access = 'open'; // values include open, whitelist (by members) and authorize (owners of the node receive notification). presence and roster aren’t implemented yet. |
41
bc717575e66a
Much better handling of modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
26
diff
changeset
|
30 config.pluginsDir = 'modules'; |
13
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
31 |
0 | 32 config.activated = [ |
33 'auto-create', | |
34 //'auto-subscribe', // Impossible à utiliser dans un component | |
35 //'collections', //TODO | |
36 'config-node', | |
37 'create-and-configure', | |
38 'create-nodes', | |
39 'delete-items', | |
40 'delete-nodes', | |
41 //'filtered-notifications', // Impossible à utiliser dans un component | |
42 'get-pending', | |
43 'instant-nodes', | |
44 'item-ids', | |
45 'last-published', // Impossible de se baser sur la présence dans un component | |
46 //'leased-subscription', //TODO | |
47 'manage-subscriptions', | |
48 'member-affiliation', | |
49 'meta-data', | |
50 'modify-affiliations', | |
51 //'multi-collection', //TODO | |
52 //'multi-subscribe', //TODO | |
53 'outcast-affiliation', | |
54 'persistent-items', | |
55 //'presence-notifications', // Impossible à utiliser dans un component | |
56 //'presence-subscribe', // Impossible à utiliser dans un component | |
57 'publish', | |
58 'publish-options', | |
59 'publish-only-affiliation', | |
60 'publisher-affiliation', | |
61 'purge-nodes', | |
62 'retract-items', | |
63 'retrieve-affiliations', | |
64 'retrieve-default', | |
65 'retrieve-default-sub', | |
66 'retrieve-items', | |
67 'retrieve-subscriptions', | |
68 'subscribe', | |
69 'subscription-options', | |
70 'subscription-notifications', | |
71 ]; | |
72 | |
73 config.service_configuration = { | |
74 subscribe_authorization: { | |
75 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_authorization'}, | |
76 _TITLE: 'PubSub subscriber request', | |
77 _INSTRUCTIONS: 'To approve this entity’s subscription request,\nclick the OK button. To deny the request, click the\ncancel button.', | |
78 'pubsub#allow': {type: 'boolean', label: 'Whether to allow the subscription', value: false}, | |
79 'pubsub#node': {type: 'text-single', label: 'The NodeID of the relevant node'}, | |
80 'pubsub#subid': {type: 'hidden'}, | |
81 'pubsub#subscriber_jid': {type: 'jid-single', label: 'The address (JID) of the subscriber'}, | |
82 }, | |
83 subscribe_options: { | |
84 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_options'}, | |
85 'pubsub#deliver': {type: 'boolean', label: 'Whether an entity wants to receive or disable notifications', value: true}, | |
86 'pubsub#digest': {type: 'boolean', label: 'Whether an entity wants to receive digests (aggregations) of notifications or all notifications individually', value: false}, | |
1
c2954a9e5665
Add a super-owner that has power over all nodes; add support for
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
87 'pubsub#digest_frequency': {type: 'text-single', label: 'The minimum number of milliseconds between sending any two notification digests', value: 24*60*60*1000}, |
0 | 88 // 'pubsub#expire': {type: 'text-single', label: 'The DateTime at which a leased subscription will end or has ended'}, |
89 // 'pubsub#include_body': {type: 'boolean', label: 'Whether an entity wants to receive an XMPP message body in addition to the payload format', value: false}, | |
90 // 'pubsub#show-values': {type: 'list-multi', label: 'The presence states for which an entity wants to receive notifications', options: { | |
91 // away: {label: 'XMPP Show Value of Away'}, | |
92 // chat: {label: 'XMPP Show Value of Chat'}, | |
93 // dnd: {label: 'XMPP Show Value of DND (Do Not Disturb)'}, | |
94 // online: {label: 'Mere Availability in XMPP (No Show Value)'}, | |
95 // xa: {label: 'XMPP Show Value of XA (Extended Away)'}, | |
96 // }, value: ['online', 'chat', 'away']}, | |
97 // 'pubsub#subscription_type': {type: 'list-single', options: { | |
98 // items: {label: 'Receive notification of new items only'}, | |
99 // nodes: {label: 'Receive notification of new nodes only'}, | |
100 // }}, | |
101 // 'pubsub#subscription_depth': {type: 'list-single', options: { | |
102 // '1': {label: 'Receive notification from direct child nodes only'}, | |
103 // all: {label: 'Receive notification from all descendent nodes'}, | |
104 // }}, | |
105 }, | |
106 node_metadata: { | |
107 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#meta-data'}, | |
108 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
109 'pubsub#creation_date': {type: 'text-single', label: 'The datetime when the node was created', value: function(){return new Date();}}, | |
110 'pubsub#creator': {type: 'jid-single', label: 'The JID of the node creator'}, | |
111 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
112 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
113 'pubsub#num_subscribers': {type: 'text-single', label: 'The number of subscribers to the node', value: 0}, | |
114 'pubsub#owner': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of owner'}, | |
115 'pubsub#publisher': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of publisher'}, | |
116 'pubsub#title': {type: 'text-single', label: 'The name of the node'}, | |
117 'pubsub#type': {type: 'text-single', label: 'Payload type'}, | |
118 }, | |
119 node_config: { | |
120 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#node_config'}, | |
121 'pubsub#access_model': {type: 'list-single', label: 'Who may subscribe and retrieve items', options: { | |
122 authorize: {label: 'Subscription requests must be approved and only subscribers may retrieve items'}, | |
123 open: {label: 'Anyone may subscribe and retrieve items'}, | |
124 // presence: {label: 'Anyone with a presence subscription of both or from may subscribe and retrieve items'}, | |
125 // roster: {label: 'Anyone in the specified roster group(s) may subscribe and retrieve items'}, | |
126 whitelist: {label: 'Only those on a whitelist may subscribe and retrieve items'}, | |
127 }}, | |
128 // 'pubsub#body_xslt': {type: 'text-single', label: 'The URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element.'}, | |
129 // 'pubsub#children_association_policy': {type: 'list-single', label: 'Who may associate leaf nodes with a collection', options: { | |
130 // all: {label: 'Anyone may associate leaf nodes with the collection'}, | |
131 // owners: {label: 'Only collection node owners may associate leaf nodes with the collection'}, | |
132 // whitelist: {label: 'Only those on a whitelist may associate leaf nodes with the collection'}, | |
133 // }}, | |
134 // 'pubsub#children_association_whitelist': {type: 'jid-multi', label: 'The list of JIDs that may associate leaf nodes with a collection'}, | |
135 // 'pubsub#children': {type: 'text-multi', label: 'The child nodes (leaf or collection) associated with a collection'}, | |
136 // 'pubsub#children_max': {type: 'text-single', label: 'The maximum number of child nodes that can be associated with a collection'}, | |
137 // 'pubsub#collection': {type: 'text-multi', label: 'The collection(s) with which a node is affiliated'}, | |
138 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
139 // 'pubsub#dataform_xslt': {type: 'text-single', label: 'The URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine'}, | |
140 'pubsub#deliver_notifications': {type: 'boolean', label: 'Whether to deliver event notifications', value: true}, | |
141 // 'pubsub#deliver_payloads': {type: 'boolean', label: 'Whether to deliver payloads with event notifications; applies only to leaf nodes'}, | |
142 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
143 // 'pubsub#item_expire': {type: 'text-single', label: 'Number of seconds after which to automatically purge items'}, | |
144 // 'pubsub#itemreply': {type: 'list-single', label: 'Whether owners or publisher should receive replies to items', options: { | |
145 // owner: {label: 'Statically specify a replyto of the node owner(s)'}, | |
146 // publisher: {label: 'Dynamically specify a replyto of the item publisher'}, | |
147 // }}, | |
148 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
149 // 'pubsub#max_items': {type: 'text-single', label: 'The maximum number of items to persist'}, | |
150 // 'pubsub#max_payload_size': {type: 'text-single', label: 'The maximum payload size in bytes'}, | |
151 'pubsub#node_type': {type: 'list-single', label: 'Whether the node is a leaf (default) or a collection', options: { | |
152 leaf: {label: 'The node is a leaf node (default)'}, | |
153 collection: {label: 'The node is a collection node'}, | |
154 }, value: 'leaf'}, | |
155 // 'pubsub#notification_type': {type: 'list-single', label: 'Specify the delivery style for notifications', options: { | |
156 // normal: {label: 'Messages of type normal'}, | |
157 // headline: {label: 'Messages of type headline'}, | |
158 // iq: {label: 'IQ stanzas (works only with presence-based delivery)'}, | |
159 // }}, | |
160 // 'pubsub#notify_config': {type: 'boolean', label: 'Whether to notify subscribers when the node configuration changes'}, | |
161 // 'pubsub#notify_delete': {type: 'boolean', label: 'Whether to notify subscribers when the node is deleted'}, | |
162 // 'pubsub#notify_retract': {type: 'boolean', label: 'Whether to notify subscribers when items are removed from the node'}, | |
163 // 'pubsub#notify_sub': {type: 'boolean', label: 'Whether to notify owners about new subscribers and unsubscribes'}, | |
164 // 'pubsub#persist_items': {type: 'boolean', label: 'Whether to persist items to storage'}, | |
165 // 'pubsub#presence_based_delivery': {type: 'boolean', label: 'Whether to deliver notifications to available users only'}, | |
166 'pubsub#publish_model': {type: 'list-single', label: 'The publisher model', options: { | |
167 publishers: {label: 'Only publishers may publish'}, | |
168 subscribers: {label: 'Subscribers may publish'}, | |
169 open: {label: 'Anyone may publish'}, | |
170 }, value: 'publishers'}, | |
171 // 'pubsub#purge_offline': {type: 'boolean', label: 'Whether to purge all items when the relevant publisher goes offline'}, | |
172 // 'pubsub#roster_groups_allowed': {type: 'list-multi', label: 'The roster group(s) allowed to subscribe and retrieve items'}, | |
173 // 'pubsub#send_last_published_item': {type: 'list-single', label: 'When to send the last published item', options: { | |
174 // never: {label: 'Never'}, | |
175 // on_sub: {label: 'When a new subscription is processed'}, | |
176 // on_sub_and_presence: {label: 'When a new subscription is processed and whenever a subscriber comes online'}, | |
177 // }, value: 'never'}, | |
178 // 'pubsub#tempsub': {type: 'boolean', label: 'Whether to make all subscriptions temporary, based on subscriber presence'}, | |
179 'pubsub#subscribe': {type: 'boolean', label: 'Whether to allow subscriptions', value: true}, | |
180 'pubsub#title': {type: 'text-single', label: 'A friendly name for the node'}, | |
181 'pubsub#type': {type: 'text-single', label: 'The type of node data, usually specified by the namespace of the payload (if any)', value: 'http://www.w3.org/2005/Atom'}, | |
182 }, | |
183 'publish-options': { | |
184 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#publish-options'}, | |
185 'pubsub#access_model': {type: 'list-single', label: 'Precondition: node configuration with the specified access model', options: { | |
186 authorize: {label: 'Access model of authorize'}, | |
187 open: {label: 'Access model of open'}, | |
188 // presence: {label: 'Access model of presence'}, | |
189 // roster: {label: 'Access model of roster'}, | |
190 whitelist: {label: 'Access model of whitelist'}, | |
191 }, value: 'open'}, | |
192 }, | |
193 }; | |
194 | |
195 config.Configuration = function(def, params) { | |
196 for (var i in def) { | |
197 if (typeof (def[i].value) != 'undefined') { | |
198 if (typeof (def[i].value) == 'function') | |
199 this[i] = def[i].value(); | |
200 else | |
201 this[i] = def[i].value; | |
202 } | |
203 } | |
204 if (params) | |
205 for (var i in params) | |
10
44889cfb2f8c
Fix getItem method.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7
diff
changeset
|
206 if (typeof def[i] != 'undefined') |
44889cfb2f8c
Fix getItem method.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7
diff
changeset
|
207 this[i] = params[i]; |
0 | 208 }; |
209 | |
210 config.enabled = function(feature) { | |
211 for (var i in config.activated) | |
212 if (typeof i == 'string' && feature == config.activated[i]) | |
213 return true; | |
214 return false; | |
215 }; | |
216 | |
13
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
217 config.enable = function(feature) { |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
218 config.activated.push(feature); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
219 } |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
220 |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
221 config.disable = function(feature) { |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
222 if (typeof feature == 'string') |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
223 config.activated.splice(config.activated.indexOf(feature), 1); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
224 else if (typeof feature == 'function') { |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
225 for (var i in config.activated) |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
226 if (feature(config.activated[i])) |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
227 config.disable(config.activated[i]); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
228 } |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
229 } |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
230 |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
231 if (config.access == 'whitelist') { |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
232 config.disable(/access-.+/); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
233 config.enable('access-whitelist'); |
0 | 234 config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist'; |
235 config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist'; | |
14
06abc804e2ab
Correct syntax error.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
13
diff
changeset
|
236 } else if (config.access == 'authorize') { |
13
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
237 config.disable(/access-.+/); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
238 config.enable('access-authorize'); |
0 | 239 config.service_configuration.node_config['pubsub#access_model'].value = 'authorize'; |
240 config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize'; | |
14
06abc804e2ab
Correct syntax error.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
13
diff
changeset
|
241 } else if (config.access == 'open') { |
13
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
242 config.disable(/access-.+/); |
447db2e8c622
Better access mode handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
10
diff
changeset
|
243 config.enable('access-open'); |
0 | 244 config.service_configuration.node_config['pubsub#access_model'].value = 'open'; |
245 config.service_configuration['publish-options']['pubsub#access_model'].value = 'open'; | |
246 } |