docs/index.html.in | 13 ------------ docs/js/main.js | 49 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 14 deletions(-)
This is just a small script I wrote. It works the same way as all the libraries
together which we are bundling, but with just JS. The only difference is that
the day of the date is formatted as 2-digit, but this should be a bug in
Firefox (at least locally for me) as the documentation states that type
'numeric' should actually not have leading zeros.
It will not be executed when the page is loaded locally.
It also uses the same proxy that query-rss uses. We can get rid of that, but
we'd either need to have our own proxy, send a sss header to allow fetching the
atom.xml or providing JSONP access to the RSS feed on virt-planet.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
docs/index.html.in | 13 ------------
docs/js/main.js | 49 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/docs/index.html.in b/docs/index.html.in
index f593445d061d..fa75289cad0f 100644
--- a/docs/index.html.in
+++ b/docs/index.html.in
@@ -5,19 +5,6 @@
<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">
- <!--
- jQuery(function($) {
- $("#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>
</head>
<body class="index">
<h1>The virtualization API</h1>
diff --git a/docs/js/main.js b/docs/js/main.js
index e57b9f47ac11..668bf752b73d 100644
--- a/docs/js/main.js
+++ b/docs/js/main.js
@@ -28,7 +28,54 @@ function pageload() {
advancedSearch.className = "advancedsearch"
simpleSearch = document.getElementById("simplesearch")
- simplesearch.addEventListener("submit", advancedsearch)
+ simpleSearch.addEventListener("submit", advancedsearch)
+
+ docLoc = document.location;
+ if (docLoc.protocol != "file:" ||
+ docLoc.origin != "null" ||
+ docLoc.host !== "" ||
+ docLoc.hostname !== "") {
+ fetchRSS()
+ }
+}
+
+function fetchRSS() {
+ cb = "jsonpRSSFeedCallback"
+ window["jsonpRSSFeedCallback"] = function (data) {
+ if (data.responseStatus != 200)
+ return
+ entries = data.responseData.feed.entries
+ nEntries = Math.min(entries.length, 4)
+
+ dl = document.createElement('dl')
+
+ dateOpts = { day: 'numeric', month: 'short', year: 'numeric'}
+
+ for (i = 0; i < nEntries; i++) {
+ entry = entries[i]
+ a = document.createElement('a')
+ a.href = entry.link
+ a.innerText = entry.title
+
+ dt = document.createElement('dt')
+ dt.appendChild(a)
+ dl.appendChild(dt)
+
+ date = new Date(entry.publishedDate)
+ datestr = date.toLocaleDateString('default', dateOpts)
+
+ dd = document.createElement('dd')
+ dd.innerText = ` by ${entry.author} on ${datestr}`
+
+ dl.appendChild(dd)
+ }
+
+ planet.appendChild(dl);
+ };
+ script = document.createElement("script")
+ script.src = "https://feedrapp.herokuapp.com/"
+ script.src += `?q=http%3A%2F%2Fplanet.virt-tools.org%2Fatom.xml&callback=${cb}`
+ document.body.appendChild(script);
}
function advancedsearch(e) {
--
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Wed, 2019-06-19 at 16:11 +0200, Martin Kletzander wrote: [...] > simpleSearch = document.getElementById("simplesearch") > - simplesearch.addEventListener("submit", advancedsearch) > + simpleSearch.addEventListener("submit", advancedsearch) If I'm not mistaken, this is an unrelated bugfix. If that's the case, then it should be its own patch. [...] > + script = document.createElement("script") > + script.src = "https://feedrapp.herokuapp.com/" > + script.src += `?q=http%3A%2F%2Fplanet.virt-tools.org%2Fatom.xml&callback=${cb}` Any way we can have the RSS URL as a plain string that we urlencode and combine with the feedrapp URL at runtime? That'd be a bit more readable I reckon. Other than these two nits, and with the caveat that I have close to zero JavaScript knowledge so I might have overlooked even serious issues with your implementation :), I *overwhelmingly* love this. Let's see whether anyone spots any blockers, but otherwise I'd say polish it up, post it as non-RFC, collect my ACK and get it merged as soon as humanly possible! -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.