mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
docs: Use our own implementation for fetching the RSS data
It will not be executed when the page is loaded locally. It needs planet.virt-tools.org to supply the right headers (which it does now). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
d922e82b5b
commit
a153056090
@ -2,20 +2,9 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="js/jquery-3.1.1.min.js"> </script>
|
|
||||||
<script type="text/javascript" src="js/moment.min.js"> </script>
|
|
||||||
<script type="text/javascript" src="js/jquery.rss.min.js"> </script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<!--
|
<!--
|
||||||
jQuery(function($) {
|
window.addEventListener("load", function() { fetchRSS() });
|
||||||
$("#planet").rss("http://planet.virt-tools.org/atom.xml", {
|
|
||||||
ssl: true,
|
|
||||||
layoutTemplate: '<dl>{entries}</dl>',
|
|
||||||
entryTemplate: '<dt><a href="{url}">{title}</a></dt><dd>by {author} on {date}</li>',
|
|
||||||
dateFormat: 'DD MMM YYYY'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -77,3 +77,65 @@ function advancedsearch(e) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchRSS() {
|
||||||
|
if (document.location.protocol == "file:")
|
||||||
|
return;
|
||||||
|
|
||||||
|
var planet = document.getElementById("planet");
|
||||||
|
if (planet === null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open("GET", "https://planet.virt-tools.org/atom.xml");
|
||||||
|
req.setRequestHeader("Accept", "application/atom+xml, text/xml");
|
||||||
|
req.onerror = function(e) {
|
||||||
|
if (this.statusText != "")
|
||||||
|
console.error(this);
|
||||||
|
};
|
||||||
|
req.onload = function(e) {
|
||||||
|
if (this.readyState !== 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.status != 200) {
|
||||||
|
console.error(this.statusText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.responseXML === null) {
|
||||||
|
console.error("Atom response is not an XML");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dl = document.createElement("dl");
|
||||||
|
var dateOpts = { day: "numeric", month: "short", year: "numeric"};
|
||||||
|
|
||||||
|
var entries = this.responseXML.querySelectorAll("feed > entry:not(:nth-of-type(1n+5))");
|
||||||
|
|
||||||
|
entries.forEach(function(e) {
|
||||||
|
var name = e.querySelector("author > name").textContent;
|
||||||
|
var title = e.querySelector("title").textContent;
|
||||||
|
var updated = e.querySelector("updated").textContent;
|
||||||
|
var uri = e.querySelector("author > uri").textContent;
|
||||||
|
|
||||||
|
var a = document.createElement("a");
|
||||||
|
a.href = uri;
|
||||||
|
a.innerText = title;
|
||||||
|
|
||||||
|
var dt = document.createElement("dt");
|
||||||
|
dt.appendChild(a);
|
||||||
|
dl.appendChild(dt);
|
||||||
|
|
||||||
|
var date = new Date(updated);
|
||||||
|
date = date.toLocaleDateString("default", dateOpts);
|
||||||
|
|
||||||
|
var dd = document.createElement("dd");
|
||||||
|
dd.innerText = ` by ${name} on ${date}`;
|
||||||
|
|
||||||
|
dl.appendChild(dd);
|
||||||
|
});
|
||||||
|
|
||||||
|
planet.appendChild(dl);
|
||||||
|
};
|
||||||
|
req.send();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user