Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added templating, its all working now

  • Loading branch information...
commit efa4e699c373d24ab84800a6d88b85dd9a4fcd96 1 parent c99260e
@robrighter authored
View
2  commons.js
@@ -13,7 +13,7 @@
};
exports.writeToResponse = function(res, contenttype, str){
- sys.puts("About to write a response of:\n" + str);
+ //sys.puts("About to write a response of:\n" + str);
res.sendHeader(200,{"Content-Type": contenttype});
res.write(str);
res.end();
View
15 dispatcher.js
@@ -10,12 +10,9 @@ var LoadBalancer = new require('./loadbalancer').LoadBalancer;
var purl = require('url');
var commons = require('./commons');
var _ = require('./lib/underscore')._;
+var PORT = 8001;
+var DOMAIN = 'localhost:8001';
-_.templateSettings = {
- start : '{{',
- end : '}}',
- interpolate : /\{\{(.+?)\}\}/g
-};
var validhash = '.[0-9A-Za-z_\-]*';
var loadbalancer = new LoadBalancer([
@@ -65,9 +62,9 @@ server.get("/createfeed", function (req, res, match) {
addFeedToClient(loadbalancer.getNextWorkerServer(), uuid.getUuid(), function(feedinfo){
fs.readFile('./frank/prod-buildout/createfeed.html', function (err, filecontents) {
if (err) throw err;
- //var template = _.template(filecontents);
- feedinfo['domain'] = 'localhost:8001';
- commons.writeToResponse(res, "text/html", filecontents);//template(feedinfo));
+ feedinfo['domain'] = DOMAIN;
+ var template = _.template(filecontents.toString('utf8'));
+ commons.writeToResponse(res, "text/html", template(feedinfo));
});
});
@@ -105,4 +102,4 @@ server.get('/', noderouter.staticHandler('./frank/prod-buildout/index.html'));
// INITIALIZATION //////////////////////////////////////////////////////////////////////////////////
bootstrap();
-server.listen(8001);
+server.listen(PORT);
View
6 frank/dynamic/createfeed.haml
@@ -1,18 +1,18 @@
#posturl
%h1= 'Adding items to your Real-Time Machine'
%h2= 'Post to url:'
- %div{:class=>'copyable'}= 'http://{{domain}}/insert/{{feedid}}'
+ %div{:class=>'copyable'}= 'http://<%= domain %>/insert/<%= feedid %>'
%p= 'Each time you post to this url it will create a new item in the real time feed. You can post items to this url with up to 5 properties. Each property can be 500 characters long.'
%p= 'In addition to the properties of your object, each POST must include an insertkey variable. The insert key for this feed is:'
%h2= 'Insert Key:'
- %div{:class=>'copyable'}= '{{insertkey}}'
+ %div{:class=>'copyable'}= '<%= insertkey %>'
%h1= 'Adding this Real-Time Machine to a web page'
%h2= 'Client Side Javascript:'
<div class='copyable'>
- &lt;script type="text/javascript"&gt;document.write(unescape("%3Cscript src='http://{{domain}}/client/{{feedid}}.js' type='text/javascript'%3E%3C/script%3E"));&lt;/script&gt;
+ &lt;script type="text/javascript"&gt;document.write(unescape("%3Cscript src='http://<%= domain %>/client/<%= feedid %>.js' type='text/javascript'%3E%3C/script%3E"));&lt;/script&gt;
&lt;script type="text/javascript"&gt; try {<br />
var thertm = new realtimemachine(function(item){<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong>//Put your code here to insert your item into the DOM</strong><br />
View
6 frank/prod-buildout/createfeed.html
@@ -1,15 +1,15 @@
<div id='posturl'>
<h1>Adding items to your Real-Time Machine</h1>
<h2>Post to url:</h2>
- <div class='copyable'>http://{{domain}}/insert/{{feedhash}}</div>
+ <div class='copyable'>http://<%= domain %>/insert/<%= feedid %></div>
<p>Each time you post to this url it will create a new item in the real time feed. You can post items to this url with up to 5 properties. Each property can be 500 characters long.</p>
<p>In addition to the properties of your object, each POST must include an insertkey variable. The insert key for this feed is:</p>
<h2>Insert Key:</h2>
- <div class='copyable'>{{insertkey}}</div>
+ <div class='copyable'><%= insertkey %></div>
<h1>Adding this Real-Time Machine to a web page</h1>
<h2>Client Side Javascript:</h2>
<div class='copyable'>
- &lt;script type="text/javascript"&gt;document.write(unescape("%3Cscript src='http://{{domain}}/client/{{feedhash}}.js' type='text/javascript'%3E%3C/script%3E"));&lt;/script&gt;
+ &lt;script type="text/javascript"&gt;document.write(unescape("%3Cscript src='http://<%= domain %>/client/<%= feedid %>.js' type='text/javascript'%3E%3C/script%3E"));&lt;/script&gt;
&lt;script type="text/javascript"&gt; try {<br />
var thertm = new realtimemachine(function(item){<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong>//Put your code here to insert your item into the DOM</strong><br />
Please sign in to comment.
Something went wrong with that request. Please try again.