You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2022/05/10 09:47:16 UTC
[ozone] branch master updated: HDDS-6666. Make Hugo markdown image syntax add responsive image class (#3364)
This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new d4d8e3c4e9 HDDS-6666. Make Hugo markdown image syntax add responsive image class (#3364)
d4d8e3c4e9 is described below
commit d4d8e3c4e9588036075e0eb52115455d82e03ddb
Author: Siyao Meng <50...@users.noreply.github.com>
AuthorDate: Tue May 10 02:47:11 2022 -0700
HDDS-6666. Make Hugo markdown image syntax add responsive image class (#3364)
---
hadoop-hdds/docs/dev-support/bin/generate-site.sh | 12 +----
.../docs/dev-support/bin/make_images_responsive.py | 57 ----------------------
.../_markup/render-image.html} | 3 +-
3 files changed, 2 insertions(+), 70 deletions(-)
diff --git a/hadoop-hdds/docs/dev-support/bin/generate-site.sh b/hadoop-hdds/docs/dev-support/bin/generate-site.sh
index 1556f95df0..3d7baa84e2 100755
--- a/hadoop-hdds/docs/dev-support/bin/generate-site.sh
+++ b/hadoop-hdds/docs/dev-support/bin/generate-site.sh
@@ -31,18 +31,8 @@ if git -C $(pwd) status >& /dev/null; then
ENABLE_GIT_INFO="--enableGitInfo"
fi
-# Copy docs files to a temporary directory inside target
-# for pre-processing the markdown files.
-TMPDIR="$DOCDIR/target/tmp"
-mkdir -p "$TMPDIR"
-rsync -a --exclude="target" --exclude="public" "$DOCDIR/" "$TMPDIR"
-
-# Replace all markdown images with a hugo shortcode to make them responsive.
-python3 $DIR/make_images_responsive.py $TMPDIR
-
DESTDIR="$DOCDIR/target/classes/docs"
mkdir -p "$DESTDIR"
-# We want to build the processed files inside the $DOCDIR/target/tmp
-cd "$TMPDIR"
+cd "$DOCDIR"
hugo "${ENABLE_GIT_INFO}" -d "$DESTDIR" "$@"
cd -
diff --git a/hadoop-hdds/docs/dev-support/bin/make_images_responsive.py b/hadoop-hdds/docs/dev-support/bin/make_images_responsive.py
deleted file mode 100644
index 4c945eb29d..0000000000
--- a/hadoop-hdds/docs/dev-support/bin/make_images_responsive.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-
-import sys
-import os
-import re
-import logging
-
-LOGLEVEL = os.environ.get('LOGLEVEL', 'WARNING').upper()
-logging.basicConfig(level=LOGLEVEL)
-
-# The first argument to the script is the directory where the documentation is
-# stored.
-docs_directory = os.path.expanduser(sys.argv[1])
-content_directory = os.path.join(docs_directory, 'content')
-
-for root, subdirs, files in os.walk(docs_directory):
- for filename in files:
- # We only want to modify markdown files.
- if filename.endswith('.md'):
- file_path = os.path.join(root, filename)
-
- new_file_content = []
-
- with open(file_path, 'r', encoding='utf-8') as f:
- for line in f:
- # If the line contains the image tag, we need to replace it
- if re.search(re.compile("^!\[(.*?)\]\((.*?)\)"), line):
- logging.debug(
- f'file {filename} (full path: {file_path})')
- logging.debug(f"found markdown image: {line}")
-
- line_replacement = line.replace(
- '![', '{{< image alt="').replace('](', '" src="').replace(')', '">}}')
-
- logging.debug(
- f"replaced with shortcode: {line_replacement}")
-
- new_file_content.append(line_replacement)
-
- else:
- new_file_content.append(line)
-
- with open(file_path, 'w', encoding='utf-8') as f:
- f.writelines(new_file_content)
diff --git a/hadoop-hdds/docs/themes/ozonedoc/layouts/shortcodes/image.html b/hadoop-hdds/docs/themes/ozonedoc/layouts/_default/_markup/render-image.html
similarity index 84%
rename from hadoop-hdds/docs/themes/ozonedoc/layouts/shortcodes/image.html
rename to hadoop-hdds/docs/themes/ozonedoc/layouts/_default/_markup/render-image.html
index 2d143e7014..93bc4f739c 100644
--- a/hadoop-hdds/docs/themes/ozonedoc/layouts/shortcodes/image.html
+++ b/hadoop-hdds/docs/themes/ozonedoc/layouts/_default/_markup/render-image.html
@@ -15,5 +15,4 @@
limitations under the License.
-->
-<!-- shortcode to easily scale images according to page width-->
-<img src='{{ .Get "src" }}' alt='{{ .Get "alt" }}' class="img-responsive"/>
\ No newline at end of file
+<img src="{{ .Destination | safeURL }}" alt='{{ .Text }}' {{ with .Title}} title="{{ . }}"{{ end }} class="img-responsive" />
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org