Skip to content

Commit 4f2f4d6

Browse files
committed
stablish
1 parent 277c59e commit 4f2f4d6

File tree

7 files changed

+108
-74
lines changed

7 files changed

+108
-74
lines changed

dist/api.min.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/article.html

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
66
<link rel="stylesheet" href="http://node-os.com/css/default.css" />
77
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
8-
<script type="text/javascript" src="https://gist.githubusercontent.com/formula1/749db638e5b5ac630caf/raw/2e07d087e9991213d40183f270d15f6d54244d39/api.min.js" ></script>
8+
<script type="text/javascript" src="/api.min.js" ></script>
99
<style>
1010
#articles img{max-width:100%}
1111
#articles article .title img{width:100px}
@@ -141,7 +141,8 @@ <h3 class="footer-title">Share</h3>
141141
name:"You've hit max data"
142142
};
143143
if(is_authed === 1){
144-
topush.message = "Apparently, people have been using our app too much...";
144+
topush.message = "Apparently, people have been using our app too much..."+
145+
"<button onclick='login()'>Log in</button>";
145146
}else{
146147
topush.message = "If you'd like to continue, please "+
147148
"<button onclick='login()'>Log in</button>";
@@ -183,7 +184,7 @@ <h3 class="footer-title">Share</h3>
183184
errors.push({name:"Bad markdown call: "+response.status, message: data.message});
184185
}
185186
item.bodyHTML = "<pre>"+item.body+"</pre>";
186-
}).finally(function(){
187+
}).always(function(){
187188
next(item);
188189
});
189190
});
@@ -248,24 +249,26 @@ <h3 class="footer-title">Share</h3>
248249

249250
var auth = new CookieStore("auth");
250251
var is_authed = -1;
251-
var auth_queueu = [];
252+
var auth_queue = [];
252253
var url = require("url");
254+
var querystring = require("querystring");
253255
var docuri = url.parse(window.location.href);
256+
docuri.query = querystring.parse(docuri.query);
257+
var config = {
258+
cid: "dafb27cb88db35267e75",
259+
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
260+
};
254261
if(docuri.query && docuri.query.code){
255-
if(url.query.state != auth.get("state")){
262+
if(docuri.query.state != auth.get("state")){
256263
errors.push(new Error("Improper State"));
257264
}else{
258265
getAccess(docuri.query.code);
259266
}
260267
}else if(auth.get("access_token")){
268+
console.log(auth.get("access_token"));
261269
is_authed = 1;
262270
}
263271

264-
var config = {
265-
cid: "dafb27cb88db35267e75",
266-
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
267-
};
268-
269272
function login(){
270273
var state = Date.now()+"_"+Math.random();
271274
auth.set("state", state);
@@ -277,16 +280,24 @@ <h3 class="footer-title">Share</h3>
277280
is_authed = 0;
278281
auth.delete("state");
279282
jQuery.get(compileYQL([
280-
"env \""+config.yqlur+"\"",
283+
"env \""+config.yqluri+"\"",
281284
"select * from github where CODE=\""+code+"\""
282285
])).done(function(results){
286+
console.log("auth success");
287+
console.log(arguments);
283288
auth.set("access_token",results.query.results.OAuth.access_token);
284289
is_authed = 1;
285290
jQuery(".four-zero-three .content").text("You've authenticated!");
286-
}).error(function(e){
291+
}).fail(function(e){
292+
console.error(arguments);
287293
is_authed = -1;
288-
errors.push(e);
289-
}).finally(function(){
294+
errors.push({
295+
class:"four-zero-three",
296+
name:"You've failed authorization",
297+
message: "You can always try again"
298+
});
299+
}).always(function(){
300+
console.log("always");
290301
while(auth_queue.length){
291302
uriAsAuthority.apply(void(0),auth_queue.pop());
292303
}
@@ -306,13 +317,13 @@ <h3 class="footer-title">Share</h3>
306317
}
307318

308319
function uriAsAuthority(uri,next){
309-
switch(is_authed){
310-
case -1: return next(uri);
311-
case 0: return auth_queueu.push([uri,next]);
312-
case 1: uri = url.parse(uri);
313-
uri.query.access_token = auth.get("access_token");
314-
return next(url.format(uri));
315-
}
320+
if(is_authed === -1) return next(uri);
321+
if(is_authed === 0) return auth_queue.push([uri,next]);
322+
uri = url.parse(uri);
323+
uri.query = querystring.parse(uri.query);
324+
uri.query.access_token = auth.get("access_token");
325+
uri.search = "?"+querystring.stringify(uri.query);
326+
next(url.format(uri));
316327
}
317328

318329
function logout(){

dist/index.html

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
66
<link rel="stylesheet" href="http://node-os.com/css/default.css" />
77
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
8-
<script type="text/javascript" src="https://gist.githubusercontent.com/formula1/749db638e5b5ac630caf/raw/2e07d087e9991213d40183f270d15f6d54244d39/api.min.js" ></script>
8+
<script type="text/javascript" src="/api.min.js" ></script>
99
<style>
1010
#articles img{max-width:100%}
1111
#articles article .title img{width:100px}
@@ -130,7 +130,8 @@ <h3 class="footer-title">Share</h3>
130130
name:"You've hit max data"
131131
};
132132
if(is_authed === 1){
133-
topush.message = "Apparently, people have been using our app too much...";
133+
topush.message = "Apparently, people have been using our app too much..."+
134+
"<button onclick='login()'>Log in</button>";
134135
}else{
135136
topush.message = "If you'd like to continue, please "+
136137
"<button onclick='login()'>Log in</button>";
@@ -172,7 +173,7 @@ <h3 class="footer-title">Share</h3>
172173
errors.push({name:"Bad markdown call: "+response.status, message: data.message});
173174
}
174175
item.bodyHTML = "<pre>"+item.body+"</pre>";
175-
}).finally(function(){
176+
}).always(function(){
176177
next(item);
177178
});
178179
});
@@ -237,24 +238,26 @@ <h3 class="footer-title">Share</h3>
237238

238239
var auth = new CookieStore("auth");
239240
var is_authed = -1;
240-
var auth_queueu = [];
241+
var auth_queue = [];
241242
var url = require("url");
243+
var querystring = require("querystring");
242244
var docuri = url.parse(window.location.href);
245+
docuri.query = querystring.parse(docuri.query);
246+
var config = {
247+
cid: "dafb27cb88db35267e75",
248+
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
249+
};
243250
if(docuri.query && docuri.query.code){
244-
if(url.query.state != auth.get("state")){
251+
if(docuri.query.state != auth.get("state")){
245252
errors.push(new Error("Improper State"));
246253
}else{
247254
getAccess(docuri.query.code);
248255
}
249256
}else if(auth.get("access_token")){
257+
console.log(auth.get("access_token"));
250258
is_authed = 1;
251259
}
252260

253-
var config = {
254-
cid: "dafb27cb88db35267e75",
255-
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
256-
};
257-
258261
function login(){
259262
var state = Date.now()+"_"+Math.random();
260263
auth.set("state", state);
@@ -266,16 +269,24 @@ <h3 class="footer-title">Share</h3>
266269
is_authed = 0;
267270
auth.delete("state");
268271
jQuery.get(compileYQL([
269-
"env \""+config.yqlur+"\"",
272+
"env \""+config.yqluri+"\"",
270273
"select * from github where CODE=\""+code+"\""
271274
])).done(function(results){
275+
console.log("auth success");
276+
console.log(arguments);
272277
auth.set("access_token",results.query.results.OAuth.access_token);
273278
is_authed = 1;
274279
jQuery(".four-zero-three .content").text("You've authenticated!");
275-
}).error(function(e){
280+
}).fail(function(e){
281+
console.error(arguments);
276282
is_authed = -1;
277-
errors.push(e);
278-
}).finally(function(){
283+
errors.push({
284+
class:"four-zero-three",
285+
name:"You've failed authorization",
286+
message: "You can always try again"
287+
});
288+
}).always(function(){
289+
console.log("always");
279290
while(auth_queue.length){
280291
uriAsAuthority.apply(void(0),auth_queue.pop());
281292
}
@@ -295,13 +306,13 @@ <h3 class="footer-title">Share</h3>
295306
}
296307

297308
function uriAsAuthority(uri,next){
298-
switch(is_authed){
299-
case -1: return next(uri);
300-
case 0: return auth_queueu.push([uri,next]);
301-
case 1: uri = url.parse(uri);
302-
uri.query.access_token = auth.get("access_token");
303-
return next(url.format(uri));
304-
}
309+
if(is_authed === -1) return next(uri);
310+
if(is_authed === 0) return auth_queue.push([uri,next]);
311+
uri = url.parse(uri);
312+
uri.query = querystring.parse(uri.query);
313+
uri.query.access_token = auth.get("access_token");
314+
uri.search = "?"+querystring.stringify(uri.query);
315+
next(url.format(uri));
305316
}
306317

307318
function logout(){

html/footerjs/error.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ function add403(){
66
name:"You've hit max data"
77
};
88
if(is_authed === 1){
9-
topush.message = "Apparently, people have been using our app too much...";
9+
topush.message = "Apparently, people have been using our app too much..."+
10+
"<button onclick='login()'>Log in</button>";
1011
}else{
1112
topush.message = "If you'd like to continue, please "+
1213
"<button onclick='login()'>Log in</button>";
@@ -48,7 +49,7 @@ function parseMarkdown(item,next){
4849
errors.push({name:"Bad markdown call: "+response.status, message: data.message});
4950
}
5051
item.bodyHTML = "<pre>"+item.body+"</pre>";
51-
}).finally(function(){
52+
}).always(function(){
5253
next(item);
5354
});
5455
});

html/footerjs/user.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,26 @@ CookieStore.prototype.save = function(){
3939

4040
var auth = new CookieStore("auth");
4141
var is_authed = -1;
42-
var auth_queueu = [];
42+
var auth_queue = [];
4343
var url = require("url");
44+
var querystring = require("querystring");
4445
var docuri = url.parse(window.location.href);
46+
docuri.query = querystring.parse(docuri.query);
47+
var config = {
48+
cid: "dafb27cb88db35267e75",
49+
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
50+
};
4551
if(docuri.query && docuri.query.code){
46-
if(url.query.state != auth.get("state")){
52+
if(docuri.query.state != auth.get("state")){
4753
errors.push(new Error("Improper State"));
4854
}else{
4955
getAccess(docuri.query.code);
5056
}
5157
}else if(auth.get("access_token")){
58+
console.log(auth.get("access_token"));
5259
is_authed = 1;
5360
}
5461

55-
var config = {
56-
cid: "dafb27cb88db35267e75",
57-
yqluri: "store://gdDAnJkTXAuVgzAQ8wboA2"
58-
};
59-
6062
function login(){
6163
var state = Date.now()+"_"+Math.random();
6264
auth.set("state", state);
@@ -68,16 +70,24 @@ function getAccess(code){
6870
is_authed = 0;
6971
auth.delete("state");
7072
jQuery.get(compileYQL([
71-
"env \""+config.yqlur+"\"",
73+
"env \""+config.yqluri+"\"",
7274
"select * from github where CODE=\""+code+"\""
7375
])).done(function(results){
76+
console.log("auth success");
77+
console.log(arguments);
7478
auth.set("access_token",results.query.results.OAuth.access_token);
7579
is_authed = 1;
7680
jQuery(".four-zero-three .content").text("You've authenticated!");
77-
}).error(function(e){
81+
}).fail(function(e){
82+
console.error(arguments);
7883
is_authed = -1;
79-
errors.push(e);
80-
}).finally(function(){
84+
errors.push({
85+
class:"four-zero-three",
86+
name:"You've failed authorization",
87+
message: "You can always try again"
88+
});
89+
}).always(function(){
90+
console.log("always");
8191
while(auth_queue.length){
8292
uriAsAuthority.apply(void(0),auth_queue.pop());
8393
}
@@ -97,13 +107,13 @@ function compileYQL(query){
97107
}
98108

99109
function uriAsAuthority(uri,next){
100-
switch(is_authed){
101-
case -1: return next(uri);
102-
case 0: return auth_queueu.push([uri,next]);
103-
case 1: uri = url.parse(uri);
104-
uri.query.access_token = auth.get("access_token");
105-
return next(url.format(uri));
106-
}
110+
if(is_authed === -1) return next(uri);
111+
if(is_authed === 0) return auth_queue.push([uri,next]);
112+
uri = url.parse(uri);
113+
uri.query = querystring.parse(uri.query);
114+
uri.query.access_token = auth.get("access_token");
115+
uri.search = "?"+querystring.stringify(uri.query);
116+
next(url.format(uri));
107117
}
108118

109119
function logout(){

html/parts/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
2-
<script type="text/javascript" src="https://gist.githubusercontent.com/formula1/749db638e5b5ac630caf/raw/2e07d087e9991213d40183f270d15f6d54244d39/api.min.js" ></script>
2+
<script type="text/javascript" src="/api.min.js" ></script>
33
<style>
44
#articles img{max-width:100%}
55
#articles article .title img{width:100px}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var fs = require("fs");
55
var b = browserify();
66
b.require("markdown");
77
b.require(__dirname+"/node_modules/highlight.js/lib/index.js", {expose:"highlight"});
8+
b.require("querystring");
89
b.require("url");
910
b.bundle(function(e,buff){
1011
if(e) throw e;

0 commit comments

Comments
 (0)