Mercurial > eldonilo > avatar
changeset 15:6689cc444617
Use an external XHTML file.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 04 Jun 2011 03:42:44 +0200 |
parents | 7fdae201c1e2 |
children | 27eaec05cfd0 |
files | avatar.js index.xhtml |
diffstat | 2 files changed, 34 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/avatar.js +++ b/avatar.js @@ -200,7 +200,7 @@ var showImage = function(jid, res) { } var last = new Date(stats.mtime); - var now = new Date(); + var now = new Date; if (now - last > 24*60*60*1000) getVCard(jid, res); @@ -253,24 +253,12 @@ http.createServer(function (req, res) { if (jid === '') { res.writeHead(200, {'Content-Type': 'application/xhtml+xml'}); - res.write('<?xml version="1.0" encoding="utf-8"?>\n'); - res.write('<!DOCTYPE html>\n'); - res.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n'); - res.write('\t<head>\n'); - res.write('\t\t<title>JavaScript XMPP Avatar Retriever</title>\n'); - res.write('\t</head>\n'); - res.write('\t<body>\n'); - res.write('\t\t<header><h1>JavaScript XMPP Avatar Retriever</h1></header>\n'); - res.write('\t\t<p>Put any JID and get its avatar. :)</p>\n'); - res.write('\t\t<form action="redirect" method="post">\n'); - res.write('\t\t\t<p>\n'); - res.write('\t\t\t\t<input name="jid" type="text" placeholder="you@yourserver.tld"/>\n'); - res.write('\t\t\t\t<input type="submit"/>\n'); - res.write('\t\t\t</p>\n'); - res.write('\t\t</form>\n'); - res.write('\t\t<footer><p>(<a href="README">README</a>, <a href="source/code">source code</a>, <a href="http://hg.linkmauve.fr/avatar">Mercurial repository</a>)</p></footer>\n'); - res.write('\t</body>\n'); - res.end('</html>\n'); + fs.readFile('index.xhtml', function(err, data) { + if (err) + throw err; + + res.end(data); + }); return; } @@ -282,7 +270,6 @@ http.createServer(function (req, res) { } req.on('data', function(content) { - console.log(content); var jid = unescape(content.toString()).replace(/^jid=/, ''); res.writeHead(301, {'Location': jid}); res.end();
new file mode 100644 --- /dev/null +++ b/index.xhtml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>JavaScript XMPP Avatar Retriever</title> + </head> + <body> + <header><h1>JavaScript XMPP Avatar Retriever</h1></header> + + <p>Put any JID and get its avatar. :)</p> + + <form action="redirect" method="post"> + <p> + <input name="jid" type="text" placeholder="you@yourserver.tld"/> + <input type="submit"/> + </p> + </form> + + <nav> + <ul> + <li><a href="README">README</a></li> + <li><a href="source/code">source code</a></li> + <li><a href="http://hg.linkmauve.fr/avatar">Mercurial repository</a></li> + </ul> + </nav> + </body> +</html>