Changeset

1827:9376e870f0e1

mod_http_index: Move template out into a file and make it configurable
author Kim Alvefur <zash@zash.se>
date Fri, 04 Sep 2015 00:23:46 +0200
parents 1826:ae2235d6c3f8
children 1828:318f38d79ea9
files mod_http_index/http_index.html mod_http_index/mod_http_index.lua
diffstat 2 files changed, 53 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_http_index/http_index.html	Fri Sep 04 00:23:46 2015 +0200
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta name="generator" value="prosody/{prosody_version} mod_{mod_name}">
+<link rel="canonical" href="{canonical}">
+<title>{title}</title>
+<style>
+body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;}
+header,footer{margin:1ex 1em;}
+footer{font-size:smaller;color:#babdb6;}
+.content{background-color:white;padding:1em;list-style-position:inside;}
+nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;}
+nav a{padding: 1ex;text-decoration:none;}
+@media screen and (min-width: 460px) {
+nav{font-size:x-large;margin:1ex 1em;}
+}
+a:link,a:visited{color:#2e3436;text-decoration:none;}
+a:link:hover,a:visited:hover{color:#3465a4;}
+ul{padding:0;}
+li{list-style:none;}
+hr{visibility:hidden;clear:both;}
+br{clear:both;}
+li:hover time{opacity:1;}
+</style>
+</head>
+<body>
+<header>
+<h1>HTTP Apps</h1>
+</header>
+<hr>
+<div class="content">
+<nav>
+<ul>{items#
+<li><a href="{item.url}" title="{item.module}">{item.name}</a></li>}
+</ul>
+</nav>
+</div>
+<hr>
+<footer>
+<br>
+<div class="powered-by">Prosody {prosody_version?}</div>
+</footer>
+</body>
+</html>
--- a/mod_http_index/mod_http_index.lua	Fri Sep 04 00:12:13 2015 +0200
+++ b/mod_http_index/mod_http_index.lua	Fri Sep 04 00:23:46 2015 +0200
@@ -3,55 +3,13 @@
 
 module:depends"http";
 
--- TODO Move templates into files
-local base_template = [[
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<meta name="generator" value="prosody/{prosody_version} mod_{mod_name}">
-<link rel="canonical" href="{canonical}">
-<title>{title}</title>
-<style>
-body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;}
-header,footer{margin:1ex 1em;}
-footer{font-size:smaller;color:#babdb6;}
-.content{background-color:white;padding:1em;list-style-position:inside;}
-nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;}
-nav a{padding: 1ex;text-decoration:none;}
-@media screen and (min-width: 460px) {
-nav{font-size:x-large;margin:1ex 1em;}
-}
-a:link,a:visited{color:#2e3436;text-decoration:none;}
-a:link:hover,a:visited:hover{color:#3465a4;}
-ul{padding:0;}
-li{list-style:none;}
-hr{visibility:hidden;clear:both;}
-br{clear:both;}
-li:hover time{opacity:1;}
-</style>
-</head>
-<body>
-<header>
-<h1>{title}</h1>
-</header>
-<hr>
-<div class="content">
-<nav>
-<ul>{items#
-<li><a href="{item.url}" title="{item.module}">{item.name}</a></li>}
-</ul>
-</nav>
-</div>
-<hr>
-<footer>
-<br>
-<div class="powered-by">Prosody {prosody_version?}</div>
-</footer>
-</body>
-</html>
-]];
+local base_template;
+do
+	local template_file = module:get_option_string(module.name .. "_template", module.name .. ".html");
+	template_file = assert(module:load_resource(template_file));
+	base_template = template_file:read("*a");
+	template_file:close();
+end
 
 local canonical = module:http_url(nil, "/");