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