Annotate

mod_webpresence/mod_webpresence.lua @ 158:1a5d5d4f08fe

Add "generic" script support to mod_extauth, as well as lpc support until waqas fixes process
author Jeff Mitchell <jeff@jefferai.org>
date Fri, 28 May 2010 16:19:27 -0400 (2010-05-28)
parent 4:63080b8973ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 do local e={};e["icons/status_online.png"]='�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\0IDAT(�U�_h[u�?�wo�M�65K�el]�+��a[u�OE\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 "�>D܆P�d0����/V�ӗ�XAa��)��Ct�i�����n7�U��$m�&Mn��{ׇ;kw���p�� �s��뺬�\'?��7C��jZ�����Ԣ� T��u����\\;�zV��wxG�n{f4�3� ��wiI���/�/���ѿ�^;y�^���#����j�b��B\0H["�%v��1���k�?�R۶��<�\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 ���\\b��Ь*Z@C�{�A\r�PQu%� 3ε�jL�\0���ޕ�{Yh� T��P���y��ɟ\'�� ��ޫ��?��(��a+d E((BAh�c3T���^Ob0�a��2K�%u���U�-��.�x"-K��Ÿ`ߖ}�zb���cz�4P��ª��ґȲ�9���l��6m�i���b��A.w\\Fn�/7XQA GZ�Ч!��~�a�lcm"G"�9��� ��<�����x�ULE���o.5�"-�-�>~�@6@��$� >�<JӚ&�q��8���<���pZ �)�[�<�H \'\0�I���%��~#�t�gR!X����־����ؽ���2F�� #�\0p�C܈���wp*<��d������3S��/?�oY�V�\\�v�6 X����a\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 �V�������� SC�����T&��[��ζ�B5�?�1� 2oe@��uw�DήI����\'�%�+ƈ�ݩ�QN��{<�J᱂�TTd�:\r�6��\\\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 }��q���s��C�Z��ӝ/V�����jg-hE�����ӯ�������_���\'�i�~�&\0\0\0\0IEND�B`�'e["icons/status_away.png"]='�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\01IDAT(�U�_L�u\0����{���Q�D� at���Ԍp�X�H�g��\\��5��a��Vm��څEK��E.Bm,\'� �H�)” �����9�y��{]�����s�<�R��9���/���*���nA<�Ʀ]���m�����s��=��nS�lq����2����\0�t��c3w���r��I��p��w��~�x�ry��T��n0�i���i���8��.�p�ԉ3J\0<����X-V\0=0}�|�`�?���b��`�7A�}��m\0����m���5Ç0M���sf��Dj��K��+��XΚ����<_��0UzW8� �@:�a �~tˏfhB��á��f,��ͤX�(�[��>c��y�@y(�)��BI���,Y��ue�y�z3o�$胰�Z&�,�PII*���C����$2�d�I�{C��ֻ|���S����<\0��"�r��:��p�.���d�J�I$x�-���6~����/���Q�`�ք1>�E�b�}t~x�֣ͼw��Ҩ�{�u���5�T%�%%\0�Ӿ��}�f&����Կ�G��Ъ`x��7<IM��Gw3H�@*�;0��K"���U�Dtd��/�M}C#6nfo��l ^`E(����5�����y�z�_C����z�cy�+W�� ���um��d��sx�IT�f�`2��\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 �{~��_SJQ]�U+����FFK�3��GϰőgƘY�Lz�A>�=4�>���=Fu�VC�h��?��bɔ�4C̠ɬ�w��U������j�wv����{Y[��ҏ]�@��*���N�n߼k^���q�Ro���,3v��,j�\0\0\0\0IEND�B`�'e["icons/status_xa.png"]="�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\07IDAT(�U�mLUu\0���s�=�s�7���Lo�C؂��jm\r��IlB��h�����Ћ�sE�����zq���ImI�,m �(6�)|P,��.��������������쑄,Ϟ��6��ivF�jYEq�hF���������tC�m���E?�K�ۤIH�m L����Dm�3�r�љPy����uS�m���^����JUMƥ�\0X�C�p�O��Kk���-,�>_SU180$d����'�x���h���S��T��>u��o�_PD�����87s@~���i�ҵ�/����M4��ώ��#���8�ӹk/�Ot���$X�ʖ���k%�|!�X�P�KW����6�օx�s �b��G�uk;/?����etJ� ����%{�F���� �};y�X��/��!�����8B��aa������ҁ��D����>7^��Ӷ���*>��+�~?�X�ƚ{y_��IX��&�����Eq9ic�9��acd�d���i��(\0�`���vp�\0��`�׫Ӓ$�j���5�T ��O\r�7��M\r��Ӆat=� �P%��p���x��‚Y%�j3ٌ]p�񠷵Ѻ���~D������a&FFس�\0w����zv��XԽ3R䡺�����L'\\�+�z� � �����װL�3��ZU��딎��������͒��á#��N�ge���ʑ\\2��Q�m ,K2�L��M�7��^hQ\0��ڎc����+���_ ��E�e'(.�i-\\1��m����J������X�������M1�Q䋉���;Vw�>�E����*�lwQ:����E�=wUU'���v�?�����h��j��\0\0\0\0IEND�B`�"e["icons/status_dnd.png"]="�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\0�IDAT(�}��k\\U���s��;IBj�\"���2h���RL��M[pQ����WnDtUQ(�nZ*6�]T�\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 �ªP-�lL-I�$����w���⚚ ���w��^x��D�����;{��-��S�GZ�宩�������_��U���٣��6�?�j��d\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 %!���E`9�x��}W'��zy�?�O��Z�����x�i��.�+#E��i:mϷ{G~;�ܡ����\0h�^x���k}���`m�^D�@ �w��)��|xp��_�'�浙�7~0XS*�'�}�z�`��@�B�����\"v�|�_���:;��ڢ�1�Z� R��Z�5(�P\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 ����_��6ϙ�(��\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 7�\0i���+R�1J�1A 1D�i�W���L�>�F�b�{s����9�s��f�=��?���=7j�!!ƈ�k-�� �(�ͦJVj�<w�]>�3��B� DAD�֚�Z�]1�4[���C��/��4�j�D!@ ��UY��@�����}�b�������SC�B�P��ʴ�zE�,E�n�w��������p�1����e:�]Yߕ��_��\\|j�ڭ{����ɉ�'�֓�{�+�� |�_����R:6rj��x����u�Rc���ፖN� uj)���О�O�?y�[�]𶎼�x�t��#������fjWW���d�������ݿ(�y�Ri�\0\0\0\0IEND�B`�"e["icons/status_chat.png"]='�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\0IDAT(�U�L�u����s��!����D�`s��q�Y:3�deS˭��1���5d�-���m�f�rㇶ6;f-o��Zs؈X6`LԎ�� �����������K��k?��P�W�t:r5c�0:��75m\rLƌP��/ު���z��[�/�=�����@�4"�Xb24��~����ğo/�ǎ�{_h���h�*�Rn�r"),I �$��3�=]}8�@�m��@�J���.Fk/Z�к�<���-�n��o:����\0���w��//��g�Mk6�E)�ŲbX�}N����\r�`"�&�����o++tyY�ŕ�Ma�p\0�к�\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 P�E�h�������v��si�w%]��D�a�gk�B�Y �e%�,���Nݦ��G�{�bu�o��X�d(-��+�g�E2tw�P\\<M�3N��G���ɓg�7�������-I�33ss��&ׯ���oC�?xzg���c�+�YS�����f �\0�\0� �Ld�D" jk�s����b��� �"|�#G�p�g�,,K1q�yGϦ�̓g����Z[/��\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 u����Z� �@\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 �J 2���ܝ����u�ȵ���X%�W�իa���u�H����H�T7���j*�jލ�������Z&cy�����\\�={��� $n��Cq��.�u��~-" "�������.�D�}��䧟�7��Knٲ�7��Su�%XDx�����7��{lK��`��-�����("��j��[ ,ϛ\rVT�V/se}�c��Ȉ��aw^�������b�@0�3\0\0\0\0IEND�B`�'e["icons/status_offline.png"]="�PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0�V%\0\0\0sBIT|d�\0\0\0 pHYs\0\0\r�\0\0\r�B(�x\0\0\0tEXtSoftware\0www.inkscape.org��<\0\0IDAT(�U��Kcg��^���\\��[;���S�Ap�)t�m�L)3V,dp��`6��� �]�/BA�2�JA�P���(����i�NҚdD'~Nr?޷�X��ٝ��=�Q��\\�_?V����AQ�v� �������埮g�j���C�i�a����(\0B<��u].//��ūT]>Z~��P�E� o5Fo �f���0 \0����P0w�r���{�U���F��փ�6660 �41 ]����!�J��d޽<�<P>�߯F>���������H)�u�t:���8###8�����F0>0��{5���놚�d���dpp���vFGG�m���n��8�T���ft]GJ���Q��\0�X���y������`ee������YZZb�����I��)����F�\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 (��szz����P���#z{{��bT*��2������Du��<��$MMM�E\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 �\0�m�L&�����<�\0x��jm7���֬������J����#�LR�TH$�������eYh���i)���˸���8d�Y��������Β�f���abb���~����u]|�e���>�Ь�¡��������R�D\"Agg'��S,�RRWWG�TUʓ��EJ�Gw?�ގ��<�\\.�������i��#��������3y��_?n���T�p�ztx\\�CQ���۶B�� ˲ ^���E�W���lx��V��ߥ�� aY�7�&���Â�3�Y�D��_~���UUu��۟_<1��mU�ir���r���Z���7�������g����D\0\0\0\0IEND�B`�"function require_resource(r)return e[r]or error("resource '"..tostring(r).."' not found");end end local s=require"util.jid".prepped_split;if not require_resource then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 function require_resource(e)local r=io.open((config.get("*","core","presence_icons")or"")..e);if r then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 return r:read("*a");end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 module:log("warn","Failed to open image file %s",(config.get("*","core","presence_icons")or"")..e);return"";end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 local e={status="404 Not Found",body="<h1>Page Not Found</h1>Sorry, we couldn't find what you were looking for :("};local n={"online","away","xa","dnd","chat","offline"};for r,e in ipairs(n)do
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 n[e]={status="200 OK",headers={["Content-Type"]="image/png"},body=require_resource("icons/status_"..e..".png")};end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 local function t(e,e,o)local e=o.url.path:match("[^/]+$");if e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 local r,e=s(e);if e and not r then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 r,e=e,o.headers.host;if e then e=e:gsub(":%d+$","");end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 if r and e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local e=hosts[e]and hosts[e].sessions[r];if e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local e=e.top_resources[1];if e and e.presence then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 e=e.presence:child_with_name("show");if not e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 e="online";else
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 e=e:get_text();end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 return n[e];end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 return n.offline;end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 local e=config.get(module.host,"core","http_ports")or{5280};require"net.httpserver".new_from_config(e,"status",t);