Skip to content

Instantly share code, notes, and snippets.

@scripting
Created April 11, 2015 18:42
Show Gist options
  • Save scripting/634d38915b00b30edf50 to your computer and use it in GitHub Desktop.
Save scripting/634d38915b00b30edf50 to your computer and use it in GitHub Desktop.
This is a demo of an idea for a home page for MyWord Editor.
<html>
<head>
<title>Dave's MyWord Blog Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="alternate" type="application/rss+xml" href="http://myword.io/users/davewiner/rss.xml" />
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">
<script src="http://fargo.io/code/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://fargo.io/code/fontAwesome/css/font-awesome.min.css"/>
<script src="http://fargo.io/code/node/shared/utils.js"></script>
<script src="http://fargo.io/code/strftime.js"></script>
<script src="http://fargo.io/code/shared/xml.js"></script>
<script src="http://fargo.io/code/shared/reader.js"></script>
<link rel="stylesheet" href="http://fargo.io/code/shared/reader.css"/>
<script>
var urlRss = "http://myword.io/users/davewiner/rss.xml";
function readPostsFromRss (url, idBlogPosts, callback) {
var htmltext = "", indentlevel = 0, whenstart = new Date ();
var thisPageUrl = stringNthField (window.location.href, "?", 1);
function getSub (item, name) {
var url;
$(item).children (name).each (function () {
url = $(this).text ();
});
return (url);
}
function add (s) {
htmltext += s + "\r\n";
}
$("#" + idBlogPosts).empty ();
readHttpFile (url, function (xmltext) {
var xstruct = $($.parseXML (xmltext));
var adrchannel = xmlGetAddress (xstruct, "channel");
$(adrchannel).children ("item").each (function () {
var pubDate = getSub (this, "pubDate"), urlPermalink = getSub (this, "guid"), title = getSub (this, "title"), description = getSub (this, "description");
var linkJson = getSub (this, "source\\:linkJson"), link = getSub (this, "link");
if (link != undefined) {
var theScript = "viewListItem ('" + linkJson + "')";
var theLink = "<div class=\"divItemTitle\"><a href=\"" + link + "\">" + title + "</a></div>";
var dateString = formatDate (pubDate, "%d-%b-%Y").toUpperCase ();
var theDate = "<div class=\"divPubDate\"><a href=\"" + link + "\">" + dateString + "</a></div>";
add ("<div class=\"divItem\">"); indentlevel++;
add ("<div class=\"divItemHeader\">" + theDate + theLink + "</div>");
if (description != undefined) {
add ("<div class=\"divItemDescription\">" + description + "</div>");
}
add ("</div>"); indentlevel--;
}
});
$("#" + idBlogPosts).append (htmltext);
if (callback != undefined) {
callback ();
}
});
}
function startup () {
console.log ("startup");
readPostsFromRss (urlRss, "idBlogPosts", function () {
});
}
</script>
<style>
body {
font-family: "Ubuntu";
font-size: 18px;
background-color: whitesmoke;
}
.divPageBody {
width: 750px;
margin-top: 100px;
margin-left: auto;
margin-right: auto;
margin-bottom: 400px;
}
.divBlogPosts ul {
list-style: none;
}
.divItemHeader a {
color: black;
font-weight: bold;
}
.divItemTitle {
font-size: 1.1em;
}
.divPubDate {
float: right;
font-size: .7em;
}
.divPubDate a {
color: gray;
}
.divItemDescription {
font-family: "Georgia";
}
.divItem {
padding-bottom: 30px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="divPageBody">
<div class="divBlogPosts" id="idBlogPosts">
</div>
</div>
<script>
startup ();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment