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.
This commit is contained in:
parent
382e28c481
commit
313e9c8737
@ -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 "<!DOCTYPE html>" > "$html_file"
|
||||
echo "<html>" >> "$html_file"
|
||||
echo "<head>" >> "$html_file"
|
||||
echo "<title>Handout</title>" >> "$html_file"
|
||||
echo "<style>" >> "$html_file"
|
||||
echo "table {" >> "$html_file"
|
||||
echo " border-collapse: collapse;" >> "$html_file"
|
||||
echo " width: 50%;" >> "$html_file"
|
||||
echo " margin: auto;" >> "$html_file"
|
||||
echo "}" >> "$html_file"
|
||||
echo "th, td {" >> "$html_file"
|
||||
echo " border: 1px solid black;" >> "$html_file"
|
||||
echo " padding: 8px;" >> "$html_file"
|
||||
echo " text-align: left;" >> "$html_file"
|
||||
echo "}" >> "$html_file"
|
||||
echo "th {" >> "$html_file"
|
||||
echo " background-color: #f2f2f2;" >> "$html_file"
|
||||
echo "}" >> "$html_file"
|
||||
echo "</style>" >> "$html_file"
|
||||
echo "</head>" >> "$html_file"
|
||||
echo "<body>" >> "$html_file"
|
||||
echo "<h2>Handout:</h2>" >> "$html_file"
|
||||
echo "<table>" >> "$html_file"
|
||||
echo "<tr><th>Deutsch</th><th>Español</th></tr>" >> "$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 "<tr><td>$german_output</td><td>$spanish_output</td></tr>" >> "$html_file"
|
||||
done
|
||||
|
||||
echo "</table>" >> "$html_file"
|
||||
echo "</body>" >> "$html_file"
|
||||
echo "</html>" >> "$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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user