Refactor HTML generation, improve Markdown content creation, and update notification mechanism in generate_text.sh:
- Refactored HTML file creation with Markdown content construction for clarity and conciseness. - Removed the HTML file generation block and replaced it with a Markdown content string. - Updated the notification mechanism using the constructed Markdown content and a curl command. - Display the constructed Markdown content instead of the HTML file. - Updated the file transfer destination to the A72 device's /sdcard/ directory for generate_text.sh.
This commit is contained in:
parent
0fb0ae1e48
commit
41f3b3a4d2
@ -62,49 +62,33 @@ generate_text() {
|
|||||||
# Call the generate_text function
|
# Call the generate_text function
|
||||||
generate_text
|
generate_text
|
||||||
|
|
||||||
# Create HTML file
|
# Create Markdown content
|
||||||
echo "<!DOCTYPE html>" > "$html_file"
|
markdown_content="**Handout:**
|
||||||
echo "<html>" >> "$html_file"
|
\n
|
||||||
echo "<head>" >> "$html_file"
|
| Deutsch | Español |
|
||||||
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
|
for component in "${all[@]}"; do
|
||||||
echo "processing: $component"
|
|
||||||
german_output=$(cat "$text_dir/${component}_de.txt")
|
german_output=$(cat "$text_dir/${component}_de.txt")
|
||||||
spanish_output=$(cat "$text_dir/${component}_es.txt")
|
spanish_output=$(cat "$text_dir/${component}_es.txt")
|
||||||
echo "<tr><td>$german_output</td><td>$spanish_output</td></tr>" >> "$html_file"
|
markdown_content+="\n| $german_output | $spanish_output |"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "</table>" >> "$html_file"
|
# Send Notification to A72 with Markdown content
|
||||||
echo "</body>" >> "$html_file"
|
curl_command="curl -u 'Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu' \
|
||||||
echo "</html>" >> "$html_file"
|
-H 'Priority:High' \
|
||||||
|
-d \"$markdown_content\" \
|
||||||
|
-H 'Markdown: yes' \
|
||||||
|
https://ntfy.michaelis.digital/ioBroker"
|
||||||
|
|
||||||
|
echo "curl_command: $curl_command"
|
||||||
|
eval "$curl_command" # Execute the constructed curl command
|
||||||
|
|
||||||
# Transfer files to A72
|
# Transfer files to A72
|
||||||
scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/data/scripts/
|
scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/sdcard/
|
||||||
|
|
||||||
# Display Markdown file content
|
# Display Markdown content
|
||||||
cat $markdown_file
|
echo -e "$markdown_content"
|
||||||
|
|
||||||
# Start generate_mp3.sh on A72
|
# Start generate_mp3.sh on A72
|
||||||
nohup ssh -i /root/.ssh/A72 -f root@$A72_ip '/data/scripts/generate_mp3.sh' > /root/generate_mp3.log &
|
nohup ssh -i /root/.ssh/A72 -f root@$A72_ip '/data/scripts/generate_mp3.sh' > /root/generate_mp3.log &
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user