Mercurial > psgxs
annotate configuration.js @ 10:44889cfb2f8c
Fix getItem method.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 27 Aug 2010 01:02:56 +0200 |
parents | 781ac4f1e304 |
children | 447db2e8c622 |
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 []. |
0 | 28 |
29 config.activated = [ | |
30 //'access-authorize', | |
31 //'access-open', | |
32 //'access-presence', // Impossible à utiliser dans un component | |
33 //'access-roster', // Impossible à utiliser dans un component | |
34 'access-whitelist', | |
35 'auto-create', | |
36 //'auto-subscribe', // Impossible à utiliser dans un component | |
37 //'collections', //TODO | |
38 'config-node', | |
39 'create-and-configure', | |
40 'create-nodes', | |
41 'delete-items', | |
42 'delete-nodes', | |
43 //'filtered-notifications', // Impossible à utiliser dans un component | |
44 'get-pending', | |
45 'instant-nodes', | |
46 'item-ids', | |
47 'last-published', // Impossible de se baser sur la présence dans un component | |
48 //'leased-subscription', //TODO | |
49 'manage-subscriptions', | |
50 'member-affiliation', | |
51 'meta-data', | |
52 'modify-affiliations', | |
53 //'multi-collection', //TODO | |
54 //'multi-subscribe', //TODO | |
55 'outcast-affiliation', | |
56 'persistent-items', | |
57 //'presence-notifications', // Impossible à utiliser dans un component | |
58 //'presence-subscribe', // Impossible à utiliser dans un component | |
59 'publish', | |
60 'publish-options', | |
61 'publish-only-affiliation', | |
62 'publisher-affiliation', | |
63 'purge-nodes', | |
64 'retract-items', | |
65 'retrieve-affiliations', | |
66 'retrieve-default', | |
67 'retrieve-default-sub', | |
68 'retrieve-items', | |
69 'retrieve-subscriptions', | |
70 'subscribe', | |
71 'subscription-options', | |
72 'subscription-notifications', | |
73 ]; | |
74 | |
75 config.service_configuration = { | |
76 subscribe_authorization: { | |
77 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_authorization'}, | |
78 _TITLE: 'PubSub subscriber request', | |
79 _INSTRUCTIONS: 'To approve this entity’s subscription request,\nclick the OK button. To deny the request, click the\ncancel button.', | |
80 'pubsub#allow': {type: 'boolean', label: 'Whether to allow the subscription', value: false}, | |
81 'pubsub#node': {type: 'text-single', label: 'The NodeID of the relevant node'}, | |
82 'pubsub#subid': {type: 'hidden'}, | |
83 'pubsub#subscriber_jid': {type: 'jid-single', label: 'The address (JID) of the subscriber'}, | |
84 }, | |
85 subscribe_options: { | |
86 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_options'}, | |
87 'pubsub#deliver': {type: 'boolean', label: 'Whether an entity wants to receive or disable notifications', value: true}, | |
88 '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
|
89 'pubsub#digest_frequency': {type: 'text-single', label: 'The minimum number of milliseconds between sending any two notification digests', value: 24*60*60*1000}, |
0 | 90 // 'pubsub#expire': {type: 'text-single', label: 'The DateTime at which a leased subscription will end or has ended'}, |
91 // 'pubsub#include_body': {type: 'boolean', label: 'Whether an entity wants to receive an XMPP message body in addition to the payload format', value: false}, | |
92 // 'pubsub#show-values': {type: 'list-multi', label: 'The presence states for which an entity wants to receive notifications', options: { | |
93 // away: {label: 'XMPP Show Value of Away'}, | |
94 // chat: {label: 'XMPP Show Value of Chat'}, | |
95 // dnd: {label: 'XMPP Show Value of DND (Do Not Disturb)'}, | |
96 // online: {label: 'Mere Availability in XMPP (No Show Value)'}, | |
97 // xa: {label: 'XMPP Show Value of XA (Extended Away)'}, | |
98 // }, value: ['online', 'chat', 'away']}, | |
99 // 'pubsub#subscription_type': {type: 'list-single', options: { | |
100 // items: {label: 'Receive notification of new items only'}, | |
101 // nodes: {label: 'Receive notification of new nodes only'}, | |
102 // }}, | |
103 // 'pubsub#subscription_depth': {type: 'list-single', options: { | |
104 // '1': {label: 'Receive notification from direct child nodes only'}, | |
105 // all: {label: 'Receive notification from all descendent nodes'}, | |
106 // }}, | |
107 }, | |
108 node_metadata: { | |
109 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#meta-data'}, | |
110 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
111 'pubsub#creation_date': {type: 'text-single', label: 'The datetime when the node was created', value: function(){return new Date();}}, | |
112 'pubsub#creator': {type: 'jid-single', label: 'The JID of the node creator'}, | |
113 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
114 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
115 'pubsub#num_subscribers': {type: 'text-single', label: 'The number of subscribers to the node', value: 0}, | |
116 'pubsub#owner': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of owner'}, | |
117 'pubsub#publisher': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of publisher'}, | |
118 'pubsub#title': {type: 'text-single', label: 'The name of the node'}, | |
119 'pubsub#type': {type: 'text-single', label: 'Payload type'}, | |
120 }, | |
121 node_config: { | |
122 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#node_config'}, | |
123 'pubsub#access_model': {type: 'list-single', label: 'Who may subscribe and retrieve items', options: { | |
124 authorize: {label: 'Subscription requests must be approved and only subscribers may retrieve items'}, | |
125 open: {label: 'Anyone may subscribe and retrieve items'}, | |
126 // presence: {label: 'Anyone with a presence subscription of both or from may subscribe and retrieve items'}, | |
127 // roster: {label: 'Anyone in the specified roster group(s) may subscribe and retrieve items'}, | |
128 whitelist: {label: 'Only those on a whitelist may subscribe and retrieve items'}, | |
129 }}, | |
130 // '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.'}, | |
131 // 'pubsub#children_association_policy': {type: 'list-single', label: 'Who may associate leaf nodes with a collection', options: { | |
132 // all: {label: 'Anyone may associate leaf nodes with the collection'}, | |
133 // owners: {label: 'Only collection node owners may associate leaf nodes with the collection'}, | |
134 // whitelist: {label: 'Only those on a whitelist may associate leaf nodes with the collection'}, | |
135 // }}, | |
136 // 'pubsub#children_association_whitelist': {type: 'jid-multi', label: 'The list of JIDs that may associate leaf nodes with a collection'}, | |
137 // 'pubsub#children': {type: 'text-multi', label: 'The child nodes (leaf or collection) associated with a collection'}, | |
138 // 'pubsub#children_max': {type: 'text-single', label: 'The maximum number of child nodes that can be associated with a collection'}, | |
139 // 'pubsub#collection': {type: 'text-multi', label: 'The collection(s) with which a node is affiliated'}, | |
140 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
141 // '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'}, | |
142 'pubsub#deliver_notifications': {type: 'boolean', label: 'Whether to deliver event notifications', value: true}, | |
143 // 'pubsub#deliver_payloads': {type: 'boolean', label: 'Whether to deliver payloads with event notifications; applies only to leaf nodes'}, | |
144 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
145 // 'pubsub#item_expire': {type: 'text-single', label: 'Number of seconds after which to automatically purge items'}, | |
146 // 'pubsub#itemreply': {type: 'list-single', label: 'Whether owners or publisher should receive replies to items', options: { | |
147 // owner: {label: 'Statically specify a replyto of the node owner(s)'}, | |
148 // publisher: {label: 'Dynamically specify a replyto of the item publisher'}, | |
149 // }}, | |
150 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
151 // 'pubsub#max_items': {type: 'text-single', label: 'The maximum number of items to persist'}, | |
152 // 'pubsub#max_payload_size': {type: 'text-single', label: 'The maximum payload size in bytes'}, | |
153 'pubsub#node_type': {type: 'list-single', label: 'Whether the node is a leaf (default) or a collection', options: { | |
154 leaf: {label: 'The node is a leaf node (default)'}, | |
155 collection: {label: 'The node is a collection node'}, | |
156 }, value: 'leaf'}, | |
157 // 'pubsub#notification_type': {type: 'list-single', label: 'Specify the delivery style for notifications', options: { | |
158 // normal: {label: 'Messages of type normal'}, | |
159 // headline: {label: 'Messages of type headline'}, | |
160 // iq: {label: 'IQ stanzas (works only with presence-based delivery)'}, | |
161 // }}, | |
162 // 'pubsub#notify_config': {type: 'boolean', label: 'Whether to notify subscribers when the node configuration changes'}, | |
163 // 'pubsub#notify_delete': {type: 'boolean', label: 'Whether to notify subscribers when the node is deleted'}, | |
164 // 'pubsub#notify_retract': {type: 'boolean', label: 'Whether to notify subscribers when items are removed from the node'}, | |
165 // 'pubsub#notify_sub': {type: 'boolean', label: 'Whether to notify owners about new subscribers and unsubscribes'}, | |
166 // 'pubsub#persist_items': {type: 'boolean', label: 'Whether to persist items to storage'}, | |
167 // 'pubsub#presence_based_delivery': {type: 'boolean', label: 'Whether to deliver notifications to available users only'}, | |
168 'pubsub#publish_model': {type: 'list-single', label: 'The publisher model', options: { | |
169 publishers: {label: 'Only publishers may publish'}, | |
170 subscribers: {label: 'Subscribers may publish'}, | |
171 open: {label: 'Anyone may publish'}, | |
172 }, value: 'publishers'}, | |
173 // 'pubsub#purge_offline': {type: 'boolean', label: 'Whether to purge all items when the relevant publisher goes offline'}, | |
174 // 'pubsub#roster_groups_allowed': {type: 'list-multi', label: 'The roster group(s) allowed to subscribe and retrieve items'}, | |
175 // 'pubsub#send_last_published_item': {type: 'list-single', label: 'When to send the last published item', options: { | |
176 // never: {label: 'Never'}, | |
177 // on_sub: {label: 'When a new subscription is processed'}, | |
178 // on_sub_and_presence: {label: 'When a new subscription is processed and whenever a subscriber comes online'}, | |
179 // }, value: 'never'}, | |
180 // 'pubsub#tempsub': {type: 'boolean', label: 'Whether to make all subscriptions temporary, based on subscriber presence'}, | |
181 'pubsub#subscribe': {type: 'boolean', label: 'Whether to allow subscriptions', value: true}, | |
182 'pubsub#title': {type: 'text-single', label: 'A friendly name for the node'}, | |
183 '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'}, | |
184 }, | |
185 'publish-options': { | |
186 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#publish-options'}, | |
187 'pubsub#access_model': {type: 'list-single', label: 'Precondition: node configuration with the specified access model', options: { | |
188 authorize: {label: 'Access model of authorize'}, | |
189 open: {label: 'Access model of open'}, | |
190 // presence: {label: 'Access model of presence'}, | |
191 // roster: {label: 'Access model of roster'}, | |
192 whitelist: {label: 'Access model of whitelist'}, | |
193 }, value: 'open'}, | |
194 }, | |
195 }; | |
196 | |
197 config.Configuration = function(def, params) { | |
198 for (var i in def) { | |
199 if (typeof (def[i].value) != 'undefined') { | |
200 if (typeof (def[i].value) == 'function') | |
201 this[i] = def[i].value(); | |
202 else | |
203 this[i] = def[i].value; | |
204 } | |
205 } | |
206 if (params) | |
207 for (var i in params) | |
10
44889cfb2f8c
Fix getItem method.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7
diff
changeset
|
208 if (typeof def[i] != 'undefined') |
44889cfb2f8c
Fix getItem method.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7
diff
changeset
|
209 this[i] = params[i]; |
0 | 210 }; |
211 | |
212 config.enabled = function(feature) { | |
213 for (var i in config.activated) | |
214 if (typeof i == 'string' && feature == config.activated[i]) | |
215 return true; | |
216 return false; | |
217 }; | |
218 | |
219 if (config.enabled('access-whitelist')) { | |
220 config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist'; | |
221 config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist'; | |
222 } else if (config.enabled('access-authorize')) { | |
223 config.service_configuration.node_config['pubsub#access_model'].value = 'authorize'; | |
224 config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize'; | |
225 } else if (config.enabled('access-open')) { | |
226 config.service_configuration.node_config['pubsub#access_model'].value = 'open'; | |
227 config.service_configuration['publish-options']['pubsub#access_model'].value = 'open'; | |
228 } |