diff --git a/tensorboard/components/BUILD b/tensorboard/components/BUILD index 8adf959fcd..d365878ceb 100644 --- a/tensorboard/components/BUILD +++ b/tensorboard/components/BUILD @@ -26,6 +26,14 @@ tensorboard_html_binary( deps = [":tensorboard"], ) +genrule( + name = "gen_tensorboard.html", + srcs = ["tensorboard.uninlined.html"], + outs = ["tensorboard.html"], + cmd = "$(execpath //tensorboard/logo:inline_favicon) $< >$@", + tools = ["//tensorboard/logo:inline_favicon"], +) + tf_web_library( name = "analytics", srcs = [ diff --git a/tensorboard/components/tensorboard.html b/tensorboard/components/tensorboard.html deleted file mode 100644 index a81bd3bf34..0000000000 --- a/tensorboard/components/tensorboard.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - TensorBoard - - - - - - - - - - - - - - - - diff --git a/tensorboard/components/tensorboard.uninlined.html b/tensorboard/components/tensorboard.uninlined.html new file mode 100644 index 0000000000..23b16f5644 --- /dev/null +++ b/tensorboard/components/tensorboard.uninlined.html @@ -0,0 +1,38 @@ + + + + + + TensorBoard + + + + + + + + + + + + + + + + diff --git a/tensorboard/logo/BUILD b/tensorboard/logo/BUILD new file mode 100644 index 0000000000..54b0278256 --- /dev/null +++ b/tensorboard/logo/BUILD @@ -0,0 +1,16 @@ +# Description: +# TensorBoard logo files. + +package(default_visibility = ["//tensorboard:internal"]) + +licenses(["notice"]) # Apache 2.0 + +exports_files(["LICENSE"]) + +sh_binary( + name = "inline_favicon", + srcs = ["inline_favicon.sh"], + data = [ + "favicon.png", + ], +) diff --git a/tensorboard/logo/favicon.png b/tensorboard/logo/favicon.png new file mode 100644 index 0000000000..13b40ca568 Binary files /dev/null and b/tensorboard/logo/favicon.png differ diff --git a/tensorboard/logo/inline_favicon.sh b/tensorboard/logo/inline_favicon.sh new file mode 100755 index 0000000000..90cec3b6c4 --- /dev/null +++ b/tensorboard/logo/inline_favicon.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright 2020 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +set -eu + +# Replaces %TENSORBOARD_FAVICON_URI% with a data URI containing the +# image contents. +# +# Usage is like `awk(1)`: provide standard input or pass file paths as +# arguments, and expect results to stdout. + +favicon_file="$0.runfiles/org_tensorflow_tensorboard/tensorboard/logo/favicon.png" +stat -- "${favicon_file}" >/dev/null # ensure exists, with nice error text + +mime_type=image/png +base64_contents="$(base64 "${favicon_file}" | tr -d '\n')" +data_uri="data:${mime_type};base64,${base64_contents}" + +exec awk -v data_uri="${data_uri}" \ + '{ gsub("%TENSORBOARD_FAVICON_URI%", data_uri); print }' \ + "$@" diff --git a/tensorboard/webapp/BUILD b/tensorboard/webapp/BUILD index f5b1854e43..73d04615b5 100644 --- a/tensorboard/webapp/BUILD +++ b/tensorboard/webapp/BUILD @@ -114,6 +114,14 @@ tf_web_library( ], ) +genrule( + name = "gen_index.html", + srcs = ["index.uninlined.html"], + outs = ["index.html"], + cmd = "$(execpath //tensorboard/logo:inline_favicon) $< >$@", + tools = ["//tensorboard/logo:inline_favicon"], +) + # A Vulcanized html binary for the complete app (both Angular and Polymer parts) tensorboard_html_binary( name = "ng_index", diff --git a/tensorboard/webapp/index.html b/tensorboard/webapp/index.html deleted file mode 100644 index 60b1b03075..0000000000 --- a/tensorboard/webapp/index.html +++ /dev/null @@ -1,35 +0,0 @@ - - - -TensorBoard - - - - - - - - - - diff --git a/tensorboard/webapp/index.uninlined.html b/tensorboard/webapp/index.uninlined.html new file mode 100644 index 0000000000..9dc2663ad4 --- /dev/null +++ b/tensorboard/webapp/index.uninlined.html @@ -0,0 +1,29 @@ + + + +TensorBoard + + + + + + + + + +