From nobody Mon Feb 9 14:14:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560948226; cv=none; d=zoho.com; s=zohoarc; b=UBH63BVK8U6JK898hldy7t4AJwZ5Fj5hrcEZl8yI0wO+5msPU2RIAj7yO/D7GUSC48aUunA9ys9caO6O2a3+7lnS1ryLAFmvIITDaPyXkeNvhRLZaABT0DLBkRIljUX7di2nnY5pLmEL1ESi5nIERbwqKHwvILVYCNdB7KibmGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560948226; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PGZsnpfZmDxwZRXW/v8Q0q8fO+8XT+MF4C5Vmjm3UbY=; b=HG5K5h9cr69SM/QR0FDnb+OcctQBLKqf0vaH05GaVZ8kAwt3l7Pc6w8uA52bKfpGEdeKaP6o1+TBZgMiVHCWpBgkH2L07oy2djZqPIEUgQk+trO5254iLIOxkH/NHmj15p956bCg/G8dkX/hgBO4buWQHx1HGQjLXXr54m4ZlFA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560948226524697.4838933789997; Wed, 19 Jun 2019 05:43:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A02D63B71F; Wed, 19 Jun 2019 12:43:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7347660166; Wed, 19 Jun 2019 12:43:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2C71A19729; Wed, 19 Jun 2019 12:43:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5JCfD3d029559 for ; Wed, 19 Jun 2019 08:41:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44CBE5C221; Wed, 19 Jun 2019 12:41:13 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3A405C220 for ; Wed, 19 Jun 2019 12:41:12 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 14:41:04 +0200 Message-Id: <20190619124105.32309-5-abologna@redhat.com> In-Reply-To: <20190619124105.32309-1-abologna@redhat.com> References: <20190619124105.32309-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 4/5] docs: Perform JavaScript minimization at build time X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Jun 2019 12:43:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Christophe de Dinechin --- .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 +=3D \ convert -rotate 90 $< $@ =20 %.html.tmp: %.html.in site.xsl subsite.xsl page.xsl \ - $(acl_generated) + $(acl_generated) $(minified_javascript) $(AM_V_GEN)name=3D`echo $@ | sed -e 's/.tmp//'`; \ dir=3D`dirname $@` ; \ if test "$$dir" =3D "."; \ @@ -270,24 +271,47 @@ MAINTAINERCLEANFILES +=3D \ 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; } =20 %.html: %.html.tmp $(AM_V_GEN)$(XMLLINT) --nonet --format $< > $(srcdir)/$@ \ || { rm $(srcdir)/$@ && exit 1; } =20 + +if HAVE_UGLIFYJS +JS =3D min.js +minified_javascript =3D $(javascript:%.js=3D%.min.js) +EXTRA_DIST +=3D $(minified_javascript) +MAINTAINERCLEANFILES +=3D $(minified_javascript) + +%.min.js: %.js + $(AM_V_GEN)$(UGLIFYJS) -o $@ $< +else ! HAVE_UGLIFYJS +JS =3D js +minified_javascript =3D $(javascript) + +dist-hook: + echo "uglifyjs is required to make dist." >&2 + exit 1 +endif ! HAVE_UGLIFYJS + $(apihtml_generated): html/index.html =20 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 =20 $(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhel= pxsl) $(AM_V_GEN)$(XSLTPROC) --stringparam timestamp $(timestamp) \ + --stringparam js "$(JS)" \ --nonet -o $(srcdir)/devhelp/ \ $(top_srcdir)/docs/devhelp/devhelp.xsl $(srcdir)/libvirt-api.xml =20 @@ -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 @@ - - -