Skip to content

Commit b80de50

Browse files
committed
Looks a ton nicer and handling errors
0 parents  commit b80de50

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

blog.html

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
5+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
6+
<link rel="stylesheet" href="http://node-os.com/css/default.css" />
7+
<!-- START: ANGULAR DEPENDENCY -->
8+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
9+
<style>
10+
#articles img{max-width:100%}
11+
</style>
12+
<!-- END: ANGULAR DEPENDENCY -->
13+
</head>
14+
<body>
15+
<header class="navbar navbar-default navbar-fixed-top" role="navigation">
16+
<!-- Brand and toggle get grouped for better mobile display -->
17+
<div class="navbar-header">
18+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
19+
<span class="sr-only">Toggle navigation</span>
20+
<span class="icon-bar"></span>
21+
<span class="icon-bar"></span>
22+
<span class="icon-bar"></span>
23+
</button>
24+
<a class="navbar-brand" href="http://node-os.com">node-os</a>
25+
</div>
26+
27+
<!-- Collect the nav links, forms, and other content for toggling -->
28+
<div class="collapse navbar-collapse navbar-ex1-collapse">
29+
<ul class="nav navbar-nav">
30+
<li><a href="http://node-os.com/blog">Blog</a></li>
31+
<li><a href="http://npkg.org">npkg.org</a></li>
32+
</ul>
33+
</div><!-- /.navbar-collapse -->
34+
</header>
35+
<!-- START: ISSUES ITEM TEMPLATE -->
36+
<section ng-app="NodeOsBlog" id="articles" class="section">
37+
<div class="container" ng-controller="ErrorListCtrl" >
38+
<article ng-repeat="error in errors" class="row">
39+
<div class="col-sm-8 col-sm-offset-2">
40+
<header class="alert alert-danger" role="alert">
41+
<h3 class="title">{{error.name}}</h3>
42+
</header>
43+
<div class="content">{{error.message}}</div>
44+
<footer>
45+
Don't worry, it probably was not your fault... probably....
46+
<br/><br/>
47+
Even if it was,
48+
<a href="https://github.com/formula1/NodeOS-Blog/issues" >just submit an issue :)</a>
49+
</footer>
50+
</div>
51+
</article>
52+
</div>
53+
<div class="container" ng-controller="BlogListCtrl" >
54+
<article ng-repeat="item in blog" class="row">
55+
<div class="col-sm-8 col-sm-offset-2">
56+
<header class="{{item.state}}">
57+
<h3 class="title">{{item.title}}</h3>
58+
<a href="https://github.com/{{uriPath}}/{{item.number}}">View on Github</a>
59+
</header>
60+
<div class="content" ng-bind-html="item.bodyHTML | to_trusted"></div>
61+
<footer>
62+
<a href="https://github.com/{{uriPath}}/{{item.number}}" class="comments">
63+
There are {{item.comments}} comments.
64+
</a>
65+
</footer>
66+
</div>
67+
</article>
68+
</div>
69+
</section>
70+
<!-- END: ISSUES ITEM TEMPLATE -->
71+
72+
<div class="section inverse trampstamp">
73+
<div class="row">
74+
<div class="col-xs-12"><img src="http://node-os.com/images/nodeos-update.png"></div>
75+
</div>
76+
</div>
77+
78+
<footer>
79+
<div class="container" id="footer">
80+
<div class="row">
81+
<div class="col-sm-7">
82+
<h3 class="footer-title">Share</h3>
83+
<p>node-os is a work in progress.</p>
84+
<p>If you would like to support us, please share node-os via Twitter</p>
85+
<p class="pvl">
86+
<a href="https://twitter.com/TheNodeOS" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @TheNodeOS</a>
87+
<script type="text/javascript">
88+
(function(d,s,id){
89+
var js;
90+
fjs=d.getElementsByTagName(s)[0];
91+
p= /^http\:/.test(d.location)?'http':'https';
92+
if(!d.getElementById(id)){
93+
js=d.createElement(s);
94+
js.id=id;
95+
js.src=p+'://platform.twitter.com/widgets.js';
96+
fjs.parentNode.insertBefore(js,fjs);
97+
}
98+
})(document, 'script', 'twitter-wjs');
99+
</script>
100+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://node-os.com/blog/OS-flavors" data-text="NodeOS - The NodeJS Powered Operating System" data-via="TheNodeOS" data-size="large">Tweet</a>
101+
</p>
102+
103+
</div>
104+
105+
</div>
106+
</div>
107+
</footer>
108+
109+
<!-- START: BIND DATA TO VIEW -->
110+
<script type="text/javascript">
111+
112+
var NodeOsBlog = angular.module('NodeOsBlog', []);
113+
var errors = [];
114+
NodeOsBlog.filter('to_trusted', ['$sce', function($sce){
115+
return function(text) {
116+
return $sce.trustAsHtml(text);
117+
};
118+
}]);
119+
NodeOsBlog.controller('ErrorListCtrl', function($scope){
120+
$scope.errors = errors;
121+
var oldwinerr = window.onerror;
122+
window.onerror = function ( message, filename, lineno, colno, error ){
123+
if ( error !== undefined && error.hasOwnProperty( "name" ) && error.name == "Magic"){
124+
errors.push({name:"Uncaught Error: "+error.name, message: message+"<pre>"+error.stack+"</pre>"});
125+
}
126+
};
127+
});
128+
NodeOsBlog.controller('BlogListCtrl', function ($scope, $http) {
129+
$scope.uriPath = "/NodeOS/NodeOS/issues";
130+
$scope.blog = [];
131+
$scope.parseMarkdown = function(item,next){
132+
$http.post("https://api.github.com/markdown",{text:item.body})
133+
.success(function(data){
134+
item.bodyHTML = data;
135+
next(item);
136+
}).error(function(data, status, headers, config) {
137+
errors.push({name:"Bad markdown call: "+status, message: data.message});
138+
item.bodyHTML = "<pre>"+item.body+"</pre>";
139+
next(item);
140+
});
141+
};
142+
$scope.last = void(0);
143+
$scope.loadMore = function(page){
144+
if($scope.last && $scope.last < page) return;
145+
var i=0;
146+
var l=-1;
147+
$http.get('https://api.github.com/repos'+$scope.uriPath+'?labels=blog&sort=created&page='+page)
148+
.success(function(data,status,headers) {
149+
console.log(headers);
150+
console.log(headers.link);
151+
if(!$scope.last) $scope.last = headers.link?headers.link:1;
152+
l = data.length;
153+
if(i === l) return; //No more
154+
var iterator = function(item){
155+
$scope.blog.push(item);
156+
i++;
157+
if(i === l) return;
158+
$scope.parseMarkdown(data[i],iterator);
159+
};
160+
$scope.parseMarkdown(data[0],iterator);
161+
}).error(function(data, status, headers, config) {
162+
errors.push({name:"Bad issues list request: "+status, message: data.message});
163+
});
164+
};
165+
$scope.loadMore(1);
166+
});
167+
</script>
168+
<!-- END: BIND DATA TO VIEW -->
169+
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" />
170+
</body>
171+
</html>

0 commit comments

Comments
 (0)