From 313e9c873705c43d40f1c4a6a6c931d1be228ffb Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Thu, 1 Feb 2024 13:54:36 +0100 Subject: [PATCH] Update generate_text.sh script The generate_text.sh script has been modified with the following changes: - Updated the variable name 'markdown_file' to 'html_file' to reflect the change in the file format from Markdown to HTML. - Modified the HTML structure to create a formatted table for the handout, enhancing readability and presentation. - Added inline CSS styling to the HTML file to improve the table layout and appearance. These changes improve the generate_text.sh script by switching from Markdown to HTML for better presentation and readability of the handout. Additionally, the HTML table is now more structured and visually appealing. The commit also includes the removal of the previous notification-related code, which was commented out and not in use. The goal is to enhance the script's functionality and improve the presentation of the generated handout in HTML format. --- generate_text.sh | 63 ++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/generate_text.sh b/generate_text.sh index 51586ba..3e95149 100755 --- a/generate_text.sh +++ b/generate_text.sh @@ -9,7 +9,7 @@ ####################################### text_dir="/root/iobroker_scripts/general/.text" -markdown_file="$text_dir/handout.md" +html_file="$text_dir/handout.html" all=("date" "time") # Add more elements as needed @@ -62,41 +62,46 @@ generate_text() { # Call the generate_text function generate_text -# Create Markdown file -echo "## Handout:" > $markdown_file -echo "| Deutsch | Español |" >> $markdown_file -echo "| ------- | ------- |" >> $markdown_file +# Create HTML file +echo "" > "$html_file" +echo "" >> "$html_file" +echo "" >> "$html_file" +echo "Handout" >> "$html_file" +echo "" >> "$html_file" +echo "" >> "$html_file" +echo "" >> "$html_file" +echo "

Handout:

" >> "$html_file" +echo "" >> "$html_file" +echo "" >> "$html_file" for component in "${all[@]}"; do - german_output=$(cat $text_dir/${component}_de.txt) - spanish_output=$(cat $text_dir/${component}_es.txt) - echo "| $german_output | $spanish_output |" >> $markdown_file + echo "processing: $component" + german_output=$(cat "$text_dir/${component}_de.txt") + spanish_output=$(cat "$text_dir/${component}_es.txt") + echo "" >> "$html_file" done +echo "
DeutschEspañol
$german_output$spanish_output
" >> "$html_file" +echo "" >> "$html_file" +echo "" >> "$html_file" + # Transfer files to A72 scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/data/scripts/ -# Send Notification to A72 with handout.md file -curl_command="curl -u 'Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu' \ - -H 'Priority:High' \ - -T $markdown_file \ - -H 'Filename: handout.md' \ - -d $'notification_date: Heute ist Dienstag, der 30. Januar 2024.\n" - -for component in "${all[@]}"; do - curl_command+="${component}:\n" - curl_command+="$(cat $text_dir/${component}_de.txt)\n" - curl_command+="$(cat $text_dir/${component}_es.txt)\n" -done - -curl_command="${curl_command%\\n}" # Remove the trailing newline -curl_command+="\n'" - -curl_command+=" https://ntfy.michaelis.digital/ioBroker" - -echo "curl_command: $curl_command" -eval "$curl_command" # Execute the constructed curl command - # Display Markdown file content cat $markdown_file