Re: [yocto] [PATCH yocto-autobuilder-helper v4] Add a banner on the old documentation docs

2022-04-18 Thread Abongwa Amahnui Bonalais
I sent a more recent patch which takes care of the topmost element overlapping 
with the banner, puting it in a div called body and pushing it down so the 
banner remains on top.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#56799): https://lists.yoctoproject.org/g/yocto/message/56799
Mute This Topic: https://lists.yoctoproject.org/mt/90519600/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] [PATCH yocto-autobuilder-helper v4] Add a banner on the old documentation docs

2022-04-17 Thread Abongwa Amahnui Bonalais
On Sun, Apr 17, 2022 at 04:45 PM, Quentin Schulz wrote:

> 
> import glob
> glob.glob('**/*.html', recursive=True)

Hi Quentin, thanks for the review.
If I use the glob module here, I will get rid of os.walk which was suggested by 
Richard, and I have some issues implementing the glob as I am not very familiar 
with it.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#56793): https://lists.yoctoproject.org/g/yocto/message/56793
Mute This Topic: https://lists.yoctoproject.org/mt/90519600/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] [PATCH yocto-autobuilder-helper v4] Add a banner on the old documentation docs

2022-04-17 Thread Quentin Schulz
Hi Amahnui,

On April 17, 2022 10:40:13 AM GMT+02:00, Abongwa Amahnui Bonalais 
 wrote:
>Signed-off-by: Abongwa Bonalais Amahnui 
>---
> trial.py  | 32 +++
> trialstyle.py | 61 +++
> 2 files changed, 93 insertions(+)
> create mode 100644 trial.py
> create mode 100644 trialstyle.py
>
>diff --git a/trial.py b/trial.py
>new file mode 100644
>index 000..c85b16c
>--- /dev/null
>+++ b/trial.py
>@@ -0,0 +1,32 @@
>+#!usr/bin/env python3

#!/usr/bin/env python3

>+#
>+# SPDX-License-Identifier: GPL-2.0-only
>+#
>+#Author: Abongwa Bonalais Amahnui 
>+#
>+#
>+# function to append to the content of a html file below the body tag
>+#
>+#
>+import os
>+html_content = '''
>+This document is outdated, you should select the 
>https://docs.yoctoproject.org/;>latest release version in this 
>series.
>+
>+'''
>+
>+
>+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'):

All of the above cam be replaced with:
import glob
glob.glob('**/*.html', recursive=True)

C.f. https://docs.python.org/3/library/glob.html#glob.glob

>+# 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:

I assume we want the same encoding that was needed for opening the file for 
writing the file otherwise we'll have some differences won't we?

In the end I think a recursive "find" for all html files which executes sed 
could have work just fine too.

E.g.
find -name "*.html" -exec sed -i 's///' {} \;

But potato potato right now ☺️

Also, this script needs to be called somewhere.

I suggest those scripts are added to the scripts/ directory of the git repo and 
they need to be called in run-docs-build shell script otherwise they are not 
used.

Cheers,
Quentin

>+# write the content of the html file
>+f.write(current_content.replace('', '' + 
>html_content))
>+loop_through_html_directories('.')
>diff --git a/trialstyle.py b/trialstyle.py
>new file mode 100644
>index 000..a75721a
>--- /dev/null
>+++ b/trialstyle.py
>@@ -0,0 +1,61 @@
>+#!usr/bin/env python3
>+#
>+# SPDX-License-Identifier: GPL-2.0-only
>+#
>+#Author: Abongwa Bonalais Amahnui 
>+#
>+#
>+# function to append to the content of a css file below the body class
>+#
>+#
>+import os
>+
>+
>+content = '''
>+ 
>+  font-family: Verdana, Sans, sans-serif;
>+
>+  /*min-width: 640px;*/
>+  width: 100%;
>+  margin:  0;
>+  padding: 0;
>+  color: #333;
>+  overflow-x: hidden;
>+  }
>+ 
>+ /*added books too*/
>+.book{
>+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('style.css'):
>+# 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
>+   css_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(css_content.replace(css_content[css_content.find('body 
>{'):css_content.find('}'[0])], 'body {' + content ))
>+loop_through_html_directories('.')

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#56792): https://lists.yoctoproject.org/g/yocto/message/56792
Mute This Topic: https://lists.yoctoproject.org/mt/90519600/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



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

2022-04-17 Thread Abongwa Amahnui Bonalais
Signed-off-by: Abongwa Bonalais Amahnui 
---
 trial.py  | 32 +++
 trialstyle.py | 61 +++
 2 files changed, 93 insertions(+)
 create mode 100644 trial.py
 create mode 100644 trialstyle.py

diff --git a/trial.py b/trial.py
new file mode 100644
index 000..c85b16c
--- /dev/null
+++ b/trial.py
@@ -0,0 +1,32 @@
+#!usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+#Author: Abongwa Bonalais Amahnui 
+#
+#
+# function to append to the content of a html file below the body tag
+#
+#
+import os
+html_content = '''
+This document is outdated, you should select the https://docs.yoctoproject.org/;>latest release version in this 
series.
+
+'''
+
+
+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('', '' + 
html_content))
+loop_through_html_directories('.')
diff --git a/trialstyle.py b/trialstyle.py
new file mode 100644
index 000..a75721a
--- /dev/null
+++ b/trialstyle.py
@@ -0,0 +1,61 @@
+#!usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+#Author: Abongwa Bonalais Amahnui 
+#
+#
+# function to append to the content of a css file below the body class
+#
+#
+import os
+
+
+content = '''
+ 
+  font-family: Verdana, Sans, sans-serif;
+
+  /*min-width: 640px;*/
+  width: 100%;
+  margin:  0;
+  padding: 0;
+  color: #333;
+  overflow-x: hidden;
+  }
+ 
+ /*added books too*/
+.book{
+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('style.css'):
+# 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
+   css_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(css_content.replace(css_content[css_content.find('body 
{'):css_content.find('}'[0])], 'body {' + content ))
+loop_through_html_directories('.')
-- 
2.25.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#56791): https://lists.yoctoproject.org/g/yocto/message/56791
Mute This Topic: https://lists.yoctoproject.org/mt/90519600/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-