Commit 8a50a0dc by Aral Balkan

Add generated JS folder to repo

  - Defies convention but necessary for Heroku-ish deployments
  - Revert npm script to prepublish so not triggered on deployment
  - Update readme with note on all this
parent 834a9e03
.DS_Store
node_modules
npm-debug.log
/js
npm-debug.log
\ No newline at end of file
(function() {
var fs, jsdom, render, set;
jsdom = require('jsdom');
fs = require('fs');
set = (fs.readFileSync(__dirname + '/set.js', 'utf8')).toString();
exports.__express = function(path, data, callback) {
return fs.readFile(path, 'utf8', function(error, template) {
var html;
if (error) {
return callback(error);
}
html = render(template, data);
return callback(null, html);
});
};
render = function(template, data) {
var customFormatter, customFormatters, doctype, doctypeHTML, doctypeName, doctypePublicAndSystemID, doctypePublicID, doctypeSystemID, document, e, error1, head, html, ref, ref1, ref2, script, window;
document = jsdom.jsdom(template);
window = document.defaultView;
window.console = console;
if (!data.__set) {
data.__set = {};
}
data.__set['server'] = true;
window["eval"](set);
customFormatters = data.__set['formatters'];
if (customFormatters) {
for (customFormatter in customFormatters) {
window.set.format[customFormatter] = customFormatters[customFormatter];
}
}
window.set.attributeWillChange = data.__set['attributeWillChange'];
window.set.textWillChange = data.__set['textWillChange'];
if (data.__set['injectData']) {
head = window.document.getElementsByTagName('head')[0];
script = window.document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.textContent = 'set.data = ' + JSON.stringify(data, null, 2) + ';';
head.appendChild(script);
}
if (data.__set['renderStatic']) {
window.set.renderStatic = true;
}
window.data = data;
try {
window["eval"]('set(window.document.documentElement, window.data);');
} catch (error1) {
e = error1;
throw e;
}
html = window.document.documentElement.outerHTML;
doctype = window.document.doctype;
if (doctype !== null) {
doctypeName = doctype.name;
doctypePublicID = (ref = doctype.publicId) != null ? ref : ' PUBLIC "' + doctype.publicId + {
'"': ''
};
doctypePublicAndSystemID = (ref1 = !doctype.publicId && doctype.systemId) != null ? ref1 : {
' SYSTEM': ''
};
doctypeSystemID = (ref2 = doctype.systemId) != null ? ref2 : ' "' + doctype.systemId + {
'"': ''
};
doctypeHTML = "<!DOCTYPE " + doctypeName + doctypePublicID + doctypePublicAndSystemID + doctypeSystemID + ">";
html = "" + doctypeHTML + html;
}
return html;
};
exports.render = render;
}).call(this);
This diff is collapsed. Click to expand it.
(function() {
var elapsedTime, reset, start, timers;
timers = {};
start = process.hrtime();
reset = function() {
return start = process.hrtime();
};
elapsedTime = function(note) {
var average, elapsed, max, min, numTries, precision, sum, times;
precision = 3;
elapsed = process.hrtime(start)[1] / 1000000;
if (!(timers[note] && Array.isArray(timers[note]))) {
timers[note] = [];
}
times = timers[note];
times.push(elapsed);
sum = times.reduce(function(previousValue, currentValue) {
return previousValue + currentValue;
});
sum = sum.toFixed(precision);
numTries = times.length;
average = (sum / numTries).toFixed(precision);
min = (Math.min.apply(Math, times)).toFixed(precision);
max = (Math.max.apply(Math, times)).toFixed(precision);
console.log("\n" + note + ":\n Elapsed: " + elapsed + " ms.\n Average: " + average + " ms over " + numTries + " tries (min: " + min + " ms, max: " + max + " ms).");
return start = process.hrtime();
};
exports.reset = reset;
exports.elapsedTime = elapsedTime;
}).call(this);
(function() {
exports.route = function(request, response) {
var meta, version;
meta = require('../../package.json');
version = meta.version;
return response.render('main', {
version: version
});
};
}).call(this);
(function() {
var superagent;
superagent = require('superagent');
exports.route = function(request, response) {
return superagent.get('https://mastodon.social/api/v1/timelines/public').end(function(error, globalTimelineResponse) {
var globalTimeline;
globalTimeline = globalTimelineResponse.body;
if (error) {
globalTimeline.errorType = 'Network';
globalTimeline.error = error;
} else if (!globalTimeline) {
globalTimeline.errorType = 'Mastodon';
globalTimeline.error = "Could not get the public timeline.";
}
return response.render('posts-client-side-updates', {
data: globalTimeline,
__set: {
injectData: true
}
});
});
};
}).call(this);
(function() {
var superagent;
superagent = require('superagent');
exports.route = function(request, response) {
return superagent.get('https://mastodon.ar.al/api/v1/timelines/public').end(function(error, globalTimelineResponse) {
var globalTimeline;
globalTimeline = globalTimelineResponse.body;
globalTimeline.__set = {
renderStatic: true
};
if (error) {
globalTimeline.errorType = 'Network';
globalTimeline.error = error;
} else if (!globalTimeline) {
globalTimeline.errorType = 'Mastodon';
globalTimeline.error = "Could not get the public timeline.";
}
return response.render('posts', {
data: globalTimeline
});
});
};
}).call(this);
(function() {
var superagent, timer;
superagent = require('superagent');
timer = require('../lib/timer');
exports.route = function(request, response) {
timer.reset();
return superagent.get('https://mastodon.ar.al/api/v1/timelines/public').end(function(error, globalTimelineResponse) {
var globalTimeline;
timer.elapsedTime('Data transfer from mastodon.ar.al');
globalTimeline = globalTimelineResponse.body;
if (error) {
globalTimeline.errorType = 'Network';
globalTimeline.error = error;
} else if (!globalTimeline.data) {
globalTimeline.errorType = 'Mastodon';
globalTimeline.error = "Could not get the public timeline.";
}
timer.reset();
response.render('posts', {
data: globalTimeline
});
return timer.elapsedTime('Template render');
});
};
}).call(this);
(function() {
var fs, marked;
marked = require('marked');
fs = require('fs');
exports.route = function(request, response) {
return fs.readFile(__dirname + '/../../readme.md', 'utf-8', function(error, markdown) {
var data, readme;
data = {};
if (error) {
response.status(404);
data.title = 'Could not find the readme.md file.';
data.error = true;
} else {
readme = marked(markdown);
data.title = 'Read me!';
data.readme = readme;
}
return response.render('readme', data);
});
};
}).call(this);
(function() {
var fs;
fs = require('fs');
exports.route = function(request, response) {
return fs.readFile(__dirname + '/../lib/set.js', 'utf-8', function(error, data) {
if (error) {
response.status(404);
return response.send('<h1>Error 404: Could not find set.js</h1>');
} else {
response.status(200);
return response.end(data);
}
});
};
}).call(this);
(function() {
var data;
data = {
title: 'Set sample',
name: 'Set',
"class": 'rendered-summary',
content: 'This is a simple example to demonstrate Set, a templating engine for Express (node.js) and client‐side JavaScript.',
newURL: 'http://aralbalkan.com',
correctURLFragment: 'ind',
aralImageURL: 'http://aralbalkan.com/images/aral.jpg',
friends: [
{
name: 'Laura',
skills: 'design, development, illustration, speaking'
}, {
name: 'Jo',
skills: 'operations, cognitive psychology, sports coaching'
}, {
name: 'Osky',
skills: 'begging for food, looking cute, occasionally howling'
}
],
templateClass: 'tab',
renderedClass: 'tab selected'
};
exports.route = function(request, response) {
data.__set = {
formatters: {
fullURL: function(value) {
return 'https://' + value + '.ie';
},
isSelected: function(value) {
return 'tab selected';
}
}
};
return response.render('simple', data);
};
}).call(this);
(function() {
var app, createRoute, express, set, superagent;
express = require('express');
set = require('./lib/set-express');
superagent = require('superagent');
createRoute = function(routeName) {
var path, route;
path = routeName === '/' ? 'main' : routeName.slice(1);
route = require('./routes/' + path).route;
return app.get(routeName, route);
};
app = express();
app.engine('html', (require('./lib/set-express')).__express);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(express["static"](__dirname + '/views'));
createRoute('/');
createRoute('/simple');
createRoute('/posts');
createRoute('/posts-client-side-updates');
createRoute('/profile');
createRoute('/readme');
createRoute('/set.js');
app.listen(process.env.PORT || 3000);
console.log('\nServer running… visit http://localhost:3000/ to play with the Set examples.\n');
}).call(this);
html
{
padding: 0 24px;
}
body
{
font-size: 14px;
margin:60px auto;
margin-top:12px;
line-height: 24px;
font-family:'Avenir Next','Helvetica Neue',Helvetica,Arial,sans-serif;
height: 100%;
text-align: justify;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
color: #252525;
}
nav h1
{
color: black;
font-size: 16px;
line-height: 16px;
margin: 6px;
}
.set-header h1 {
margin-top: 24px;
}
h1,h2
{
font-weight:500;
margin-bottom: 24px;
margin-top: 24px;
}
h2
{
margin-bottom: 12px;
}
ul
{
margin-bottom: 24px;
}
li
{
margin: 12px 0;
}
a
{
text-decoration: none;
/*color: #7f8c8d;*/
color: #135BA4;
}
footer
{
margin-top:36px;
border-top:1px solid #000;
font-size:small;
line-height: 18px;
}
abbr
{
border-bottom: 1px dotted gray;
}
#set-logo
{
width:100%;
max-width: 320px;
/*position: fixed;*/
margin: 0 auto;
display:block;
}
#short-description
{
text-align: center;
color: #252525;
font-size:18px;
margin-bottom: 24px;
}
.tabs
{
list-style-type: none;
border-bottom: 10px solid #b3b3b3;
text-align:right;
padding-top: 0px;
padding-bottom: 0;
overflow: hidden;
display:block;
margin: 24px 0 12px 0;
}
.tabs a {
text-decoration: none;
}
.tabs li
{
margin-right: 6px;
margin-bottom: 0;
padding: 0 10px;
-webkit-border-radius: 6px 6px 0 0;
border-radius: 6px 6px 0 0;
background-color: rgba(0, 0, 0, 0.1);
float:left;
color: #404040;
}
li.selected
{
background-color: #b3b3b3;
color: #333;
}
.invisible
{
display:none;
}
@media all and (max-width: 400px)
{
.tabs
{
font-size: 14px;
padding-bottom: 0;
}
.tabs li
{
padding: 0 6px;
margin-right: 2px;
}
}
body
{
/* little bit of margin to compensate for the fixed controls at the bottom of the screen */
margin-bottom: 100px;
}
#tests
{
font-size:14px;
-moz-column-gap: 48px;
-webkit-column-gap: 48px;
column-gap: 48px;
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
button
{
font-size: 14px;
}
section
{
margin: 48px 0;
/*background-color: #eee;*/
-webkit-column-break-inside:avoid;
-moz-column-break-inside:avoid;
-o-column-break-inside:avoid;
-ms-column-break-inside:avoid;
column-break-inside:avoid;
}
section:first-child
{
margin-top: 0;
}
/* Tables */
tr, table, td, th { border: none; margin: 0; padding: 0; border-spacing: 0;}
table { width: 100%; border: 1px solid gray; }
th { background-color: lightgray; text-align: left; border-bottom: 1px solid gray; padding-left: 12px;}
tr:nth-child(2n+1), option:nth-child(2n+1) { background-color: #eee;}
td { border-left: 1px solid gray;}
td:first-child {border-left:0;}
td
{
padding:0 12px;
width:30%;
vertical-align:top
}
ul li { margin: 0 12px; }
header { margin-bottom: 48px; }
h3
{
background-color: #eee;
text-align:center;
font-size: 16px;
line-height: 24px;
padding: 5px;
margin: 12px 0;
}
h3:first-child { margin-top: 0;}
select
{
width: 100%;
}
.bluish
{
background: rgba(56,146,227,0.41);
}
/* Reduce number of columns on narrower browser widths */
@media all and (max-width: 900px)
{
#tests
{
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
}
@media all and (max-width: 580px)
{
#tests
{
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
html { padding: 0 12px; }
h1 { margin-bottom: 24px; }
section { margin: 24px 0; }
}
a.absent {
color: #cc0000;
}
a.anchor {
display: block;
padding-left: 30px;
margin-left: -30px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0;
}
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
text-decoration: none;
}
h1 tt, h1 code {
font-size: inherit;
}
h2 tt, h2 code {
font-size: inherit;
}
h3 tt, h3 code {
font-size: inherit;
}
h4 tt, h4 code {
font-size: inherit;
}
h5 tt, h5 code {
font-size: inherit;
}
h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: black;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #cccccc;
color: black;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777777;
font-size: 14px;
}
p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0;
}
hr {
background: transparent url("http://tinyurl.com/bq5kskr") repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
padding: 0;
}
body > h2:first-child {
margin-top: 0;
padding-top: 0;
}
body > h1:first-child {
margin-top: 0;
padding-top: 0;
}
body > h1:first-child + h2 {
margin-top: 0;
padding-top: 0;
}
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
margin-top: 0;
}
li p.first {
display: inline-block;
}
ul, ol {
padding-left: 30px;
}
ul :first-child, ol :first-child {
margin-top: 0;
}
ul :last-child, ol :last-child {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt > :first-child {
margin-top: 0;
}
dl dt > :last-child {
margin-bottom: 0;