Software /
code /
prosody-modules
Annotate
mod_candy/mod_candy.lua @ 1204:fc42f8484451
mod_s2s_keysize_policy: Add note about required LuaSec patch
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Sep 2013 19:11:29 +0200 |
parent | 1031:6b34cc81e15d |
child | 1384:f67eacb1ac9f |
rev | line source |
---|---|
933
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- mod_candy.lua |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 -- Copyright (C) 2013 Kim Alvefur |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 -- Run this in www_files |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 -- curl -L http://github.com/candy-chat/candy/tarball/master | tar xzfv - --strip-components=1 |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local json_encode = require"util.json".encode; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
1031
6b34cc81e15d
mod_candy: Add dependency on mod_bosh
Kim Alvefur <zash@zash.se>
parents:
933
diff
changeset
|
9 module:depends"bosh"; |
933
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local serve = module:depends"http_files".serve; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 module:provides("http", { |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 route = { |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 ["GET /prosody.js"] = function(event) |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 event.response.headers.content_type = "text/javascript"; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 return ("// Generated by Prosody\n" |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 .."var Prosody = %s;\n") |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 :format(json_encode({ |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 bosh_path = module:http_url("bosh","/http-bind"); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 version = prosody.version; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 host = module:get_host(); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 anonymous = module:get_option_string("authentication") == "anonymous"; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 })); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 end; |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 ["GET /*"] = serve(module:get_directory().."/www_files"); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 } |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 }); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 |