Created
February 18, 2014 00:55
-
-
Save chesster/9062422 to your computer and use it in GitHub Desktop.
RSS on a blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feedLoaded = (result) -> | |
unless result.error | |
container = document.getElementById("rssnews") | |
if container | |
container.innerHTML = "" | |
i = 0 | |
ul = document.createElement("ul") | |
ul.setAttribute "class", "posts" | |
while i < result.feed.entries.length | |
entry = result.feed.entries[i] | |
date = new Date(entry.publishedDate) | |
monthNames = [ | |
"Styczeń" | |
"Luty" | |
"Marzen" | |
"Kwiecień" | |
"Maj" | |
"Czerwiec" | |
"Lipiec" | |
"Sierpień" | |
"Wrzesień" | |
"Październik" | |
"Listopad" | |
"Grudzień" | |
] | |
localeDate = date.getDate() + " " + monthNames[date.getMonth()] + " " + date.getFullYear() + " » " | |
a = document.createElement("a") | |
a.setAttribute "href", entry.link | |
a.setAttribute "title", entry.title | |
title_char_limit = 70 | |
title = if entry.title.length < title_char_limit then entry.title else entry.title.substring(0,title_char_limit).replace /^\s+|\s+$/g, ""+"..." | |
a.appendChild document.createTextNode(title) | |
span = document.createElement("span") | |
span.setAttribute "class", "grey" | |
span.appendChild document.createTextNode(localeDate) | |
li = document.createElement("li") | |
li.appendChild span | |
li.appendChild a | |
ul.appendChild li | |
i++ | |
container.appendChild ul | |
return | |
OnLoad = -> | |
feed = new google.feeds.Feed("http://www.rssmix.com/u/3872014/rss.xml") | |
feed.setNumEntries 10 | |
feed.load feedLoaded | |
return | |
google.load "feeds", "1" | |
google.setOnLoadCallback OnLoad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment