Mercurial > prosody-modules
annotate mod_candy/mod_candy.lua @ 1567:585bb8ac11bb
mod_muc_log: Change to a non-locale dependent timestamp format
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 10 Nov 2014 14:47:54 +0100 |
parents | f67eacb1ac9f |
children | 991a5f74f848 |
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"); |
1384
f67eacb1ac9f
mod_candy: Redirect from /candy -> /candy/
Kim Alvefur <zash@zash.se>
parents:
1031
diff
changeset
|
26 GET = function(event) |
f67eacb1ac9f
mod_candy: Redirect from /candy -> /candy/
Kim Alvefur <zash@zash.se>
parents:
1031
diff
changeset
|
27 event.response.headers.location = event.request.path.."/"; |
f67eacb1ac9f
mod_candy: Redirect from /candy -> /candy/
Kim Alvefur <zash@zash.se>
parents:
1031
diff
changeset
|
28 return 301; |
f67eacb1ac9f
mod_candy: Redirect from /candy -> /candy/
Kim Alvefur <zash@zash.se>
parents:
1031
diff
changeset
|
29 end; |
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
|
30 } |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 }); |
5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 |