Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 03619d1

Browse files
committed
cleaning up
1 parent f1ac77f commit 03619d1

File tree

4 files changed

+144
-116
lines changed

4 files changed

+144
-116
lines changed

‎html/footerjs/cacheOrLoad.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function UriIterator(cachename, timestamp, itemCBs){
3939
}catch(e){
4040
return itemCBs.error(e);
4141
}
42+
delete in_memory[cachename];
4243
if(data.length === 0){
4344
itemCBs.done(timestamp);
4445
}else{

‎html/footerjs/template.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
function Template(template,contain,unique){
3+
this.template = Handlebars.compile(jQuery(template).html());
4+
this.contain = jQuery(contain);
5+
this.unique = {};
6+
if(Array.isArray(unique)){
7+
var l = unique.length;
8+
while(l--){
9+
this.unique[unique[l]] = false;
10+
}
11+
}
12+
this.contain.find(".remove").on("click",this.remove.bind(this));
13+
}
14+
15+
Template.prototype.add = function(item){
16+
if(item.class && typeof this.unique[item.class] != "undefined"){
17+
if(this.unique[item.class]) return;
18+
this.unique[item.class] = true;
19+
}
20+
console.log("appending");
21+
this.contain.append(this.template(item));
22+
};
23+
24+
Template.prototype.remove = function(e){
25+
e.preventDefault();
26+
var art = $(this).closest("article");
27+
var u = art.attr("data-unique");
28+
if(u){
29+
this.unique[u] = false;
30+
}
31+
art.remove();
32+
};

‎html/footerjs/utility.js‎

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,6 @@ jQuery(function($){
66
});
77
});
88

9-
function Template(template,contain,unique){
10-
this.template = Handlebars.compile(jQuery(template).html());
11-
this.contain = jQuery(contain);
12-
this.unique = {};
13-
if(Array.isArray(unique)){
14-
var l = unique.length;
15-
while(l--){
16-
this.unique[unique[l]] = false;
17-
}
18-
}
19-
this.contain.find(".remove").on("click",this.remove.bind(this));
20-
}
21-
22-
Template.prototype.add = function(item){
23-
if(item.class && typeof this.unique[item.class] != "undefined"){
24-
if(this.unique[item.class]) return;
25-
this.unique[item.class] = true;
26-
}
27-
console.log("appending");
28-
this.contain.append(this.template(item));
29-
};
30-
31-
Template.prototype.remove = function(e){
32-
e.preventDefault();
33-
var art = $(this).closest("article");
34-
var u = art.attr("data-unique");
35-
if(u){
36-
this.unique[u] = false;
37-
}
38-
art.remove();
39-
};
40-
419

4210
function compileYQL(query){
4311
if(Array.isArray(query)){
@@ -95,30 +63,3 @@ function parseMarkdown(item,next){
9563
});
9664
});
9765
}
98-
99-
100-
/*
101-
var markdown = require("markdown").markdown;
102-
function parseMarkdown(item,next){
103-
console.log("parsing");
104-
105-
try{
106-
var t = jQuery("<div>"+markdown.toHTML(item.body)+"</div>");
107-
t.find("code").wrap("<pre></pre>");
108-
109-
item.bodyHTML = t.html();
110-
console.log(item.bodyHTML);
111-
}catch(e){
112-
console.log(e);
113-
item.bodyHTML = "<pre>"+item.body+"</pre>";
114-
}
115-
setTimeout(next.bind(next,item),1);
116-
}
117-
/* */
118-
119-
120-
function ISOplus1(iso){
121-
var d = new Date(iso);
122-
d.setSeconds(d.getSeconds() + 1);
123-
return d.toISOString();
124-
}

‎index.js‎

Lines changed: 111 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,119 @@
11
var browserify = require("browserify");
22
var UglifyJS = require("uglify-js");
33
var fs = require("fs");
4-
5-
var b = browserify();
6-
b.require("./AuthProvider", {expose:"AuthProvider"});
7-
//b.require("markdown");
8-
b.require(__dirname+"/node_modules/highlight.js/lib/index.js", {expose:"highlight"});
9-
b.require("querystring");
10-
//b.require("url");
11-
b.require("async");
12-
b.bundle(function(e,buff){
13-
if(e) throw e;
14-
var min = UglifyJS.parse(buff.toString("utf-8"));
15-
min.figure_out_scope();
16-
fs.writeFile(
17-
__dirname+"/dist/api.min.js",
18-
min.print_to_string(),
19-
function(e){
20-
if(e) throw e;
21-
console.log("wrote the js");
22-
}
23-
);
24-
});
25-
4+
var async = require("async");
265
var ejs = require('ejs');
276

7+
module.exports.compileHTML = function compileHTML(inputdir, templatepath, outputdir, next){
8+
fs.readdir(pagepath,function(e,files){
9+
if(e) return next(e);
10+
async.each(files,function(file,next){
11+
var input = inputdir+"/"+file;
12+
fs.stat(input,function(e,s){
13+
if(e) return next(e);
14+
if(s.isDirectory()){
15+
return next("things to be compiled are not expecting a directory");
16+
}
17+
var filename = file.split(".")[0];
18+
var output = outputdir+"/"+filename+".html";
19+
ejs.renderFile(
20+
input,
21+
{
22+
cur_page:{},
23+
templatepath:templatepath
24+
},
25+
function(e,file){
26+
if(e) return next(e);
27+
fs.writeFile(
28+
output,
29+
file,
30+
function(e){
31+
if(e) return next(e);
32+
next(void(0), {
33+
input:input,
34+
output:output
35+
});
36+
}
37+
);
38+
}
39+
);
40+
})
41+
},next);
42+
});
43+
};
2844

29-
30-
ejs.renderFile(
31-
__dirname+"/html/blog.ejs",
32-
{
33-
cur_page:{},
34-
htmlpath:__dirname+"/html"
35-
},
36-
function(e,file){
37-
if(e) throw e;
38-
fs.writeFile(
39-
__dirname+"/dist/index.html",
40-
file,
41-
function(e){
42-
if(e) throw e;
43-
console.log("wrote index.html");
44-
}
45-
);
45+
module.exports.compileJS = function compileJS(inputrequire, outputdir,next){
46+
var b = browserify();
47+
var l = inputrequire.length;
48+
while(l--){
49+
var item = inputrequire[l];
50+
if(typeof item === "string"){
51+
return b.require(item);
52+
}
53+
if(!item.name){
54+
return next("when specifying something to require, "+
55+
"\n\t you must provide a valid string or"+
56+
"\n\t you must provide an object with {path:\"valid path or name\"}");
57+
}
58+
b.require(item.path, item.options);
4659
}
47-
);
48-
ejs.renderFile(
49-
__dirname+"/html/article.ejs",
50-
{
51-
cur_page:{},
52-
htmlpath:__dirname+"/html"
53-
},
54-
function(e,file){
55-
if(e) throw e;
56-
fs.writeFile(
57-
__dirname+"/dist/article.html",
58-
file,
59-
function(e){
60-
if(e) throw e;
61-
console.log("wrote article.html");
60+
b.require("./AuthProvider", {expose:"AuthProvider"});
61+
//b.require("markdown");
62+
b.require(__dirname+"/node_modules/highlight.js/lib/index.js", {expose:"highlight"});
63+
b.require("querystring");
64+
b.require("async");
65+
b.bundle(function(e,buff){
66+
if(e) return next(e);
67+
async.parrallel([
68+
function(){
69+
fs.writeFile(
70+
outputdir+"/api.js",
71+
buff,
72+
function(e){
73+
if(e) return next(e);
74+
next(void(0), {input:inputrequire,output:outputdir+"/api.js"});
75+
}
76+
);
77+
},function(next){
78+
var min = UglifyJS.parse(buff.toString("utf-8"));
79+
min.figure_out_scope();
80+
fs.writeFile(
81+
outputdir+"/api.min.js",
82+
min.print_to_string(),
83+
function(e){
84+
if(e) return next(e);
85+
next(void(0), {input:inputrequire,output:outputdir+"/api.min.js"});
86+
}
87+
);
6288
}
63-
);
64-
}
65-
);
89+
],next);
90+
});
91+
};
92+
93+
module.exports.compile = function(inputs, templatepath, outputdir, next){
94+
async.parrallel([
95+
compileHTML.bind(void(0),inputs.dir, templatepath, outputdir),
96+
compileJS.bind(void(0),inputs.require, outputdir)
97+
],function(e,results){
98+
if(e) return next(e);
99+
var net = [];
100+
var l = results.length;
101+
while(l--){
102+
net = net.concat(results[l]);
103+
}
104+
next(void(0),net);
105+
});
106+
};
107+
108+
if(!module.parent){
109+
var inputs = {
110+
require:[
111+
{path:"./AuthProvider", options:{expose:"AuthProvider"}},
112+
{path:__dirname+"/node_modules/highlight.js/lib/index.js", options:{expose:"highlight"}},
113+
"querystring",
114+
"async",
115+
// "markdown"
116+
],
117+
dir:__dirname+"/html"
118+
};
119+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /