core/actions.lua

Wed, 14 Apr 2010 13:01:10 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 14 Apr 2010 13:01:10 +0100
changeset 2982
0395f2f34bd5
parent 2923
b7049746bd29
permissions
-rw-r--r--

prosody.cfg.lua.dist: Refactor the default config file based on feedback from confused users

1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
4 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
6 -- COPYING file in the source package for more information.
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
7 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 698
diff changeset
8
698
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local actions = {};
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 function register(path, t)
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local curr = actions;
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 for comp in path:gmatch("([^/]+)/") do
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 if curr[comp] == nil then
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 curr[comp] = {};
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 curr = curr[comp];
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 if type(curr) ~= "table" then
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 return nil, "path-taken";
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 end
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 end
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 curr[path:match("/([^/]+)$")] = t;
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 return true;
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 end
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
d8a678e40a0a Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 return { actions = actions, register= register };

mercurial