Skip to content

Commit

Permalink
add Python skript for DSGVO stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MarAlder committed Aug 10, 2023
1 parent 5c85d42 commit 0b4bfce
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- name: Build Documentation
run: msbuild /p:Configuration=Release documentation\Cpacs_doc_project.shfbproj

- name: Add dsgvo footer to html docs
run: python .\documentation\Cpacs_doc_dsgvo.py

- name: Package HTML Docs
run: 7z a -tzip .\build\doc\htmlDocs.zip .\build\doc\*

Expand Down
41 changes: 41 additions & 0 deletions documentation/Cpacs_doc_dsgvo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import re

# ==============================================================================================
# DSGVO
# This script modifies the CPACS documentation so that it contains a dsgvo-conform footer
# ==============================================================================================

def replace_page_footer(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()

pattern = r'<div id="pageFooter" class="pageFooter"><p>.*?</p>'
replacement = '''
<div id="pageFooter" class="pageFooter"><p>
&copy; 2023 <a href="https://www.DLR.de">Deutsches Zentrum für Luft- und Raumfahrt e.V.</a>&nbsp;&nbsp;&nbsp;
<a href="https://www.dlr.de/sl">Institute of System Architectures in Aeronautics</a></li>&nbsp;&nbsp;&nbsp;
<a href="https://www.cpacs.de/pages/imprint.html">Imprint</a></li>&nbsp;&nbsp;&nbsp;
<a href="https://www.cpacs.de/pages/privacy.html">Privacy</a></li>
</p>
'''

content = re.sub(pattern, replacement, content, flags=re.DOTALL)

with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)

def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.html') or file.endswith('.htm'):
file_path = os.path.join(root, file)
replace_page_footer(file_path)
print(f"Processed: {file_path}")


if __name__ == '__main__':

target_directory = "./build/doc/"

process_directory(target_directory)

0 comments on commit 0b4bfce

Please sign in to comment.