From: Michael Tremer Date: Sun, 4 Jun 2023 11:14:51 +0000 (+0000) Subject: web: Build function to easily compose URLs X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ddfb3889ec35fd6cb3edc40be15a48693c81eb0;p=pbs.git web: Build function to easily compose URLs Signed-off-by: Michael Tremer --- diff --git a/src/templates/builds/index.html b/src/templates/builds/index.html index 8f49d5e5..00cc0167 100644 --- a/src/templates/builds/index.html +++ b/src/templates/builds/index.html @@ -35,11 +35,12 @@
diff --git a/src/web/__init__.py b/src/web/__init__.py index 5d5ce96e..f0c68cd8 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -99,6 +99,7 @@ class Application(tornado.web.Application): "extract_hostname" : self.extract_hostname, "format_time" : self.format_time, "group" : self.group, + "make_url" : self.make_url, }, xsrf_cookies = True, ) @@ -290,3 +291,12 @@ class Application(tornado.web.Application): def group(self, handler, *args, **kwargs): return misc.group(*args, **kwargs) + + def make_url(self, handler, url, **kwargs): + # Format any query arguments and append them to the URL + if kwargs: + args = urllib.parse.urlencode(kwargs) + + url = "%s?%s" % (url, args) + + return url