Replica, primary development repository is https://github.com/jjg/preposter.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 lines
2.0 KiB

<!DOCTYPE html>
<html>
<head>
<title>{0}'s Preposter.us Blog</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width; initial-scale=1.0;">
<link rel="stylesheet" href="css/reset.css" media="all" />
<link rel="stylesheet" href="css/single-col.css" media="all" />
</head>
<body>
<section>
<header>
<h1><span>{0}'s</span> Preposter.us Blog</h1>
<h2><span>Posts</span></h2>
</header>
<article class="cols">
<ul id="postlist"></ul>
</article>
<br>
<div class="footer">
hosted by <a style="color: red; text-decoration: none" href="https://preposter.us">preposter.us</a>
</div>
</section>
<script>
var serverProtocol = location.protocol;
var serverHost = location.hostname;
var serverPort = location.port;
//var serverURL = serverProtocol + '//' + serverHost + ':' + serverPort;
//var postListURL = serverURL + '/{1}/posts.json';
var postListURL = 'posts.json';
var postListReq = new XMLHttpRequest();
postListReq.onload = renderList;
postListReq.open('GET', postListURL, true);
postListReq.send();
function renderList(){
var posts = JSON.parse(this.responseText).posts;
posts.sort(function(a,b) { return Date.parse(b.post.date) - Date.parse(a.post.date) } )
var postListHTML = '';
for(var i=0;i<posts.length;i++){
var postDate = new Date(posts[i].post.date);
var dateString = (postDate.getMonth() + 1) + '/' + postDate.getDate() + '/' + postDate.getFullYear();
postListHTML = postListHTML + '<li>' + dateString + '&nbsp;<a href="' + posts[i].post.slug + '.html">' + posts[i].post.title + '</a></li>\n';
}
var postList = document.getElementById('postlist');
postList.innerHTML = postListHTML;
}
</script>
</body>
</html>