Skip to content

Commit 551e6fc

Browse files
committed
fixes and a test
1 parent f145937 commit 551e6fc

16 files changed

+2408
-11748
lines changed

api.js

+2,017-11,564
Large diffs are not rendered by default.

api.min.js

+65-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

article.html

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<link rel="stylesheet" href="http://node-os.com/css/default.css"/>
88

99
<script type="application/javascript" src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
10-
<script type="text/javascript" src="/api.min.js"></script>
1110
<style>
1211
.more {display:none}
1312
#articles img{max-width:100%}
@@ -62,7 +61,7 @@ <h3 class="title">{{name}}</h3>
6261
<footer>
6362
Don't worry, it probably was not your fault... probably...<br/>
6463
Even if it was,
65-
<a target="_blank" href="https://github.com/formula1/NodeOS-Blog/issues">just submit an issue :)</a>
64+
<a target="_blank" href="https://github.com/NodeOS/GitBlog/issues">just submit an issue :)</a>
6665
</footer>
6766
</div>
6867
</article>
@@ -73,7 +72,7 @@ <h1>We store data on your computer</h1>
7372
<div>
7473
<p>
7574
If you login: We store your access token we retrieve from github on your computer as a cookie.
76-
<a href="https://github.com/formula1/AuthProvider/blob/master/index.js#L87">See the Code</a>
75+
<a class="btn btn-primary" href="https://github.com/formula1/AuthProvider/blob/master/index.js#L87">See the Code</a>
7776
</p>
7877
<p class="more">
7978
This is done so that we can access the github api in a verified manner.<br/>
@@ -82,7 +81,7 @@ <h1>We store data on your computer</h1>
8281
</p>
8382
<p>
8483
By Using the Blog: We store data we get from github on your available local storage.
85-
<a href="https://github.com/formula1/NodeOS-Blog/blob/master/html/footerjs/cacheOrLoad.js#L38">See the Code</a>
84+
<a class="btn btn-primary" href="https://github.com/NodeOS/GitBlog/blob/master/js/cacheOrLoad.js">See the Code</a>
8685
</p>
8786
<p class="more" >
8887
This is done so that you may avoid as many calls to github as possible.<br/>
@@ -177,13 +176,7 @@ <h3 class="footer-title">Share</h3>
177176

178177
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
179178
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
180-
181-
<!-- START: BIND DATA TO VIEW -->
182-
<script type="text/javascript" src="/js/cacheOrLoad.js"></script>
183-
<script type="text/javascript" src="/js/template.js"></script>
184-
<script type="text/javascript" src="/js/utility.js"></script>
185-
<script type="text/javascript" src="/js/error.js"></script>
186-
<script type="text/javascript" src="/js/user.js"></script>
179+
<script type="text/javascript" src="api.js"></script>
187180

188181
<script type="text/javascript">
189182
var num = (function(){
@@ -205,6 +198,10 @@ <h3 class="footer-title">Share</h3>
205198

206199
jQuery(function($){
207200
if(!num) return;
201+
var Template = require("template");
202+
var cacheOrUriIterator = require("cache-or-load");
203+
204+
208205
singleHandler = new Template(
209206
"script.template.blogsingle",
210207
"div.container.blogsingle"
@@ -260,6 +257,9 @@ <h3 class="footer-title">Share</h3>
260257

261258
jQuery(function($){
262259
if(!num) return;
260+
var Template = require("template");
261+
var cacheOrUriIterator = require("cache-or-load");
262+
263263
commentHandler = new Template(
264264
"script.template.comments",
265265
"div.container.comments"

build.js

+49-63
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var path = require("path");
44
var async = require("async");
55
var browserify = require("browserify");
66
var ejs = require('ejs');
7-
var UglifyJS = require("uglify-js");
87

98

109
var ob = module.exports = {};
@@ -59,59 +58,52 @@ ob.compileHTML = function compileHTML(inputdir, templatepath, outputdir, next)
5958

6059
ob.compileJS = function compileJS(inputrequire, outputdir,next)
6160
{
62-
var b = browserify();
63-
var l = inputrequire.length;
64-
65-
while(l--)
66-
{
67-
var item = inputrequire[l];
68-
69-
if(typeof item === "string")
61+
var createBundle = function(inputrequire)
62+
{
63+
var b = browserify();
64+
var l = inputrequire.length;
65+
inputrequire = inputrequire.map(function(item)
7066
{
71-
b.require(item);
72-
continue;
73-
}
74-
75-
if(!item.path)
76-
return next("when specifying something to require, "+
77-
"\n\t you must provide a valid string or"+
78-
"\n\t you must provide an object with {path:\"valid path or name\"}");
79-
80-
b.require(item.path, item.options);
81-
inputrequire[l] = item.path;
82-
}
83-
84-
b.bundle(function(e,buff)
85-
{
86-
if(e) return next(e);
87-
88-
async.parallel(
89-
[
90-
function(next)
67+
if(typeof item === "string")
9168
{
92-
fs.writeFile(outputdir+"/api.js", buff,
93-
function(e)
94-
{
95-
if(e) return next(e);
96-
next(void(0), {input:inputrequire,output:outputdir+"/api.js"});
97-
});
98-
},
99-
function(next)
69+
b.add(path.normalize(item));
70+
return item;
71+
}
72+
if(!item.path)
10073
{
101-
var min = UglifyJS.parse(buff.toString("utf-8"));
102-
103-
min.figure_out_scope();
104-
fs.writeFile(outputdir+"/api.min.js", min.print_to_string(),
105-
function(e)
106-
{
107-
if(e) return next(e);
108-
109-
next(void(0), {input:inputrequire,output:outputdir+"/api.min.js"});
110-
});
74+
throw new Error(
75+
"when specifying something to require, "+
76+
"\n\t you must provide a valid string or"+
77+
"\n\t you must provide an object with {path:\"valid path or name\"}"
78+
);
11179
}
112-
],
113-
next);
114-
});
80+
b.require(path.normalize(item.path), item.options);
81+
return item.path;
82+
});
83+
return b;
84+
};
85+
async.parallel(
86+
[
87+
function(next)
88+
{
89+
createBundle(inputrequire).bundle()
90+
.pipe(fs.createWriteStream(outputdir+"/api.js"))
91+
.on("end",function(){
92+
next(void(0), {input:inputrequire,output:outputdir+"/api.js"});
93+
}).on("error",next)
94+
},
95+
function(next)
96+
{
97+
createBundle(inputrequire).transform({global: true}, 'uglifyify')
98+
.bundle()
99+
.pipe(fs.createWriteStream(outputdir+"/api.min.js"))
100+
.on("end",function()
101+
{
102+
next(void(0), {input:inputrequire,output:outputdir+"/api.min.js"});
103+
}).on("error",next);
104+
}
105+
],
106+
next);
115107
};
116108

117109
ob.compileAll = function compileAll(inputs, templatepath, outputdir, next)
@@ -121,7 +113,7 @@ ob.compileAll = function compileAll(inputs, templatepath, outputdir, next)
121113
async.parallel(
122114
[
123115
ob.compileHTML.bind(void(0),inputs.dir, templatepath, outputdir),
124-
ob.compileJS.bind(void(0),inputs.require, outputdir)
116+
ob.compileJS.bind(void(0),inputs.add, outputdir)
125117
],
126118
function(e,results)
127119
{
@@ -143,19 +135,13 @@ if(!module.parent)
143135
{
144136
var inputs =
145137
{
146-
require:
138+
add:
147139
[
148-
"auth-provider",
149-
{
150-
path: __dirname+"/node_modules/highlight.js/lib/index.js",
151-
options:
152-
{
153-
expose: "highlight"
154-
}
155-
},
156-
"querystring",
157-
"async",
158-
// "markdown"
140+
{path:__dirname+"/js/template.js", options:{expose:"template"}},
141+
{path:__dirname+"/js/cacheOrLoad.js", options:{expose:"cache-or-load"}},
142+
__dirname+"/js/utility.js",
143+
__dirname+"/js/error.js",
144+
__dirname+"/js/user.js"
159145
],
160146
dir: __dirname+"/input"
161147
};

index.html

+6-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<link rel="stylesheet" href="http://node-os.com/css/default.css"/>
88

99
<script type="application/javascript" src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
10-
<script type="text/javascript" src="/api.min.js"></script>
1110
<style>
1211
.more {display:none}
1312
#articles img{max-width:100%}
@@ -62,7 +61,7 @@ <h3 class="title">{{name}}</h3>
6261
<footer>
6362
Don't worry, it probably was not your fault... probably...<br/>
6463
Even if it was,
65-
<a target="_blank" href="https://github.com/formula1/NodeOS-Blog/issues">just submit an issue :)</a>
64+
<a target="_blank" href="https://github.com/NodeOS/GitBlog/issues">just submit an issue :)</a>
6665
</footer>
6766
</div>
6867
</article>
@@ -73,7 +72,7 @@ <h1>We store data on your computer</h1>
7372
<div>
7473
<p>
7574
If you login: We store your access token we retrieve from github on your computer as a cookie.
76-
<a href="https://github.com/formula1/AuthProvider/blob/master/index.js#L87">See the Code</a>
75+
<a class="btn btn-primary" href="https://github.com/formula1/AuthProvider/blob/master/index.js#L87">See the Code</a>
7776
</p>
7877
<p class="more">
7978
This is done so that we can access the github api in a verified manner.<br/>
@@ -82,7 +81,7 @@ <h1>We store data on your computer</h1>
8281
</p>
8382
<p>
8483
By Using the Blog: We store data we get from github on your available local storage.
85-
<a href="https://github.com/formula1/NodeOS-Blog/blob/master/html/footerjs/cacheOrLoad.js#L38">See the Code</a>
84+
<a class="btn btn-primary" href="https://github.com/NodeOS/GitBlog/blob/master/js/cacheOrLoad.js">See the Code</a>
8685
</p>
8786
<p class="more" >
8887
This is done so that you may avoid as many calls to github as possible.<br/>
@@ -164,19 +163,15 @@ <h3 class="footer-title">Share</h3>
164163

165164
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
166165
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
167-
168-
<!-- START: BIND DATA TO VIEW -->
169-
<script type="text/javascript" src="/js/cacheOrLoad.js"></script>
170-
<script type="text/javascript" src="/js/template.js"></script>
171-
<script type="text/javascript" src="/js/utility.js"></script>
172-
<script type="text/javascript" src="/js/error.js"></script>
173-
<script type="text/javascript" src="/js/user.js"></script>
166+
<script type="text/javascript" src="api.js"></script>
174167

175168
<script type="text/javascript">
176169

177170
var listHandler;
178171

179172
jQuery(function($){
173+
var Template = require("template");
174+
var cacheOrUriIterator = require("cache-or-load");
180175
listHandler = new Template(
181176
"script.template.bloglist",
182177
"div.container.bloglist"

js/bloglist.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
var listHandler;
33

44
jQuery(function($){
5+
var Template = require("template");
6+
var cacheOrUriIterator = require("cache-or-load");
57
listHandler = new Template(
68
"script.template.bloglist",
79
"div.container.bloglist"

js/blogsingle.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ var singleHandler;
1717

1818
jQuery(function($){
1919
if(!num) return;
20+
var Template = require("template");
21+
var cacheOrUriIterator = require("cache-or-load");
22+
23+
2024
singleHandler = new Template(
2125
"script.template.blogsingle",
2226
"div.container.blogsingle"

0 commit comments

Comments
 (0)