From nobody Mon Sep 16 19:17:43 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17073258855421006.3589484591511; Wed, 7 Feb 2024 09:11:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7D7B71F16; Wed, 7 Feb 2024 12:11:24 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6AF821E54; Wed, 7 Feb 2024 11:54:02 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E0CE11F03; Wed, 7 Feb 2024 11:53:39 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 83A061E2B for ; Wed, 7 Feb 2024 11:52:47 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-5E_DkTNhNOuMKgQ89YRGjQ-1; Wed, 07 Feb 2024 11:52:45 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8471E1022EFB for ; Wed, 7 Feb 2024 16:52:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F21AF2026D09 for ; Wed, 7 Feb 2024 16:52:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 5E_DkTNhNOuMKgQ89YRGjQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 03/11] js: Separate the virt-tools blog planet loader code Date: Wed, 7 Feb 2024 17:52:33 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: IOQBMRO5AUMBRVMIGVH5DQGCMKCE2QL6 X-Message-ID-Hash: IOQBMRO5AUMBRVMIGVH5DQGCMKCE2QL6 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1707325887188100001 In order to promote simple assets sharing between main libvirt web and the libvirt-wiki separate the virt tools blog feed loader from the main code used for search. Signed-off-by: Peter Krempa --- docs/index.rst | 5 +-- docs/js/main.js | 62 ----------------------------- docs/js/meson.build | 1 + docs/js/virt-tools-blog-planet.js | 65 +++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 docs/js/virt-tools-blog-planet.js diff --git a/docs/index.rst b/docs/index.rst index b1666ee22e..79afae65da 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -65,10 +65,7 @@ Blog Planet .. raw:: html -
diff --git a/docs/js/main.js b/docs/js/main.js index 87b817b287..bb94c5ac52 100644 --- a/docs/js/main.js +++ b/docs/js/main.js @@ -89,65 +89,3 @@ function advancedsearch(e) { return false; } - -function fetchRSS() { - if (document.location.protocol =3D=3D "file:") - return; - - var planet =3D document.getElementById("planet"); - if (planet =3D=3D=3D null) - return; - - var req =3D new XMLHttpRequest(); - req.open("GET", "https://planet.virt-tools.org/atom.xml"); - req.setRequestHeader("Accept", "application/atom+xml, text/xml"); - req.onerror =3D function(e) { - if (this.statusText !=3D "") - console.error(this); - }; - req.onload =3D function(e) { - if (this.readyState !=3D=3D 4) - return; - - if (this.status !=3D 200) { - console.error(this.statusText); - return; - } - - if (this.responseXML =3D=3D=3D null) { - console.error("Atom response is not an XML"); - return; - } - - var dl =3D document.createElement("dl"); - var dateOpts =3D { day: "numeric", month: "short", year: "numeric"= }; - - var entries =3D this.responseXML.querySelectorAll("feed > entry:no= t(:nth-of-type(1n+5))"); - - entries.forEach(function(e) { - var name =3D e.querySelector("author > name").textContent; - var title =3D e.querySelector("title").textContent; - var updated =3D e.querySelector("updated").textContent; - var link =3D e.querySelector("link").attributes.href.textConte= nt; - - var a =3D document.createElement("a"); - a.href =3D link; - a.innerText =3D title; - - var dt =3D document.createElement("dt"); - dt.appendChild(a); - dl.appendChild(dt); - - var date =3D new Date(updated); - date =3D date.toLocaleDateString("default", dateOpts); - - var dd =3D document.createElement("dd"); - dd.innerText =3D ` by ${name} on ${date}`; - - dl.appendChild(dd); - }); - - planet.appendChild(dl); - }; - req.send(); -} diff --git a/docs/js/meson.build b/docs/js/meson.build index 9f77b0d85c..e83d1c92b0 100644 --- a/docs/js/meson.build +++ b/docs/js/meson.build @@ -1,5 +1,6 @@ docs_js_files =3D [ 'main.js', + 'virt-tools-blog-planet.js', ] install_data(docs_js_files, install_dir: docs_html_dir / 'js') diff --git a/docs/js/virt-tools-blog-planet.js b/docs/js/virt-tools-blog-pl= anet.js new file mode 100644 index 0000000000..7f4e2bf3b9 --- /dev/null +++ b/docs/js/virt-tools-blog-planet.js @@ -0,0 +1,65 @@ +"use strict"; + +function fetchRSS() { + if (document.location.protocol =3D=3D "file:") + return; + + var planet =3D document.getElementById("planet"); + if (planet =3D=3D=3D null) + return; + + var req =3D new XMLHttpRequest(); + req.open("GET", "https://planet.virt-tools.org/atom.xml"); + req.setRequestHeader("Accept", "application/atom+xml, text/xml"); + req.onerror =3D function(e) { + if (this.statusText !=3D "") + console.error(this); + }; + req.onload =3D function(e) { + if (this.readyState !=3D=3D 4) + return; + + if (this.status !=3D 200) { + console.error(this.statusText); + return; + } + + if (this.responseXML =3D=3D=3D null) { + console.error("Atom response is not an XML"); + return; + } + + var dl =3D document.createElement("dl"); + var dateOpts =3D { day: "numeric", month: "short", year: "numeric"= }; + + var entries =3D this.responseXML.querySelectorAll("feed > entry:no= t(:nth-of-type(1n+5))"); + + entries.forEach(function(e) { + var name =3D e.querySelector("author > name").textContent; + var title =3D e.querySelector("title").textContent; + var updated =3D e.querySelector("updated").textContent; + var link =3D e.querySelector("link").attributes.href.textConte= nt; + + var a =3D document.createElement("a"); + a.href =3D link; + a.innerText =3D title; + + var dt =3D document.createElement("dt"); + dt.appendChild(a); + dl.appendChild(dt); + + var date =3D new Date(updated); + date =3D date.toLocaleDateString("default", dateOpts); + + var dd =3D document.createElement("dd"); + dd.innerText =3D ` by ${name} on ${date}`; + + dl.appendChild(dd); + }); + + planet.appendChild(dl); + }; + req.send(); +} + +window.addEventListener("load", function() { fetchRSS() }); --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org