[PATCH 00/11] webpage related fixes

Patch 1 fixes the 'maven' redirect for gitlab pages by adding a /. Note that I didn't test that yet as it's hard to do with the redirects file, so this one will be tested in produciton. The rest of the series optimizes JS, CSS and XSLT assets for reuse in libvirt wiki by separating out stuff that is relevant only for libvirt.org. There will be a corresponding merge request to pull them into the wiki project. The resulting page can be browsed at: https://pipo.sk.gitlab.io/-/libvirt/-/jobs/6119138205/artifacts/website/inde... https://gitlab.com/pipo.sk/libvirt/-/pipelines/1168193309 Peter Krempa (11): gitlab_pages: Fix 'maven' redirect docs: page.xsl: Fix headerlinks with new docutils js: Separate the virt-tools blog planet loader code css: mobile: Split up libvirt.org specific styles from main template style css: Split out page templated styles to 'libvirt-template.css' css: Remove unused CSS for migration support matrix table css: Move styles for the generated API documents to libvirt-api.css css: Move generic styles to 'generic.css' docs: Move 'html including' from page.xsl to site.xsl docs: xsl: Properly propagate 'href_base' as XSL template parameter docs: page.xsl: Split up 'href_base' for assets and links .gitlab_pages_redirects | 2 +- docs/css/generic.css | 59 +++ docs/css/libvirt-api.css | 112 +++++ docs/css/libvirt-template.css | 236 +++++++++++ docs/css/libvirt.css | 417 ------------------- docs/css/main.css | 5 +- docs/css/meson.build | 5 +- docs/css/mobile-libvirt.css | 17 + docs/css/{mobile.css => mobile-template.css} | 15 +- docs/html/meson.build | 2 + docs/index.rst | 5 +- docs/js/main.js | 62 --- docs/js/meson.build | 1 + docs/js/virt-tools-blog-planet.js | 65 +++ docs/newapi.xsl | 3 +- docs/page.xsl | 37 +- docs/site.xsl | 17 +- 17 files changed, 535 insertions(+), 525 deletions(-) create mode 100644 docs/css/libvirt-api.css create mode 100644 docs/css/libvirt-template.css create mode 100644 docs/css/mobile-libvirt.css rename docs/css/{mobile.css => mobile-template.css} (84%) create mode 100644 docs/js/virt-tools-blog-planet.js -- 2.43.0

The redirect to the 'maven' repository of libvirt doesn't work currently for libvirt pages as the ':splat' replacement doesn't match due to a missing '/'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .gitlab_pages_redirects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab_pages_redirects b/.gitlab_pages_redirects index baa94384ba..ab21561911 100644 --- a/.gitlab_pages_redirects +++ b/.gitlab_pages_redirects @@ -7,7 +7,7 @@ # Redirects to the download server /libvirt/sources/* https://download.libvirt.org/:splat 301 /libvirt/ruby/download/* https://download.libvirt.org/ruby/:splat 301 -/libvirt/maven2/org/libvirt* https://download.libvirt.org/maven2/org/libvirt/:splat 301 +/libvirt/maven2/org/libvirt/* https://download.libvirt.org/maven2/org/libvirt/:splat 301 # Redirects to subproject pages /libvirt/ruby/* https://ruby.libvirt.org/:splat 301 -- 2.43.0

New docutils generates a <section> element rather than a <div class='section'> as it did before thus breaking our headerlink generator. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/page.xsl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/page.xsl b/docs/page.xsl index 1021899b3a..04d7cc9432 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -139,6 +139,9 @@ <xsl:if test="./html:a/@id"> <a class="headerlink" href="#{html:a/@id}" title="Link to this headline">¶</a> </xsl:if> + <xsl:if test="parent::html:section"> + <a class="headerlink" href="#{../@id}" title="Link to this headline">¶</a> + </xsl:if> <xsl:if test="parent::html:div[@class='section']"> <a class="headerlink" href="#{../@id}" title="Link to this headline">¶</a> </xsl:if> -- 2.43.0

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 <pkrempa@redhat.com> --- 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 - <script type="text/javascript"> - <!-- - window.addEventListener("load", function() { fetchRSS() }); - // --> + <script type="text/javascript" src="js/virt-tools-blog-planet.js"> </script> <div id="planet"> </div> 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 == "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 link = e.querySelector("link").attributes.href.textContent; - - var a = document.createElement("a"); - a.href = link; - 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(); -} 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 = [ '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-planet.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 == "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 link = e.querySelector("link").attributes.href.textContent; + + var a = document.createElement("a"); + a.href = link; + 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(); +} + +window.addEventListener("load", function() { fetchRSS() }); -- 2.43.0

Separate the libvirt.org specific stuff from the main template style so that the latter can be reused in libvirt-wiki without modification. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/css/main.css | 3 ++- docs/css/meson.build | 3 ++- docs/css/mobile-libvirt.css | 17 +++++++++++++++++ docs/css/{mobile.css => mobile-template.css} | 15 +-------------- 4 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 docs/css/mobile-libvirt.css rename docs/css/{mobile.css => mobile-template.css} (84%) diff --git a/docs/css/main.css b/docs/css/main.css index 88e453aca6..74498dd30e 100644 --- a/docs/css/main.css +++ b/docs/css/main.css @@ -1,4 +1,5 @@ @import url(fonts.css); @import url(generic.css); @import url(libvirt.css); -@import url(mobile.css); +@import url(mobile-template.css); +@import url(mobile-libvirt.css); diff --git a/docs/css/meson.build b/docs/css/meson.build index a2a2ccfb28..51cf0d6b72 100644 --- a/docs/css/meson.build +++ b/docs/css/meson.build @@ -3,7 +3,8 @@ docs_css_files = [ 'generic.css', 'libvirt.css', 'main.css', - 'mobile.css', + 'mobile-template.css', + 'mobile-libvirt.css', ] install_data(docs_css_files, install_dir: docs_html_dir / 'css') diff --git a/docs/css/mobile-libvirt.css b/docs/css/mobile-libvirt.css new file mode 100644 index 0000000000..b9e81b0d93 --- /dev/null +++ b/docs/css/mobile-libvirt.css @@ -0,0 +1,17 @@ +@media (max-width: 1000px) { + #the-virtualization-api > h1, + #the-virtualization-api > h2 { + display: none; + } + + #the-virtualization-api section, + #the-virtualization-api .section, + #documentation section, + #documentation .section, + #knowledge-base section, + #knowledge-base .section { + width: 100%; + margin-left: 0px; + float: none; + } +} diff --git a/docs/css/mobile.css b/docs/css/mobile-template.css similarity index 84% rename from docs/css/mobile.css rename to docs/css/mobile-template.css index 2e223f468e..2f862d58ea 100644 --- a/docs/css/mobile.css +++ b/docs/css/mobile-template.css @@ -1,3 +1,4 @@ +/* Style for the page.xsl template */ @media (max-width: 1000px) { #home { width: 100%; @@ -20,10 +21,6 @@ #search form { padding: 5px; } - #the-virtualization-api > h1, - #the-virtualization-api > h2 { - display: none; - } #jumplinks { padding: 0px; display: block; @@ -88,16 +85,6 @@ #body { margin-top: 180px; } - #the-virtualization-api section, - #the-virtualization-api .section, - #documentation section, - #documentation .section, - #knowledge-base section, - #knowledge-base .section { - width: 100%; - margin-left: 0px; - float: none; - } #advancedsearch { margin-top: 4em; border: 0px; -- 2.43.0

Separate the styles related to the main page template and the build process specifics (docutils-originated) into a separate CSS file. Hint: Best viewed with 'git show --color-moved=blocks' Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/css/libvirt-template.css | 236 +++++++++++++++++++++++++++++++++ docs/css/libvirt.css | 237 ---------------------------------- docs/css/main.css | 1 + docs/css/meson.build | 1 + 4 files changed, 238 insertions(+), 237 deletions(-) create mode 100644 docs/css/libvirt-template.css diff --git a/docs/css/libvirt-template.css b/docs/css/libvirt-template.css new file mode 100644 index 0000000000..2ea93c793f --- /dev/null +++ b/docs/css/libvirt-template.css @@ -0,0 +1,236 @@ +/* styles related to the page template (page.xsl) */ +#nav { + position: absolute; + top: 0px; + left: 0px; + height: 100px; + background: rgb(0, 95, 97); + border-bottom: 3px solid rgb(60, 133, 124); + width: 100%; + display: table; +} + +#home { + background-image: url(../logos/logo-banner-light-256.png); + background-repeat: no-repeat; + background-position: left center; + height: 100px; + width: 269px; + margin-left: 1em; + text-indent: 100%; white-space: nowrap; overflow: hidden; +} + +#home a { + color: rgb(0, 95, 97); + height: 100px; + width: 269px; + display: block; +} + +#jumplinks { + display: table-cell; + vertical-align: middle; + font-size: 16pt; + text-align: right; +} + +#jumplinks ul { + list-style: none; +} + +#jumplinks li { + display: inline; + padding-left: 2em; + font-weight: bold; +} + +#jumplinks a { + color: rgb(255, 255, 255); + text-decoration: none; +} + +#jumplinks a:hover { + color: rgb(255, 230, 0); +} + +#search { + display: table-cell; + vertical-align: middle; + width: 13em; + text-align: right; + padding: 1em; +} + +#search input { + border: 0px; + height: 2em; +} + +#search input[type=text] { + background: rgb(230, 230, 230); + color: rgb(0, 0, 0); + width: 10em; + padding: 0px; + padding-left: 2px; + padding-right: 2px; +} + +#search input[type=submit] { + background: rgb(60, 133, 124); + color: rgb(255, 255, 255); + width: 3em; + font-weight: bold; +} + +#search input[type=submit]:active, +#search input[type=submit]:hover { + color: rgb(255, 230, 0); +} + +#body { + border: 0px; + left: 0px; + margin: 0px; + margin-top: 120px; + margin-left: 1em; + margin-right: 1em; +} + +main, +.document { + margin-left: auto; + margin-right: auto; + padding: 0px; + padding-bottom: 1em; + max-width: 95%; + width: 70em; +} + +h1 a, h2 a, h3 a, h4 a, h5 a { + color: inherit; + text-decoration: inherit; +} + +a.headerlink { + text-decoration: none!important; + visibility: hidden; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink { + visibility: visible; +} + +br.clear { + clear: both; + border: 0px; +} + +#footer { + clear: both; + border-top: 3px solid rgb(60, 133, 124); + margin-top: 2em; + padding: 1em; + background: rgb(0, 95, 97); + color: rgb(255, 255, 255); +} + +#footer a { + color: inherit; + text-decoration: none; +} + +#footer a:hover { + color: rgb(255, 230, 0); +} + +#conduct { + float: right; + text-align: right; + font-size: smaller; + margin-right: 3em; +} + +#conduct a { + text-decoration: underline; +} + +#contact, #community, #contribute { + float: left; + padding: 0px; + margin-left: 3em; +} + +#footer h3 { + margin:0px; + font-size: 1em; + color: rgb(60, 133, 124); +} + +#footer ul { + list-style: none; + margin: 0px; + font-size: smaller; +} + +#advancedsearch { + display: none; + vertical-align: bottom; + position: absolute; + padding: 1em; + padding-top: 0em; + margin-top: 0em; + top: 100px; + right: 0px; + width: 15em; + text-align: left; + color: white; + background: rgb(0, 95, 97); + border-left: 3px solid rgb(60, 133, 124); + border-bottom: 3px solid rgb(60, 133, 124); +} + +/* Use div.advancedsearch, not #advancedsearch because the + * 'advancedsearch' class is set dynamically when javascript + * loads. This ensures that the advancedsearch options are + * not displayed when javascript is disabled. +*/ +#search:hover div.advancedsearch { + display: table; +} + +#advancedsearch span { + display: block; +} + +#advancedsearch input[type=radio] { + height: inherit; + display: inline; +} + +#advancedsearch label { + display: inline; +} + +/* Elements with id 'contents' contain the table of contents generated by docutils */ +.contents li p { + margin: 2px; +} + +#contents { + margin-top: 1em; + margin-bottom: 1em; + background: rgb(230, 230, 230); + padding: 0.5em; + padding-left: 0px; + display: inline-block; + border: 1px solid #999999; +} + +#contents p.topic-title { + display: none; +} diff --git a/docs/css/libvirt.css b/docs/css/libvirt.css index 0dc3280694..370bff1f0d 100644 --- a/docs/css/libvirt.css +++ b/docs/css/libvirt.css @@ -1,110 +1,3 @@ -#nav { - position: absolute; - top: 0px; - left: 0px; - height: 100px; - background: rgb(0, 95, 97); - border-bottom: 3px solid rgb(60, 133, 124); - width: 100%; - display: table; -} - -#home { - background-image: url(../logos/logo-banner-light-256.png); - background-repeat: no-repeat; - background-position: left center; - height: 100px; - width: 269px; - margin-left: 1em; - text-indent: 100%; white-space: nowrap; overflow: hidden; -} - -#home a { - color: rgb(0, 95, 97); - height: 100px; - width: 269px; - display: block; -} - -#jumplinks { - display: table-cell; - vertical-align: middle; - font-size: 16pt; - text-align: right; -} - -#jumplinks ul { - list-style: none; -} - -#jumplinks li { - display: inline; - padding-left: 2em; - font-weight: bold; -} - -#jumplinks a { - color: rgb(255, 255, 255); - text-decoration: none; -} - -#jumplinks a:hover { - color: rgb(255, 230, 0); -} - -#search { - display: table-cell; - vertical-align: middle; - width: 13em; - text-align: right; - padding: 1em; -} - -#search input { - border: 0px; - height: 2em; -} - -#search input[type=text] { - background: rgb(230, 230, 230); - color: rgb(0, 0, 0); - width: 10em; - padding: 0px; - padding-left: 2px; - padding-right: 2px; -} - -#search input[type=submit] { - background: rgb(60, 133, 124); - color: rgb(255, 255, 255); - width: 3em; - font-weight: bold; -} - -#search input[type=submit]:active, -#search input[type=submit]:hover { - color: rgb(255, 230, 0); -} - -#body { - border: 0px; - left: 0px; - margin: 0px; - margin-top: 120px; - margin-left: 1em; - margin-right: 1em; -} - -main, -.document { - margin-left: auto; - margin-right: auto; - padding: 0px; - padding-bottom: 1em; - max-width: 95%; - width: 70em; -} - main#the-virtualization-api, #the-virtualization-api.document, main#documentation, @@ -151,11 +44,6 @@ div.api table td, div.variablelist table td { padding-left: 1em; } -h1 a, h2 a, h3 a, h4 a, h5 a { - color: inherit; - text-decoration: inherit; -} - table { border-collapse: collapse; min-width: 60%; @@ -303,20 +191,6 @@ div.description pre.code { margin-left: 2.5em; } -a.headerlink { - text-decoration: none!important; - visibility: hidden; -} - -h1:hover > a.headerlink, -h2:hover > a.headerlink, -h3:hover > a.headerlink, -h4:hover > a.headerlink, -h5:hover > a.headerlink, -h6:hover > a.headerlink { - visibility: visible; -} - #the-virtualization-api section, #the-virtualization-api .section, #documentation section, @@ -360,58 +234,6 @@ h6:hover > a.headerlink { padding: 1em; } -br.clear { - clear: both; - border: 0px; -} - -#footer { - clear: both; - border-top: 3px solid rgb(60, 133, 124); - margin-top: 2em; - padding: 1em; - background: rgb(0, 95, 97); - color: rgb(255, 255, 255); -} - -#footer a { - color: inherit; - text-decoration: none; -} - -#footer a:hover { - color: rgb(255, 230, 0); -} - -#conduct { - float: right; - text-align: right; - font-size: smaller; - margin-right: 3em; -} - -#conduct a { - text-decoration: underline; -} - -#contact, #community, #contribute { - float: left; - padding: 0px; - margin-left: 3em; -} - -#footer h3 { - margin:0px; - font-size: 1em; - color: rgb(60, 133, 124); -} - -#footer ul { - list-style: none; - margin: 0px; - font-size: smaller; -} - #the-virtualization-api dd, #documentation dd, #knowledge-base dd { @@ -467,45 +289,6 @@ td.enumvalue { white-space: nowrap; } -#advancedsearch { - display: none; - vertical-align: bottom; - position: absolute; - padding: 1em; - padding-top: 0em; - margin-top: 0em; - top: 100px; - right: 0px; - width: 15em; - text-align: left; - color: white; - background: rgb(0, 95, 97); - border-left: 3px solid rgb(60, 133, 124); - border-bottom: 3px solid rgb(60, 133, 124); -} - -/* Use div.advancedsearch, not #advancedsearch because the - * 'advancedsearch' class is set dynamically when javascript - * loads. This ensures that the advancedsearch options are - * not displayed when javascript is disabled. -*/ -#search:hover div.advancedsearch { - display: table; -} - -#advancedsearch span { - display: block; -} - -#advancedsearch input[type=radio] { - height: inherit; - display: inline; -} - -#advancedsearch label { - display: inline; -} - .removedhv { color: darkred; } @@ -515,31 +298,11 @@ td.enumvalue { background: #eeeeee; } -.contents li p { - margin: 2px; -} - th p, td p { margin-top: 0px; margin-bottom: 0px; } -/* Elements with id 'contents' contain the table of contents generated by docutils */ - -#contents { - margin-top: 1em; - margin-bottom: 1em; - background: rgb(230, 230, 230); - padding: 0.5em; - padding-left: 0px; - display: inline-block; - border: 1px solid #999999; -} - -#contents p.topic-title { - display: none; -} - span.del { text-decoration: line-through; } diff --git a/docs/css/main.css b/docs/css/main.css index 74498dd30e..d832836f3a 100644 --- a/docs/css/main.css +++ b/docs/css/main.css @@ -1,5 +1,6 @@ @import url(fonts.css); @import url(generic.css); @import url(libvirt.css); +@import url(libvirt-template.css); @import url(mobile-template.css); @import url(mobile-libvirt.css); diff --git a/docs/css/meson.build b/docs/css/meson.build index 51cf0d6b72..74007c8051 100644 --- a/docs/css/meson.build +++ b/docs/css/meson.build @@ -2,6 +2,7 @@ docs_css_files = [ 'fonts.css', 'generic.css', 'libvirt.css', + 'libvirt-template.css', 'main.css', 'mobile-template.css', 'mobile-libvirt.css', -- 2.43.0

The 'table tbody td.y' and 'table tbody td.n' selectors don't exist since commit 8841302e3d46b2de0227dc2f97e4e647580e3d88 which converted the table to rST. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/css/libvirt.css | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/css/libvirt.css b/docs/css/libvirt.css index 370bff1f0d..2dc127f373 100644 --- a/docs/css/libvirt.css +++ b/docs/css/libvirt.css @@ -99,16 +99,6 @@ img.diagram { margin-right: auto; } - -table tbody td.y { - background: rgb(220,255,220); - text-align: center; -} -table tbody td.n { - background: rgb(255,220,220); - text-align: center; -} - .api { font-family: monospace; } -- 2.43.0

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/css/libvirt-api.css | 112 +++++++++++++++++++++++++++++++++++++++ docs/css/libvirt.css | 111 -------------------------------------- docs/css/main.css | 1 + docs/css/meson.build | 1 + 4 files changed, 114 insertions(+), 111 deletions(-) create mode 100644 docs/css/libvirt-api.css diff --git a/docs/css/libvirt-api.css b/docs/css/libvirt-api.css new file mode 100644 index 0000000000..ab6d846530 --- /dev/null +++ b/docs/css/libvirt-api.css @@ -0,0 +1,112 @@ +/* CSS styles for the generated API documents */ + +div.api { + border: 1px solid #999999; + background: #eeeeee; + color: black; + padding: 3px; +} + +div.api pre { + margin: 0px; + border: 0px; + background: inherit; + padding: inherit; +} + +div.api table { + margin: 0px; + padding-left: 2em; + border-spacing: 0px; +} + +div.api table td, div.variablelist table td { + vertical-align: top; + padding-left: 1em; +} + +.api { + font-family: monospace; +} + +.api .type { + font-weight: bold; + white-space: nowrap; + color: darkslateblue; +} + +.api .keyword { + font-weight: bold; + color: #A2F; +} + +.api .comment { + color: #080; + margin-left: 2em; + position: relative; +} + +.api .comment:before { + content: ": "; + position: absolute; + left: -1.3em; +} + +.api .undisclosed { + font-style: italic; + letter-spacing: .3ex; + font-weight: bolder; + text-transform: uppercase; + margin-left: 2em; +} + +.api .directive { + color: teal; +} + +.api :link:hover, .api :link:focus { + color: blue; + border-color: blue; +} + +.api :link { + text-decoration: none; +} + +.api table td,.api table th { + border: 0px; +} + +.api table tr:hover td, .api table col:hover td { + background: inherit; +} + +.api table tr td:hover { + background: inherit; +} + +dl.variablelist > dt { + display: block; + float: left; + font-style: italic; + font-weight: inherit; +} + +.variablelist dd { + padding-left: 10em; +} + +dl.variablelist > dt:after { + content: ": "; +} + +div.description pre.code { + border: 1px dashed grey; + background-color: inherit; + padding: 5px 10px 5px 10px; + margin-left: 2.5em; +} + +td.enumvalue { + white-space: nowrap; +} diff --git a/docs/css/libvirt.css b/docs/css/libvirt.css index 2dc127f373..02942bcf75 100644 --- a/docs/css/libvirt.css +++ b/docs/css/libvirt.css @@ -19,31 +19,6 @@ a { color: rgb(0, 95, 97); } -div.api { - border: 1px solid #999999; - background: #eeeeee; - color: black; - padding: 3px; -} - -div.api pre { - margin: 0px; - border: 0px; - background: inherit; - padding: inherit; -} - -div.api table { - margin: 0px; - padding-left: 2em; - border-spacing: 0px; -} - -div.api table td, div.variablelist table td { - vertical-align: top; - padding-left: 1em; -} - table { border-collapse: collapse; min-width: 60%; @@ -99,88 +74,6 @@ img.diagram { margin-right: auto; } -.api { - font-family: monospace; -} - -.api .type { - font-weight: bold; - white-space: nowrap; - color: darkslateblue; -} - -.api .keyword { - font-weight: bold; - color: #A2F; -} - -.api .comment { - color: #080; - margin-left: 2em; - position: relative; -} - -.api .comment:before { - content: ": "; - position: absolute; - left: -1.3em; -} - -.api .undisclosed { - font-style: italic; - letter-spacing: .3ex; - font-weight: bolder; - text-transform: uppercase; - margin-left: 2em; -} - -.api .directive { - color: teal; -} - -.api :link:hover, .api :link:focus { - color: blue; - border-color: blue; -} - -.api :link { - text-decoration: none; -} - -.api table td,.api table th { - border: 0px; -} - -.api table tr:hover td, .api table col:hover td { - background: inherit; -} - -.api table tr td:hover { - background: inherit; -} - -dl.variablelist > dt { - display: block; - float: left; - font-style: italic; - font-weight: inherit; -} - -.variablelist dd { - padding-left: 10em; -} - -dl.variablelist > dt:after { - content: ": "; -} - -div.description pre.code { - border: 1px dashed grey; - background-color: inherit; - padding: 5px 10px 5px 10px; - margin-left: 2.5em; -} - #the-virtualization-api section, #the-virtualization-api .section, #documentation section, @@ -275,10 +168,6 @@ div.description pre.code { margin-bottom: 1em; } -td.enumvalue { - white-space: nowrap; -} - .removedhv { color: darkred; } diff --git a/docs/css/main.css b/docs/css/main.css index d832836f3a..fdcba22130 100644 --- a/docs/css/main.css +++ b/docs/css/main.css @@ -1,6 +1,7 @@ @import url(fonts.css); @import url(generic.css); @import url(libvirt.css); +@import url(libvirt-api.css); @import url(libvirt-template.css); @import url(mobile-template.css); @import url(mobile-libvirt.css); diff --git a/docs/css/meson.build b/docs/css/meson.build index 74007c8051..6f4f140ffc 100644 --- a/docs/css/meson.build +++ b/docs/css/meson.build @@ -2,6 +2,7 @@ docs_css_files = [ 'fonts.css', 'generic.css', 'libvirt.css', + 'libvirt-api.css', 'libvirt-template.css', 'main.css', 'mobile-template.css', -- 2.43.0

Move the few generic styles to the appropriate document. 'libvirt.css' will now be a compilation of styles related only to libvirt.org. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/css/generic.css | 59 ++++++++++++++++++++++++++++++++++++++++++++ docs/css/libvirt.css | 59 -------------------------------------------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/docs/css/generic.css b/docs/css/generic.css index d15d85e67a..df37ceea37 100644 --- a/docs/css/generic.css +++ b/docs/css/generic.css @@ -83,3 +83,62 @@ dd code, p code, tt { pre { font-size: 90%; } + +pre { + border: 1px solid #999999; + background: #eeeeee; + color: black; + padding: 1em; +} + +a { + color: rgb(0, 95, 97); +} + +table { + border-collapse: collapse; + min-width: 60%; + margin-left: auto; + margin-right: auto; +} + +table th { + background: rgb(0, 95, 97); + color: rgb(255, 255, 255); + padding: 0.5em; +} + +table th a { + color: inherit; + text-decoration: inherit; +} + +table td, table th { + border: 1px solid rgb(60, 133, 124); +} + +table td { + padding: 4px; +} + +table tr:hover td, table col:hover td { + background: #eeeeee; +} + +table tr td:hover { + background: #c5dbd8; +} + +.literal, code { + font-family: monospace; + background: #eeeeee; +} + +th p, td p { + margin-top: 0px; + margin-bottom: 0px; +} + +span.del { + text-decoration: line-through; +} diff --git a/docs/css/libvirt.css b/docs/css/libvirt.css index 02942bcf75..58ac1d385b 100644 --- a/docs/css/libvirt.css +++ b/docs/css/libvirt.css @@ -8,51 +8,6 @@ main#knowledge-base, width: inherit; } -pre { - border: 1px solid #999999; - background: #eeeeee; - color: black; - padding: 1em; -} - -a { - color: rgb(0, 95, 97); -} - -table { - border-collapse: collapse; - min-width: 60%; - margin-left: auto; - margin-right: auto; -} - -table th { - background: rgb(0, 95, 97); - color: rgb(255, 255, 255); - padding: 0.5em; -} - -table th a { - color: inherit; - text-decoration: inherit; -} - -table td, table th { - border: 1px solid rgb(60, 133, 124); -} - -table td { - padding: 4px; -} - -table tr:hover td, table col:hover td { - background: #eeeeee; -} - -table tr td:hover { - background: #c5dbd8; -} - span.since { color: #3c857c; font-style: italic; @@ -171,17 +126,3 @@ img.diagram { .removedhv { color: darkred; } - -.literal, code { - font-family: monospace; - background: #eeeeee; -} - -th p, td p { - margin-top: 0px; - margin-bottom: 0px; -} - -span.del { - text-decoration: line-through; -} -- 2.43.0

Strip down the main template as much as possible. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/page.xsl | 14 -------------- docs/site.xsl | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/page.xsl b/docs/page.xsl index 04d7cc9432..e2f0092ae9 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -7,18 +7,12 @@ exclude-result-prefixes="xsl exsl html" version="1.0"> - <xsl:param name="builddir" select="'..'"/> - <xsl:template match="node() | @*" mode="content"> <xsl:copy> <xsl:apply-templates select="node() | @*" mode="content"/> </xsl:copy> </xsl:template> - <xsl:template match="html:div[@id='include']" mode="content"> - <xsl:call-template name="include"/> - </xsl:template> - <!-- This is the master page structure --> <xsl:template match="/" mode="page"> <xsl:param name="pagesrc"/> @@ -125,14 +119,6 @@ </html> </xsl:template> - <xsl:template name="include"> - <xsl:variable name="inchtml"> - <xsl:copy-of select="document(concat($builddir, '/docs/', @filename))"/> - </xsl:variable> - - <xsl:apply-templates select="exsl:node-set($inchtml)/html:html/html:body/*" mode="content"/> - </xsl:template> - <xsl:template match="html:h1 | html:h2 | html:h3 | html:h4 | html:h5 | html:h6" mode="content"> <xsl:element name="{name()}"> <xsl:apply-templates mode="copy" /> diff --git a/docs/site.xsl b/docs/site.xsl index f56eb67b8a..0c11619fea 100644 --- a/docs/site.xsl +++ b/docs/site.xsl @@ -8,6 +8,20 @@ <xsl:import href="page.xsl"/> + <xsl:param name="builddir" select="'..'"/> + + <xsl:template match="html:div[@id='include']" mode="content"> + <xsl:call-template name="include"/> + </xsl:template> + + <xsl:template name="include"> + <xsl:variable name="inchtml"> + <xsl:copy-of select="document(concat($builddir, '/docs/', @filename))"/> + </xsl:variable> + + <xsl:apply-templates select="exsl:node-set($inchtml)/html:html/html:body/*" mode="content"/> + </xsl:template> + <xsl:output method="xml" encoding="UTF-8" -- 2.43.0

Propagate it as a parameter both from site.xsl and from newapi.xsl, the latter of which declared it as a variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/html/meson.build | 2 ++ docs/newapi.xsl | 2 +- docs/page.xsl | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/html/meson.build b/docs/html/meson.build index e2758ed177..abb4fcf72a 100644 --- a/docs/html/meson.build +++ b/docs/html/meson.build @@ -27,6 +27,7 @@ index_api_gen = custom_target( xsltproc_prog, '--nonet', '-o', docs_builddir, '--stringparam', 'builddir', meson.project_build_root(), '--stringparam', 'timestamp', docs_timestamp, + '--stringparam', 'href_base', '../', '@INPUT@', ], install: true, @@ -53,6 +54,7 @@ foreach name : [ 'admin', 'lxc', 'qemu' ] xsltproc_prog, '--nonet', '-o', docs_builddir, '--stringparam', 'builddir', meson.project_build_root(), '--stringparam', 'timestamp', docs_timestamp, + '--stringparam', 'href_base', '../', '@INPUT@', ], install: true, diff --git a/docs/newapi.xsl b/docs/newapi.xsl index 19a440bb09..ebe7fdedd7 100644 --- a/docs/newapi.xsl +++ b/docs/newapi.xsl @@ -24,7 +24,6 @@ <!-- the target directory for the HTML output --> <xsl:variable name="htmldir">html</xsl:variable> - <xsl:variable name="href_base">../</xsl:variable> <xsl:template name="aclinfo"> <xsl:param name="acl"/> @@ -816,6 +815,7 @@ encoding="UTF-8"> <xsl:apply-templates select="exsl:node-set($subpage)" mode="page"> <xsl:with-param name="timestamp" select="$timestamp"/> + <xsl:with-param name="href_base" select="$href_base"/> </xsl:apply-templates> </xsl:document> </xsl:for-each> diff --git a/docs/page.xsl b/docs/page.xsl index e2f0092ae9..5d55fac43f 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -17,6 +17,7 @@ <xsl:template match="/" mode="page"> <xsl:param name="pagesrc"/> <xsl:param name="timestamp"/> + <xsl:param name="href_base"/> <xsl:text disable-output-escaping="yes"><!DOCTYPE html> </xsl:text> <html data-sourcedoc="{$pagesrc}"> -- 2.43.0

To allow reuse of this template as-is in libvirt-wiki, we need to be able to specify a distinct asset_href_base and link_href_base. Adjust the template to allow that. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/newapi.xsl | 3 ++- docs/page.xsl | 21 +++++++++++---------- docs/site.xsl | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/newapi.xsl b/docs/newapi.xsl index ebe7fdedd7..d6f8d88170 100644 --- a/docs/newapi.xsl +++ b/docs/newapi.xsl @@ -815,7 +815,8 @@ encoding="UTF-8"> <xsl:apply-templates select="exsl:node-set($subpage)" mode="page"> <xsl:with-param name="timestamp" select="$timestamp"/> - <xsl:with-param name="href_base" select="$href_base"/> + <xsl:with-param name="link_href_base" select="$href_base"/> + <xsl:with-param name="asset_href_base" select="$href_base"/> </xsl:apply-templates> </xsl:document> </xsl:for-each> diff --git a/docs/page.xsl b/docs/page.xsl index 5d55fac43f..a51587db6c 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -17,7 +17,8 @@ <xsl:template match="/" mode="page"> <xsl:param name="pagesrc"/> <xsl:param name="timestamp"/> - <xsl:param name="href_base"/> + <xsl:param name="link_href_base"/> + <xsl:param name="asset_href_base"/> <xsl:text disable-output-escaping="yes"><!DOCTYPE html> </xsl:text> <html data-sourcedoc="{$pagesrc}"> @@ -31,7 +32,7 @@ <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> - <link rel="stylesheet" type="text/css" href="{$href_base}css/main.css"/> + <link rel="stylesheet" type="text/css" href="{$asset_href_base}css/main.css"/> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/> @@ -43,7 +44,7 @@ <meta name="go-import" content="{/html:html/html:head/html:meta[@name='go-import']/@content}"/> </xsl:if> - <script type="text/javascript" src="{$href_base}js/main.js"> + <script type="text/javascript" src="{$asset_href_base}js/main.js"> <xsl:comment>// forces non-empty element</xsl:comment> </script> </head> @@ -62,13 +63,13 @@ </div> <div id="nav"> <div id="home"> - <a href="{$href_base}index.html">Home</a> + <a href="{$link_href_base}index.html">Home</a> </div> <div id="jumplinks"> <ul> - <li><a href="{$href_base}downloads.html">Download</a></li> - <li><a href="{$href_base}contribute.html">Contribute</a></li> - <li><a href="{$href_base}docs.html">Docs</a></li> + <li><a href="{$link_href_base}downloads.html">Download</a></li> + <li><a href="{$link_href_base}contribute.html">Contribute</a></li> + <li><a href="{$link_href_base}docs.html">Docs</a></li> </ul> </div> <div id="search"> @@ -91,8 +92,8 @@ <div id="contact"> <h3>Contact</h3> <ul> - <li><a href="{$href_base}contact.html#mailing-lists">email</a></li> - <li><a href="{$href_base}contact.html#irc">irc</a></li> + <li><a href="{$link_href_base}contact.html#mailing-lists">email</a></li> + <li><a href="{$link_href_base}contact.html#irc">irc</a></li> </ul> </div> <div id="community"> @@ -112,7 +113,7 @@ </div> </xsl:if> <div id="conduct"> - Participants in the libvirt project agree to abide by <a href="{$href_base}governance.html#code-of-conduct">the project code of conduct</a> + Participants in the libvirt project agree to abide by <a href="{$link_href_base}governance.html#code-of-conduct">the project code of conduct</a> </div> <br class="clear"/> </div> diff --git a/docs/site.xsl b/docs/site.xsl index 0c11619fea..c0b56be72f 100644 --- a/docs/site.xsl +++ b/docs/site.xsl @@ -31,7 +31,8 @@ <xsl:apply-templates select="." mode="page"> <xsl:with-param name="pagesrc" select="$pagesrc"/> <xsl:with-param name="timestamp" select="$timestamp"/> - <xsl:with-param name="href_base" select="$href_base"/> + <xsl:with-param name="link_href_base" select="$href_base"/> + <xsl:with-param name="asset_href_base" select="$href_base"/> </xsl:apply-templates> </xsl:template> -- 2.43.0

On a Wednesday in 2024, Peter Krempa wrote:
Patch 1 fixes the 'maven' redirect for gitlab pages by adding a /. Note that I didn't test that yet as it's hard to do with the redirects file, so this one will be tested in produciton.
The rest of the series optimizes JS, CSS and XSLT assets for reuse in libvirt wiki by separating out stuff that is relevant only for libvirt.org. There will be a corresponding merge request to pull them into the wiki project.
The resulting page can be browsed at:
https://pipo.sk.gitlab.io/-/libvirt/-/jobs/6119138205/artifacts/website/inde...
https://gitlab.com/pipo.sk/libvirt/-/pipelines/1168193309
Peter Krempa (11): gitlab_pages: Fix 'maven' redirect docs: page.xsl: Fix headerlinks with new docutils js: Separate the virt-tools blog planet loader code css: mobile: Split up libvirt.org specific styles from main template style css: Split out page templated styles to 'libvirt-template.css' css: Remove unused CSS for migration support matrix table css: Move styles for the generated API documents to libvirt-api.css css: Move generic styles to 'generic.css' docs: Move 'html including' from page.xsl to site.xsl docs: xsl: Properly propagate 'href_base' as XSL template parameter docs: page.xsl: Split up 'href_base' for assets and links
.gitlab_pages_redirects | 2 +- docs/css/generic.css | 59 +++ docs/css/libvirt-api.css | 112 +++++ docs/css/libvirt-template.css | 236 +++++++++++ docs/css/libvirt.css | 417 ------------------- docs/css/main.css | 5 +- docs/css/meson.build | 5 +- docs/css/mobile-libvirt.css | 17 + docs/css/{mobile.css => mobile-template.css} | 15 +- docs/html/meson.build | 2 + docs/index.rst | 5 +- docs/js/main.js | 62 --- docs/js/meson.build | 1 + docs/js/virt-tools-blog-planet.js | 65 +++ docs/newapi.xsl | 3 +- docs/page.xsl | 37 +- docs/site.xsl | 17 +- 17 files changed, 535 insertions(+), 525 deletions(-) create mode 100644 docs/css/libvirt-api.css create mode 100644 docs/css/libvirt-template.css create mode 100644 docs/css/mobile-libvirt.css rename docs/css/{mobile.css => mobile-template.css} (84%) create mode 100644 docs/js/virt-tools-blog-planet.js
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa