[libvirt] [PATCH v3 0/5] docs: Update third-party JavaScript libraries

We're carrying around embedded copies of a few JavaScript libraries for use in our homepage, and we've been unforgivably bad at keeping them up to date. Address that. While doing so, replace the minified version of each library with its non-minified counterpart so that libvirt.git and release archives will include the actual source code for them, rather than what is basically the JavaScript equivalent of binary blobs. Note that I consider this to be merely a stop-gap measure until we start generating the blog roll, the only part of the libvirt website that uses these libraries, on the server side and finally drop them entirely. I don't have cycles to dedicate to that effort at the moment though, and this is better than leaving the situation unchanged for who knows how much longer. Since the diffs are kinda big and honestly just not very interesting, I've snipped them liberally; the unabridged version of this series can be fetched with $ git fetch https://github.com/andreabolognani/libvirt js Changes from [v2]: * import non-minified libraries and minify them at build time. Changes from [v1]: * drop libraries instead of updating them. [v2] https://www.redhat.com/archives/libvir-list/2019-June/msg00611.html [v1] https://www.redhat.com/archives/libvir-list/2019-June/msg00551.html Andrea Bolognani (5): docs: Update jQuery docs: Update Moment.js docs: Update jquery.rss docs: Perform JavaScript minimization at build time spec: Require uglifyjs for RPM build .gitignore | 1 + docs/Makefile.am | 37 +- docs/index.html.in | 6 +- docs/js/jquery-3.1.1.min.js | 4 - docs/js/jquery-3.4.1.js | 10598 +++++++++++++++++++++++++++++++++ docs/js/jquery.rss-3.3.0.js | 333 ++ docs/js/jquery.rss.min.js | 11 - docs/js/moment-2.24.0.js | 4602 ++++++++++++++ docs/js/moment.min.js | 7 - docs/page.xsl | 2 +- docs/site.xsl | 1 + docs/subsite.xsl | 1 + libvirt.spec.in | 5 + m4/virt-external-programs.m4 | 2 + 14 files changed, 15578 insertions(+), 32 deletions(-) delete mode 100644 docs/js/jquery-3.1.1.min.js create mode 100644 docs/js/jquery-3.4.1.js create mode 100644 docs/js/jquery.rss-3.3.0.js delete mode 100644 docs/js/jquery.rss.min.js create mode 100644 docs/js/moment-2.24.0.js delete mode 100644 docs/js/moment.min.js -- 2.21.0

We're using the very outdated 3.1.1 (Sep 2016). Replace it with 3.4.1 (May 2019), the latest available. The new file, unlike the one it replaces, is not minified. We'll take care of that separately. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/Makefile.am | 2 +- docs/index.html.in | 2 +- docs/js/jquery-3.1.1.min.js | 4 - docs/js/jquery-3.4.1.js | 10598 ++++++++++++++++++++++++++++++++++ 4 files changed, 10600 insertions(+), 6 deletions(-) delete mode 100644 docs/js/jquery-3.1.1.min.js create mode 100644 docs/js/jquery-3.4.1.js diff --git a/docs/Makefile.am b/docs/Makefile.am index 0c899f9580..f42307c7d5 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -67,7 +67,7 @@ css = \ javascript = \ js/main.js \ - js/jquery-3.1.1.min.js \ + js/jquery-3.4.1.js \ js/jquery.rss.min.js \ js/moment.min.js diff --git a/docs/index.html.in b/docs/index.html.in index f593445d06..edf18f8aec 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -2,7 +2,7 @@ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <script type="text/javascript" src="js/jquery-3.1.1.min.js"> </script> + <script type="text/javascript" src="js/jquery-3.4.1.js"> </script> <script type="text/javascript" src="js/moment.min.js"> </script> <script type="text/javascript" src="js/jquery.rss.min.js"> </script> diff --git a/docs/js/jquery-3.1.1.min.js b/docs/js/jquery-3.1.1.min.js deleted file mode 100644 index 4c5be4c0fb..0000000000 --- a/docs/js/jquery-3.1.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v3.1.1 | (c) jQuery Foundation | jquery.org/license */ -!function(a,b){"use strict";"object"==typeof module&&"object"==typeo [...] diff --git a/docs/js/jquery-3.4.1.js b/docs/js/jquery-3.4.1.js new file mode 100644 index 0000000000..773ad95c56 --- /dev/null +++ b/docs/js/jquery-3.4.1.js @@ -0,0 +1,10598 @@ +/*! + * jQuery JavaScript Library v3.4.1 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2019-05-01T21:04Z + */ +( function( global, factory ) { + + "use strict"; + + if ( typeof module === "object" && typeof module.exports === "obj [...] -- 2.21.0

We're using the very outdated 2.8.3 (Nov 2014). Replace it with 2.24.0 (Jan 2019), the latest available. The new file, unlike the one it replaces, is not minified. We'll take care of that separately. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/Makefile.am | 3 +- docs/index.html.in | 2 +- docs/js/moment-2.24.0.js | 4602 ++++++++++++++++++++++++++++++++++++++ docs/js/moment.min.js | 7 - 4 files changed, 4605 insertions(+), 9 deletions(-) create mode 100644 docs/js/moment-2.24.0.js delete mode 100644 docs/js/moment.min.js diff --git a/docs/Makefile.am b/docs/Makefile.am index f42307c7d5..83d5c41419 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -69,7 +69,8 @@ javascript = \ js/main.js \ js/jquery-3.4.1.js \ js/jquery.rss.min.js \ - js/moment.min.js + js/moment-2.24.0.js \ + $(NULL) fonts = \ diff --git a/docs/index.html.in b/docs/index.html.in index edf18f8aec..422dc10700 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="js/jquery-3.4.1.js"> </script> - <script type="text/javascript" src="js/moment.min.js"> </script> + <script type="text/javascript" src="js/moment-2.24.0.js"> </script> <script type="text/javascript" src="js/jquery.rss.min.js"> </script> <script type="text/javascript"> diff --git a/docs/js/moment-2.24.0.js b/docs/js/moment-2.24.0.js new file mode 100644 index 0000000000..1b129716ac --- /dev/null +++ b/docs/js/moment-2.24.0.js @@ -0,0 +1,4602 @@ +//! moment.js + +;(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? m [...] diff --git a/docs/js/moment.min.js b/docs/js/moment.min.js deleted file mode 100644 index 9fb34ee07f..0000000000 --- a/docs/js/moment.min.js +++ /dev/null @@ -1,7 +0,0 @@ -//! moment.js -//! version : 2.8.4 -//! authors : Tim Wood, Iskren Chernev, Moment.js contributors -//! license : MIT -//! momentjs.com -(function(a){function b(a,b,c){switch(arguments.length){case 2:retur [...] -- 2.21.0

We're using the very outdated 3.2.1 (Dec 2015). Replace it with 3.3.0 (Jan 2017), the latest available. The new file, unlike the one it replaces, is not minified. We'll take care of that separately. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/Makefile.am | 2 +- docs/index.html.in | 2 +- docs/js/jquery.rss-3.3.0.js | 333 ++++++++++++++++++++++++++++++++++++ docs/js/jquery.rss.min.js | 11 -- 4 files changed, 335 insertions(+), 13 deletions(-) create mode 100644 docs/js/jquery.rss-3.3.0.js delete mode 100644 docs/js/jquery.rss.min.js diff --git a/docs/Makefile.am b/docs/Makefile.am index 83d5c41419..9b79fc60c1 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -68,7 +68,7 @@ css = \ javascript = \ js/main.js \ js/jquery-3.4.1.js \ - js/jquery.rss.min.js \ + js/jquery.rss-3.3.0.js \ js/moment-2.24.0.js \ $(NULL) diff --git a/docs/index.html.in b/docs/index.html.in index 422dc10700..cab387ebb6 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -4,7 +4,7 @@ <head> <script type="text/javascript" src="js/jquery-3.4.1.js"> </script> <script type="text/javascript" src="js/moment-2.24.0.js"> </script> - <script type="text/javascript" src="js/jquery.rss.min.js"> </script> + <script type="text/javascript" src="js/jquery.rss-3.3.0.js"> </script> <script type="text/javascript"> <!-- diff --git a/docs/js/jquery.rss-3.3.0.js b/docs/js/jquery.rss-3.3.0.js new file mode 100644 index 0000000000..d25ed45141 --- /dev/null +++ b/docs/js/jquery.rss-3.3.0.js @@ -0,0 +1,333 @@ +(function ($) { + 'use strict'; + + var RSS = function (target, url, options, callback) { [...] diff --git a/docs/js/jquery.rss.min.js b/docs/js/jquery.rss.min.js deleted file mode 100644 index ad21eb5816..0000000000 --- a/docs/js/jquery.rss.min.js +++ /dev/null @@ -1,11 +0,0 @@ -(function(d){var e=function(a,b,c,f){this.target=a;this.url=b;this.h [...] -- 2.21.0

We want to store third-party JavaScript libraries in their non-minimized (source) form in the repository, but when users are browsing libvirt.org we'd rather only transmit the more compact minified variant. Call uglifyjs at build time, if available, to achieve this. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .gitignore | 1 + docs/Makefile.am | 30 +++++++++++++++++++++++++++--- docs/index.html.in | 6 +++--- docs/page.xsl | 2 +- docs/site.xsl | 1 + docs/subsite.xsl | 1 + m4/virt-external-programs.m4 | 2 ++ 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 727bfdb6ec..522ac762b6 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ /docs/apibuild.py.stamp /docs/devhelp/libvirt.devhelp /docs/hvsupport.html.in +/docs/js/*.min.js /docs/libvirt-admin-*.xml /docs/libvirt-api.xml /docs/libvirt-lxc-*.xml diff --git a/docs/Makefile.am b/docs/Makefile.am index 9b79fc60c1..e787a7c47b 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -240,6 +240,7 @@ news.html.in: \ $(srcdir)/news.xml \ $(srcdir)/news-html.xsl $(AM_V_GEN)$(XSLTPROC) --nonet \ + --stringparam js "$(JS)" \ $(srcdir)/news-html.xsl \ $(srcdir)/news.xml \ >$@-tmp \ @@ -258,7 +259,7 @@ MAINTAINERCLEANFILES += \ convert -rotate 90 $< $@ %.html.tmp: %.html.in site.xsl subsite.xsl page.xsl \ - $(acl_generated) + $(acl_generated) $(minified_javascript) $(AM_V_GEN)name=`echo $@ | sed -e 's/.tmp//'`; \ dir=`dirname $@` ; \ if test "$$dir" = "."; \ @@ -270,24 +271,47 @@ MAINTAINERCLEANFILES += \ fi; \ $(XSLTPROC) --stringparam pagename $$name \ --stringparam timestamp $(timestamp) --nonet \ + --stringparam js "$(JS)" \ $(top_srcdir)/docs/$$style $< > $@ \ + || { rm $@ && exit 1; }; \ + sed -i 's/@JS@/$(JS)/g' "$@" \ || { rm $@ && exit 1; } %.html: %.html.tmp $(AM_V_GEN)$(XMLLINT) --nonet --format $< > $(srcdir)/$@ \ || { rm $(srcdir)/$@ && exit 1; } + +if HAVE_UGLIFYJS +JS = min.js +minified_javascript = $(javascript:%.js=%.min.js) +EXTRA_DIST += $(minified_javascript) +MAINTAINERCLEANFILES += $(minified_javascript) + +%.min.js: %.js + $(AM_V_GEN)$(UGLIFYJS) -o $@ $< +else ! HAVE_UGLIFYJS +JS = js +minified_javascript = $(javascript) + +dist-hook: + echo "uglifyjs is required to make dist." >&2 + exit 1 +endif ! HAVE_UGLIFYJS + $(apihtml_generated): html/index.html html/index.html: libvirt-api.xml newapi.xsl page.xsl $(APIBUILD_STAMP) $(AM_V_GEN)$(XSLTPROC) --nonet -o $(srcdir)/ \ --stringparam builddir '$(abs_top_builddir)' \ --stringparam timestamp $(timestamp) \ + --stringparam js "$(JS)" \ $(srcdir)/newapi.xsl $(srcdir)/libvirt-api.xml && \ $(XMLLINT) --nonet --noout $(srcdir)/html/*.html $(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl) $(AM_V_GEN)$(XSLTPROC) --stringparam timestamp $(timestamp) \ + --stringparam js "$(JS)" \ --nonet -o $(srcdir)/devhelp/ \ $(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml @@ -372,7 +396,7 @@ install-data-local: for f in $(css) $(dot_html) $(gif) $(png); do \ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR); done $(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/js - for f in $(javascript); do \ + for f in $(minified_javascript); do \ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR)/js/; done $(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/logos for f in $(logofiles); do \ @@ -401,7 +425,7 @@ uninstall-local: for f in $(logofiles); do \ rm -f $(DESTDIR)$(HTML_DIR)/$$f; \ done - for f in $(javascript); do \ + for f in $(minified_javascript); do \ rm -f $(DESTDIR)$(HTML_DIR)/$$f; \ done for h in $(apihtml); do rm -f $(DESTDIR)$(HTML_DIR)/$$h; done diff --git a/docs/index.html.in b/docs/index.html.in index cab387ebb6..a912d7282a 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -2,9 +2,9 @@ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <script type="text/javascript" src="js/jquery-3.4.1.js"> </script> - <script type="text/javascript" src="js/moment-2.24.0.js"> </script> - <script type="text/javascript" src="js/jquery.rss-3.3.0.js"> </script> + <script type="text/javascript" src="js/jquery-3.4.1.@JS@"> </script> + <script type="text/javascript" src="js/moment-2.24.0.@JS@"> </script> + <script type="text/javascript" src="js/jquery.rss-3.3.0.@JS@"> </script> <script type="text/javascript"> <!-- diff --git a/docs/page.xsl b/docs/page.xsl index 65ddeb2bb7..bf78103df3 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -99,7 +99,7 @@ <meta name="description" content="libvirt, virtualization, virtualization API"/> <xsl:apply-templates select="/html:html/html:head/*" mode="content"/> - <script type="text/javascript" src="{$href_base}js/main.js"> + <script type="text/javascript" src="{$href_base}js/main.{$js}"> <xsl:comment>// forces non-empty element</xsl:comment> </script> </head> diff --git a/docs/site.xsl b/docs/site.xsl index c9d41f2c93..fb9c503993 100644 --- a/docs/site.xsl +++ b/docs/site.xsl @@ -28,6 +28,7 @@ <xsl:apply-templates select="." mode="page"> <xsl:with-param name="pagename" select="$pagename"/> <xsl:with-param name="timestamp" select="$timestamp"/> + <xsl:with-param name="js" select="$js"/> </xsl:apply-templates> </xsl:template> diff --git a/docs/subsite.xsl b/docs/subsite.xsl index f56ac0491c..c939ed6588 100644 --- a/docs/subsite.xsl +++ b/docs/subsite.xsl @@ -18,6 +18,7 @@ <xsl:apply-templates select="." mode="page"> <xsl:with-param name="pagename" select="$pagename"/> <xsl:with-param name="timestamp" select="$timestamp"/> + <xsl:with-param name="js" select="$js"/> </xsl:apply-templates> </xsl:template> diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4 index 0f995998c3..371acb972c 100644 --- a/m4/virt-external-programs.m4 +++ b/m4/virt-external-programs.m4 @@ -34,6 +34,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [ AC_MSG_ERROR("xsltproc is required to build libvirt") fi AC_PATH_PROG([AUGPARSE], [augparse], [/usr/bin/augparse]) + AC_PATH_PROG([UGLIFYJS], [uglifyjs], []) + AM_CONDITIONAL([HAVE_UGLIFYJS], [test "$UGLIFYJS"]) AC_PROG_MKDIR_P AC_PROG_LN_S -- 2.21.0

On 19 Jun 2019, at 14:41, Andrea Bolognani <abologna@redhat.com> wrote:
We want to store third-party JavaScript libraries in their non-minimized (source) form in the repository, but when users are browsing libvirt.org we'd rather only transmit the more compact minified variant.
Call uglifyjs at build time, if available, to achieve this. Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
--- .gitignore | 1 + docs/Makefile.am | 30 +++++++++++++++++++++++++++--- docs/index.html.in | 6 +++--- docs/page.xsl | 2 +- docs/site.xsl | 1 + docs/subsite.xsl | 1 + m4/virt-external-programs.m4 | 2 ++ 7 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore index 727bfdb6ec..522ac762b6 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ /docs/apibuild.py.stamp /docs/devhelp/libvirt.devhelp /docs/hvsupport.html.in +/docs/js/*.min.js /docs/libvirt-admin-*.xml /docs/libvirt-api.xml /docs/libvirt-lxc-*.xml diff --git a/docs/Makefile.am b/docs/Makefile.am index 9b79fc60c1..e787a7c47b 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -240,6 +240,7 @@ news.html.in: \ $(srcdir)/news.xml \ $(srcdir)/news-html.xsl $(AM_V_GEN)$(XSLTPROC) --nonet \ + --stringparam js "$(JS)" \ $(srcdir)/news-html.xsl \ $(srcdir)/news.xml \ >$@-tmp \ @@ -258,7 +259,7 @@ MAINTAINERCLEANFILES += \ convert -rotate 90 $< $@
%.html.tmp: %.html.in site.xsl subsite.xsl page.xsl \ - $(acl_generated) + $(acl_generated) $(minified_javascript) $(AM_V_GEN)name=`echo $@ | sed -e 's/.tmp//'`; \ dir=`dirname $@` ; \ if test "$$dir" = "."; \ @@ -270,24 +271,47 @@ MAINTAINERCLEANFILES += \ fi; \ $(XSLTPROC) --stringparam pagename $$name \ --stringparam timestamp $(timestamp) --nonet \ + --stringparam js "$(JS)" \ $(top_srcdir)/docs/$$style $< > $@ \ + || { rm $@ && exit 1; }; \ + sed -i 's/@JS@/$(JS)/g' "$@" \ || { rm $@ && exit 1; }
%.html: %.html.tmp $(AM_V_GEN)$(XMLLINT) --nonet --format $< > $(srcdir)/$@ \ || { rm $(srcdir)/$@ && exit 1; }
+ +if HAVE_UGLIFYJS +JS = min.js +minified_javascript = $(javascript:%.js=%.min.js) +EXTRA_DIST += $(minified_javascript) +MAINTAINERCLEANFILES += $(minified_javascript) + +%.min.js: %.js + $(AM_V_GEN)$(UGLIFYJS) -o $@ $< +else ! HAVE_UGLIFYJS +JS = js +minified_javascript = $(javascript) + +dist-hook: + echo "uglifyjs is required to make dist." >&2
It’s silly, but the Fedora package is called uglify-js. Maybe mention that?
+ exit 1 +endif ! HAVE_UGLIFYJS + $(apihtml_generated): html/index.html
html/index.html: libvirt-api.xml newapi.xsl page.xsl $(APIBUILD_STAMP) $(AM_V_GEN)$(XSLTPROC) --nonet -o $(srcdir)/ \ --stringparam builddir '$(abs_top_builddir)' \ --stringparam timestamp $(timestamp) \ + --stringparam js "$(JS)" \ $(srcdir)/newapi.xsl $(srcdir)/libvirt-api.xml && \ $(XMLLINT) --nonet --noout $(srcdir)/html/*.html
$(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl) $(AM_V_GEN)$(XSLTPROC) --stringparam timestamp $(timestamp) \ + --stringparam js "$(JS)" \ --nonet -o $(srcdir)/devhelp/ \ $(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml
@@ -372,7 +396,7 @@ install-data-local: for f in $(css) $(dot_html) $(gif) $(png); do \ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR); done $(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/js - for f in $(javascript); do \ + for f in $(minified_javascript); do \ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR)/js/; done $(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/logos for f in $(logofiles); do \ @@ -401,7 +425,7 @@ uninstall-local: for f in $(logofiles); do \ rm -f $(DESTDIR)$(HTML_DIR)/$$f; \ done - for f in $(javascript); do \ + for f in $(minified_javascript); do \ rm -f $(DESTDIR)$(HTML_DIR)/$$f; \ done for h in $(apihtml); do rm -f $(DESTDIR)$(HTML_DIR)/$$h; done diff --git a/docs/index.html.in b/docs/index.html.in index cab387ebb6..a912d7282a 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -2,9 +2,9 @@ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <script type="text/javascript" src="js/jquery-3.4.1.js"> </script> - <script type="text/javascript" src="js/moment-2.24.0.js"> </script> - <script type="text/javascript" src="js/jquery.rss-3.3.0.js"> </script> + <script type="text/javascript" src="js/jquery-3.4.1.@JS@"> </script> + <script type="text/javascript" src="js/moment-2.24.0.@JS@"> </script> + <script type="text/javascript" src="js/jquery.rss-3.3.0.@JS@"> </script>
<script type="text/javascript"> <!-- diff --git a/docs/page.xsl b/docs/page.xsl index 65ddeb2bb7..bf78103df3 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -99,7 +99,7 @@ <meta name="description" content="libvirt, virtualization, virtualization API"/> <xsl:apply-templates select="/html:html/html:head/*" mode="content"/>
- <script type="text/javascript" src="{$href_base}js/main.js"> + <script type="text/javascript" src="{$href_base}js/main.{$js}"> <xsl:comment>// forces non-empty element</xsl:comment> </script> </head> diff --git a/docs/site.xsl b/docs/site.xsl index c9d41f2c93..fb9c503993 100644 --- a/docs/site.xsl +++ b/docs/site.xsl @@ -28,6 +28,7 @@ <xsl:apply-templates select="." mode="page"> <xsl:with-param name="pagename" select="$pagename"/> <xsl:with-param name="timestamp" select="$timestamp"/> + <xsl:with-param name="js" select="$js"/> </xsl:apply-templates> </xsl:template>
diff --git a/docs/subsite.xsl b/docs/subsite.xsl index f56ac0491c..c939ed6588 100644 --- a/docs/subsite.xsl +++ b/docs/subsite.xsl @@ -18,6 +18,7 @@ <xsl:apply-templates select="." mode="page"> <xsl:with-param name="pagename" select="$pagename"/> <xsl:with-param name="timestamp" select="$timestamp"/> + <xsl:with-param name="js" select="$js"/> </xsl:apply-templates> </xsl:template>
diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4 index 0f995998c3..371acb972c 100644 --- a/m4/virt-external-programs.m4 +++ b/m4/virt-external-programs.m4 @@ -34,6 +34,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [ AC_MSG_ERROR("xsltproc is required to build libvirt") fi AC_PATH_PROG([AUGPARSE], [augparse], [/usr/bin/augparse]) + AC_PATH_PROG([UGLIFYJS], [uglifyjs], []) + AM_CONDITIONAL([HAVE_UGLIFYJS], [test "$UGLIFYJS"]) AC_PROG_MKDIR_P AC_PROG_LN_S
-- 2.21.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- libvirt.spec.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 3b5b4925fd..426756031d 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -403,6 +403,11 @@ BuildRequires: libtirpc-devel BuildRequires: firewalld-filesystem %endif +# For JavaScript minimization +%if 0%{?fedora} +BuildRequires: uglify-js +%endif + Provides: bundled(gnulib) %description -- 2.21.0

On 19 Jun 2019, at 14:41, Andrea Bolognani <abologna@redhat.com> wrote:
We're carrying around embedded copies of a few JavaScript libraries for use in our homepage, and we've been unforgivably bad at keeping them up to date. Address that.
While doing so, replace the minified version of each library with its non-minified counterpart so that libvirt.git and release archives will include the actual source code for them, rather than what is basically the JavaScript equivalent of binary blobs.
Note that I consider this to be merely a stop-gap measure until we start generating the blog roll, the only part of the libvirt website that uses these libraries, on the server side and finally drop them entirely. I don't have cycles to dedicate to that effort at the moment though, and this is better than leaving the situation unchanged for who knows how much longer.
Since the diffs are kinda big and honestly just not very interesting, I've snipped them liberally; the unabridged version of this series can be fetched with
$ git fetch https://github.com/andreabolognani/libvirt js
Changes from [v2]:
* import non-minified libraries and minify them at build time.
Changes from [v1]:
* drop libraries instead of updating them.
[v2] https://www.redhat.com/archives/libvir-list/2019-June/msg00611.html [v1] https://www.redhat.com/archives/libvir-list/2019-June/msg00551.html
Andrea Bolognani (5): docs: Update jQuery docs: Update Moment.js docs: Update jquery.rss docs: Perform JavaScript minimization at build time spec: Require uglifyjs for RPM build
In the spec file, why do you BuildRequire uglify-js only on Fedora? Does that mean that if you build elsewhere, you may end up with a build that minifies or not depending on whether uglifyjs is in path or not?
.gitignore | 1 + docs/Makefile.am | 37 +- docs/index.html.in | 6 +- docs/js/jquery-3.1.1.min.js | 4 - docs/js/jquery-3.4.1.js | 10598 +++++++++++++++++++++++++++++++++ docs/js/jquery.rss-3.3.0.js | 333 ++ docs/js/jquery.rss.min.js | 11 - docs/js/moment-2.24.0.js | 4602 ++++++++++++++ docs/js/moment.min.js | 7 - docs/page.xsl | 2 +- docs/site.xsl | 1 + docs/subsite.xsl | 1 + libvirt.spec.in | 5 + m4/virt-external-programs.m4 | 2 + 14 files changed, 15578 insertions(+), 32 deletions(-) delete mode 100644 docs/js/jquery-3.1.1.min.js create mode 100644 docs/js/jquery-3.4.1.js create mode 100644 docs/js/jquery.rss-3.3.0.js delete mode 100644 docs/js/jquery.rss.min.js create mode 100644 docs/js/moment-2.24.0.js delete mode 100644 docs/js/moment.min.js
-- 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 17:00 +0200, Christophe de Dinechin wrote:
Andrea Bolognani (5): docs: Update jQuery docs: Update Moment.js docs: Update jquery.rss docs: Perform JavaScript minimization at build time spec: Require uglifyjs for RPM build
In the spec file, why do you BuildRequire uglify-js only on Fedora?
uglifyjs is not packaged for RHEL, which is the other platform our spec file targets, so we can't really BuildRequire it there.
Does that mean that if you build elsewhere, you may end up with a build that minifies or not depending on whether uglifyjs is in path or not?
Yeah. Luckily we're not going with these patches but with Martin's approach instead, which neatly sidesteps this issue :) -- Andrea Bolognani / Red Hat / Virtualization

On 20 Jun 2019, at 12:25, Andrea Bolognani <abologna@redhat.com> wrote:
On Wed, 2019-06-19 at 17:00 +0200, Christophe de Dinechin wrote:
Andrea Bolognani (5): docs: Update jQuery docs: Update Moment.js docs: Update jquery.rss docs: Perform JavaScript minimization at build time spec: Require uglifyjs for RPM build
In the spec file, why do you BuildRequire uglify-js only on Fedora?
uglifyjs is not packaged for RHEL, which is the other platform our spec file targets, so we can't really BuildRequire it there.
I was afraid that was the reason ;-)
Does that mean that if you build elsewhere, you may end up with a build that minifies or not depending on whether uglifyjs is in path or not?
Yeah. Luckily we're not going with these patches but with Martin's approach instead, which neatly sidesteps this issue :)
OK.
-- Andrea Bolognani / Red Hat / Virtualization
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Andrea Bolognani
-
Christophe de Dinechin