From 37b0a263bfb44a358c810348554ac7bfdb3745d4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 28 Jan 2020 11:14:15 +0100 Subject: [PATCH] luci-base: add L.media() URL construction helper Signed-off-by: Jo-Philipp Wich (cherry picked from commit b60b4790d1b1b8d52657c0c9ba91da86d0b8a28d) --- .../htdocs/luci-static/resources/luci.js | 22 +++++++++++++++++++ modules/luci-base/luasrc/view/header.htm | 1 + 2 files changed, 23 insertions(+) diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 808ab0c5c..b281da5e5 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -1748,6 +1748,28 @@ return this.path(this.env.resource, arguments); }, + /** + * Construct an URL path relative to the media resource path of the + * LuCI ui (usually `/luci-static/$theme_name`). + * + * The resulting URL is guaranteed to only contain the characters + * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well + * as `/` for the path separator. + * + * @instance + * @memberof LuCI + * + * @param {string[]} [parts] + * An array of parts to join into an URL path. Parts may contain + * slashes and any of the other characters mentioned above. + * + * @return {string} + * Returns the resulting URL path. + */ + media: function() { + return this.path(this.env.media, arguments); + }, + /** * Return the complete URL path to the current view. * diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm index 1ef0e5b01..08911c7f5 100644 --- a/modules/luci-base/luasrc/view/header.htm +++ b/modules/luci-base/luasrc/view/header.htm @@ -18,6 +18,7 @@