You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/01/13 08:51:59 UTC
[buildstream] branch master updated: doc/badges.py: Adding staticly
generated HTML page for automated redirects.
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/buildstream.git
The following commit(s) were added to refs/heads/master by this push:
new aeb7a8d doc/badges.py: Adding staticly generated HTML page for automated redirects.
aeb7a8d is described below
commit aeb7a8def10079ff5cd6ece76c26ccd233b2f9df
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Wed Jan 13 17:46:58 2021 +0900
doc/badges.py: Adding staticly generated HTML page for automated redirects.
In addition to publishing the latest badges with every commit to master,
we now also generate a release.html and snapshot.html file which is simply
a redirect to the latest release and snapshot url on github.
This allows us better control of the URL which the badges link to,
now the README.rst redirects the latest release/snapshot when clicking
on the corresponding badges automatically with the following snippet:
.. image:: https://docs.buildstream.build/master/_static/release.svg
:target: https://docs.buildstream.build/master/_static/release.html
.. image:: https://docs.buildstream.build/master/_static/snapshot.svg
:target: https://docs.buildstream.build/master/_static/snapshot.html
Changes:
- README.rst: Use the new link targets for the release/snapshot badges
- doc/badges.py: Support generating the redirect html files
- doc/Makefile: Generate the redirect html files during the build
---
README.rst | 4 ++--
doc/Makefile | 4 +++-
doc/badges.py | 38 ++++++++++++++++++++++++++++++++------
3 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/README.rst b/README.rst
index 59fb142..627e933 100644
--- a/README.rst
+++ b/README.rst
@@ -2,10 +2,10 @@ About
-----
.. image:: https://docs.buildstream.build/master/_static/release.svg
- :target: https://gitlab.com/BuildStream/buildstream/commits/bst-1
+ :target: https://docs.buildstream.build/master/_static/release.html
.. image:: https://docs.buildstream.build/master/_static/snapshot.svg
- :target: https://gitlab.com/BuildStream/buildstream/commits/master
+ :target: https://docs.buildstream.build/master/_static/snapshot.html
.. image:: https://gitlab.com/BuildStream/buildstream/badges/master/pipeline.svg
:target: https://gitlab.com/BuildStream/buildstream/commits/master
diff --git a/doc/Makefile b/doc/Makefile
index 43b0cd0..d71be8e 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -126,7 +126,7 @@ sessions-clean:
############################################################
-# Generate release badges #
+# Generate release badges and their redirecting html pages #
############################################################
badges-clean:
rm -rf source/badges
@@ -135,6 +135,8 @@ badges:
mkdir -p source/badges
$(CURDIR)/badges.py > source/badges/snapshot.svg
$(CURDIR)/badges.py --release > source/badges/release.svg
+ $(CURDIR)/badges.py --redirect > source/badges/snapshot.html
+ $(CURDIR)/badges.py --redirect --release > source/badges/release.html
############################################################
diff --git a/doc/badges.py b/doc/badges.py
index 794b5cb..0b3ae4e 100755
--- a/doc/badges.py
+++ b/doc/badges.py
@@ -67,6 +67,23 @@ BADGE_TEMPLATE = """
</svg>
"""
+# The redirect template is for a static html page hosted in the
+# latest docs which always redirects you to the latest snapshot
+# or release on github.
+#
+REDIRECT_TEMPLATE = """
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Latest {badge_name}</title>
+ <meta http-equiv="refresh" content="0;url={url_target}"/>
+ </head>
+ <body>
+ <p></p>
+ </body>
+</html>
+"""
+
URL_FORMAT = 'https://github.com/apache/buildstream/releases/tag/{version}'
RELEASE_COLOR = '#0040FF'
SNAPSHOT_COLOR = '#FF8000'
@@ -123,7 +140,9 @@ def guess_version(release):
@click.command(short_help="Generate the version badges")
@click.option('--release', is_flag=True, default=False,
help="Whether to generate the badge for the release version")
-def generate_badges(release):
+@click.option('--redirect', is_flag=True, default=False,
+ help="Whether to generate the redirect html file")
+def generate_badges(release, redirect):
"""Generate the version badge svg files
"""
major, minor, micro = guess_version(release)
@@ -137,11 +156,18 @@ def generate_badges(release):
version = '{major}.{minor}.{micro}'.format(major=major, minor=minor, micro=micro)
url_target = URL_FORMAT.format(version=version)
- badge = BADGE_TEMPLATE.format(badge_name=badge_name,
- version=version,
- color=color,
- url_target=url_target)
- click.echo(badge, nl=False)
+
+ if redirect:
+ template = REDIRECT_TEMPLATE
+ else:
+ template = BADGE_TEMPLATE
+
+ output = template.format(badge_name=badge_name,
+ version=version,
+ color=color,
+ url_target=url_target)
+
+ click.echo(output, nl=False)
return 0