[PATCH yocto-autobuilder-helper v7] Add a banner on the old documentation docs.


Abongwa Amahnui Bonalais
 

Also added a command in the run-docs-build file to run the python script once in the extracted tarball directory.

Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@...>
---
docs_fix_all_html_css.py | 79 ++++++++++++++++++++++++++++++++++++++++
run-docs-build | 2 +
2 files changed, 81 insertions(+)
create mode 100755 docs_fix_all_html_css.py

diff --git a/docs_fix_all_html_css.py b/docs_fix_all_html_css.py
new file mode 100755
index 0000000..7693b04
--- /dev/null
+++ b/docs_fix_all_html_css.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+#Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@...>
+#
+#
+# function to append to the content of a html file below the body tag
+#
+#
+import os
+
+
+html_content = '''
+<div id="outdated-warning">This document is outdated, you should select the <a href="https://docs.yoctoproject.org/">latest release version</a> in this series.</div>
+<div xml:lang="en" class="body" lang="en">
+'''
+last_div = '''
+</div>
+
+'''
+
+css_replacement_content = '''
+
+ font-family: Verdana, Sans, sans-serif;
+
+ /*min-width: 640px;*/
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ color: #333;
+ overflow-x: hidden;
+ }
+
+ /*added books too*/
+.body{
+margin: 0 auto;
+min-width: 640px;
+padding: 0 5em 5em 5em;
+}
+/* added the id below to make the banner show and be fixed*/
+#outdated-warning{
+text-align: center;
+background-color: rgb(255, 186, 186);
+color: rgb(106, 14, 14);
+padding: 0.5em 0;
+width: 100%;
+position: fixed;
+top: 0;
+
+
+'''
+
+def loop_through_html_directories(dir):
+ for dirpath, dirnames, filenames in os.walk(dir):
+ # loop through all files in the directory
+ for filename in filenames:
+ # check if the file is an html file
+ if filename.endswith('.html'):
+ # open the html file in read mode
+ with open(os.path.join(dirpath, filename), 'r', encoding="ISO-8859-1") as f:
+ # read the content of the html file
+ current_content = f.read()
+ # open the html file in write mode
+ with open(os.path.join(dirpath, filename), 'w') as f:
+ # write the content of the html file
+ f.write(current_content.replace('<body>', '<body>' + html_content))
+ f.write(current_content.replace('</body>', last_div + '</body>'))
+ if filename.endswith('.css'):
+ # open the css file in read mode
+ with open(os.path.join(dirpath, filename), 'r', encoding="ISO-8859-1") as f:
+ # read the content of the css file
+ css_content = f.read()
+ # open the css file in write mode
+ with open(os.path.join(dirpath, filename), 'w') as f:
+ # write the content of the css file
+ f.write(css_content.replace(css_content[css_content.find('body {'):css_content.find('}'[0])], 'body {' + css_replacement_content ))
+loop_through_html_directories('.')
+
diff --git a/run-docs-build b/run-docs-build
index ecc5332..307ac19 100755
--- a/run-docs-build
+++ b/run-docs-build
@@ -37,6 +37,8 @@ cd $outputdir
echo Extracing old content from archive
tar -xJf $docbookarchive

+$scriptdir/docs_fix_all_html_css.py
+
cd $bbdocs
mkdir $outputdir/bitbake

--
2.25.1

Join yocto@lists.yoctoproject.org to automatically receive all group messages.