Mercurial > prosody-modules
annotate mod_http_index/mod_http_index.lua @ 1661:69aa2b54ba8a
mod_privilege: implemented message privilege
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 02 Apr 2015 21:47:05 +0200 |
parents | 0d8cc6971cdb |
children | 1b5c817cb642 |
rev | line source |
---|---|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local url = require"socket.url"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 module:depends"http"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 -- local dump = require"util.serialization".new"dump".serialize; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local function template(data) |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 --[[ DOC |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 Like util.template, but deals with plain text |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 Returns a closure that is called with a table of values |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 {name} is substituted for values["name"] and is XML escaped |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 {name!} is substituted without XML escaping |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 {name?} is optional and is replaced with an empty string if no value exists |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 ]] |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 return function(values) |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 return (data:gsub("{([^}]-)(%p?)}", function (name, opt) |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local value = values[name]; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 if value then |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 if opt ~= "!" then |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 return st.xml_escape(value); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 return value; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 elseif opt == "?" then |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 return ""; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end)); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 -- TODO Move templates into files |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 local base = template(template[[ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 <!DOCTYPE html> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 <html> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 <head> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 <meta charset="utf-8"> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 <meta name="viewport" content="width=device-width, initial-scale=1"> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 <meta name="generator" value="prosody/{prosody_version} mod_{mod_name}"> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 <link rel="canonical" href="{canonical}"> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 <title>{title}</title> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 <style> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 header,footer{margin:1ex 1em;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 footer{font-size:smaller;color:#babdb6;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 .content{background-color:white;padding:1em;list-style-position:inside;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 nav a{padding: 1ex;text-decoration:none;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 nav a[rel="up"]{font-size:smaller;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 nav a[rel="prev"]{float:left;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 nav a[rel="next"]{float:right;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 nav a[rel="next::after"]{content:" →";} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 nav a[rel="prev::before"]{content:"← ";} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 nav a:empty::after,nav a:empty::before{content:""} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 @media screen and (min-width: 460px) { |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 nav{font-size:x-large;margin:1ex 1em;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 } |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 a:link,a:visited{color:#2e3436;text-decoration:none;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 a:link:hover,a:visited:hover{color:#3465a4;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
59 ul,ol{padding:0;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
60 li{list-style:none;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
61 hr{visibility:hidden;clear:both;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
62 br{clear:both;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
63 li time{float:right;font-size:small;opacity:0.2;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
64 li:hover time{opacity:1;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
65 .room-list .description{font-size:smaller;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
66 q.body::before,q.body::after{content:"";} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 .presence .verb{font-style:normal;color:#30c030;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
68 .presence.unavailable .verb{color:#c03030;} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
69 </style> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
70 </head> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
71 <body> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
72 <header> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
73 <h1>{title}</h1> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
74 {header!} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
75 </header> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
76 <hr> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
77 <div class="content"> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
78 {body!} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
79 </div> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
80 <hr> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
81 <footer> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
82 {footer!} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
83 <br> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
84 <div class="powered-by">Prosody {prosody_version?}</div> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
85 </footer> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
86 </body> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
87 </html> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
88 ]] { prosody_version = prosody.version, mod_name = module.name }); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
89 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
90 local canonical = module:http_url(nil, "/"); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
91 local page_template = template(base{ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
92 canonical = canonical; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
93 title = "HTTP stuff"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
94 header = ""; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
95 body = [[ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
96 <nav> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
97 <ul> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
98 {lines!} |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
99 </ul> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
100 </nav> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
101 ]]; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
102 footer = ""; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
103 }); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
104 local line_template = template[[ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
105 <li><a href="{url}" title="{module}">{name}</a></li> |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
106 ]]; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
107 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
108 local function relative(base, link) |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
109 base = url.parse(base); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
110 link = url.parse(link); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
111 for k,v in pairs(base) do |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
112 if link[k] == v then |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
113 link[k] = nil; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
114 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
115 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
116 return url.build(link); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
117 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
118 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
119 local function handler(event) |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
120 local items = module:get_host_items("http-provider"); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
121 local item; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
122 for i = 1, #items do |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
123 item = items[i]; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
124 if module.name ~= item._provided_by then |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
125 items[i] = line_template{ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
126 name = item.name; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
127 module = "mod_" .. item._provided_by; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
128 url = relative(canonical, module:http_url(item.name, item.default_path)); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
129 }; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
130 else |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
131 items[i] = ""; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
132 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
133 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
134 event.response.headers.content_type = "text/html"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
135 return page_template{ |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
136 lines = table.concat(items); |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
137 }; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
138 end |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
139 |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
140 module:provides("http", { |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
141 route = { |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
142 ["GET /"] = handler; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
143 }; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
144 default_path = "/"; |
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
145 }); |