mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-30 22:11:59 -09:00
docs/website: fixing js for the new feed source
Feed source is moved to a local atom file available on the web server to remove further problems with unreliable feed sources. Moving the feed required a bit of refactor of the load_activity function so it won't download two times te same url. This change requires a cron job like this enabled on the website: * * * * * wget -O new.atom https://lore.kernel.org/buildroot/new.atom Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
ee7cf14b51
commit
ca97c78ee0
@@ -1,39 +1,50 @@
|
|||||||
function load_activity(feedurl, divid) {
|
function display_activity(result, activity) {
|
||||||
let container = document.getElementById(divid);
|
let loaded = 0;
|
||||||
|
let nb_display = 8;
|
||||||
|
let container;
|
||||||
|
if (result==null) return;
|
||||||
|
for (let i = 0; i < result.feed.entry.length; i++) {
|
||||||
|
let entry = result.feed.entry[i];
|
||||||
|
if (activity==="commit" && entry.title.toString().indexOf("git commit") !== -1) {
|
||||||
|
container = document.getElementById("commit-activity");
|
||||||
|
} else if (activity==="mailing-list" && entry.title.toString().indexOf("git commit") === -1) {
|
||||||
|
container = document.getElementById("mailing-list-activity");
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
loaded += 1
|
||||||
|
if (loaded > nb_display)
|
||||||
|
break;
|
||||||
|
let div = document.createElement("p");
|
||||||
|
let link = document.createElement("a");
|
||||||
|
let d = new Date(entry.updated);
|
||||||
|
let data = '[' + d.toLocaleDateString() + '] ' + entry.title;
|
||||||
|
let text = document.createTextNode(data);
|
||||||
|
link.appendChild(text);
|
||||||
|
link.title = entry.title;
|
||||||
|
link.href = entry.link._href;
|
||||||
|
div.appendChild(link);
|
||||||
|
container.appendChild(div);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < (nb_display - loaded); i++) {
|
||||||
|
container.appendChild(document.createElement("p"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_activity(feedurl) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "https://cors-anywhere.herokuapp.com/" + feedurl
|
url: feedurl
|
||||||
})
|
})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
let x2js = new X2JS();
|
let x2js = new X2JS();
|
||||||
let result = x2js.xml_str2json(data.documentElement.outerHTML);
|
let result = x2js.xml_str2json(data.documentElement.outerHTML);
|
||||||
let loaded = 0;
|
display_activity(result, "commit");
|
||||||
let nb_display = 8;
|
display_activity(result, "mailing-list");
|
||||||
if (result==null) return;
|
|
||||||
for (let i = 0; i < result.feed.entry.length; i++) {
|
|
||||||
let entry = result.feed.entry[i];
|
|
||||||
if (entry.title.indexOf("git commit") !== -1)
|
|
||||||
continue;
|
|
||||||
loaded += 1;
|
|
||||||
if (loaded > nb_display)
|
|
||||||
break;
|
|
||||||
let div = document.createElement("p");
|
|
||||||
let link = document.createElement("a");
|
|
||||||
let d = new Date(entry.published);
|
|
||||||
let data = '[' + d.toLocaleDateString() + '] ' + entry.title;
|
|
||||||
let text = document.createTextNode(data);
|
|
||||||
link.appendChild(text);
|
|
||||||
link.title = entry.title;
|
|
||||||
link.href = entry.link._href;
|
|
||||||
div.appendChild(link);
|
|
||||||
container.appendChild(div);
|
|
||||||
}
|
|
||||||
let empty = nb_display - loaded;
|
|
||||||
for (let i = 0; i < empty; i++) {
|
|
||||||
container.appendChild(document.createElement("p"));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function google_analytics() {
|
function google_analytics() {
|
||||||
let _gaq = _gaq || [];
|
let _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', 'UA-21761074-1']);
|
_gaq.push(['_setAccount', 'UA-21761074-1']);
|
||||||
@@ -86,8 +97,7 @@ jQuery(document).ready(function($) {
|
|||||||
url = url.split(/[\\/]/).pop();
|
url = url.split(/[\\/]/).pop();
|
||||||
$('.nav a[href="/' + url + '"]').parent().addClass('active');
|
$('.nav a[href="/' + url + '"]').parent().addClass('active');
|
||||||
|
|
||||||
load_activity("http://buildroot-busybox.2317881.n4.nabble.com/Buildroot-busybox-ft2.xml", "mailing-list-activity");
|
load_activity("/new.atom");
|
||||||
load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
|
|
||||||
|
|
||||||
$('#slides').html('<iframe src="https://docs.google.com/gview?url=http://bootlin.com/doc/training/buildroot/buildroot-slides.pdf&embedded=true" style="position:absolute; width:100%; height:100%; top:0; left:0;" frameborder="0"></iframe>')
|
$('#slides').html('<iframe src="https://docs.google.com/gview?url=http://bootlin.com/doc/training/buildroot/buildroot-slides.pdf&embedded=true" style="position:absolute; width:100%; height:100%; top:0; left:0;" frameborder="0"></iframe>')
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user