2023-07-12 22:42:21 +03:00
|
|
|
#!/bin/bash
|
2023-08-13 03:28:52 +03:00
|
|
|
# noter 1.1.0 - "the lazy update" - @k@layer8.space - mit
|
2023-07-14 21:56:28 +03:00
|
|
|
|
2023-07-12 22:42:21 +03:00
|
|
|
nlog() {
|
2023-08-13 03:28:52 +03:00
|
|
|
local ORANGE='\033[0;33m'
|
|
|
|
local NO_COLOR='\033[0m'
|
|
|
|
echo -e "${ORANGE}[noter] | ${1} ${NO_COLOR}"
|
2023-07-14 21:56:28 +03:00
|
|
|
}
|
|
|
|
|
2023-08-13 03:28:52 +03:00
|
|
|
if [ ! -d "notes" ]; then
|
|
|
|
nlog "Error: 'notes' folder not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-07-14 21:56:28 +03:00
|
|
|
|
2023-07-12 22:42:21 +03:00
|
|
|
generate_note_html() {
|
2023-08-13 03:28:52 +03:00
|
|
|
local note_date="$(date -d "$(basename "$1" .txt)" +"%B %d, %Y")"
|
|
|
|
for img in $(grep -oP '(?<=<img src=").*?(?=")' "$1"); do
|
|
|
|
sed -i "s|<img src=\"$img\"|<img src=\"$img\" loading=\"lazy\"|g" "$1"
|
|
|
|
done
|
|
|
|
echo "<a name='$(basename "$1" .txt)'></a>"
|
|
|
|
echo "<div class='note'>"
|
|
|
|
if [ "$2" = true ]; then
|
|
|
|
echo "<h3><a href='#$(date -d "$(basename "$1" .txt)" +"%Y")'>$(date -d "$(basename "$1" .txt)" +"%Y")</a></h3>"
|
|
|
|
fi
|
|
|
|
echo "<h4><a href='$(basename "$1" .txt).html'>$note_date</a></h4>"
|
|
|
|
echo "<pre>$(cat "$1")</pre>"
|
|
|
|
echo "</div>"
|
2023-07-12 22:42:21 +03:00
|
|
|
}
|
|
|
|
|
2023-08-13 03:28:52 +03:00
|
|
|
generate_top_year_bar() {
|
|
|
|
local years=$(find notes -name "*.txt" ! -empty | cut -d'/' -f2 | cut -d'-' -f1 | sort -u | tac)
|
|
|
|
local top_bar="<center><div class='top-bar'>"
|
|
|
|
local first_year=true
|
|
|
|
for year in $years; do
|
|
|
|
if [ "$first_year" = false ]; then
|
|
|
|
top_bar+=" | "
|
|
|
|
else
|
|
|
|
first_year=false
|
|
|
|
fi
|
|
|
|
top_bar+="<a href='#$(find notes -name "$year-*.txt" ! -empty | sort -n | head -n1 | cut -d'/' -f2 | cut -d'.' -f1)'>$year</a>"
|
|
|
|
done
|
|
|
|
top_bar+="</div></center><br>"
|
|
|
|
echo "$top_bar"
|
|
|
|
}
|
2023-07-12 22:42:21 +03:00
|
|
|
|
|
|
|
notecount=$(find notes -name "*.txt" ! -empty | wc -l)
|
|
|
|
|
|
|
|
# Create HTML file
|
|
|
|
output_file="notes.html"
|
|
|
|
echo "<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2023-08-13 03:28:52 +03:00
|
|
|
<meta charset='utf-8'>
|
2023-07-12 22:42:21 +03:00
|
|
|
<title>$notecount notes | noter</title>
|
2023-08-13 03:28:52 +03:00
|
|
|
<meta property='og:title' content='koutsies telenotes' />
|
|
|
|
<meta property='og:description' content='thoughts about mainly computers... maybe recipes and cats too?' />
|
2023-07-12 22:42:21 +03:00
|
|
|
<meta property='og:type' content='website' />
|
|
|
|
<meta property='og:generator' content='noter' />
|
2023-08-13 03:28:52 +03:00
|
|
|
<!-- those who seek, shall see - but thy shall be prepared... -->
|
|
|
|
<link rel='icon' type='image/png' href='data:image/png;base64,AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAKBEAAJ4EAAAwMAAAAQAgAGgmAADGFQAAKAAAABAAAAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUK50I1OwdpVVsna9U7J2vVSxdpRQrnQjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFSydqZVsnf/VbJ3/1Wyd/9Vsnf/VLJ2pgAAAAAAAAAAAAAAAAAAAAA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
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: 100%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
.container {
|
|
|
|
max-width: 800px;
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
.note {
|
|
|
|
background-color: #181717;
|
|
|
|
padding: 10px;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
h1 {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
h3 {
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
pre {
|
|
|
|
color: #fff;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
}
|
|
|
|
.back-to-top {
|
|
|
|
text-align: right;
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
.last-updated {
|
|
|
|
text-align: right;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
color: #888;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
2023-08-13 03:28:52 +03:00
|
|
|
a:link, a:visited, a:hover, a:active {
|
|
|
|
color: #ff6600;
|
|
|
|
text-decoration: underline;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
2023-07-12 22:42:21 +03:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class='container'><h1>notes</h1>" >"$output_file"
|
2023-08-13 03:28:52 +03:00
|
|
|
generate_top_year_bar >>"$output_file"
|
2023-07-12 22:42:21 +03:00
|
|
|
# loop for every note in notes
|
|
|
|
nlog "generating page..."
|
|
|
|
for file in $(ls -r notes/*.txt); do
|
2023-08-13 03:28:52 +03:00
|
|
|
nlog "processing: $file"
|
|
|
|
if [ -f "$file" ] && [ -s "$file" ]; then
|
|
|
|
generate_note_html "$file" >>"$output_file"
|
|
|
|
fi
|
2023-07-12 22:42:21 +03:00
|
|
|
done
|
|
|
|
|
2023-08-13 03:28:52 +03:00
|
|
|
# bottom navigation
|
|
|
|
echo "<div class='generated-with'>generated with <a href='https://git.sr.ht/~koutsie/noter'>noter</a></div>" >>"$output_file"
|
|
|
|
echo "<div class='back-to-top'><a href='#'>Back to Top</a></div>" >>"$output_file"
|
|
|
|
echo "<div class='last-updated'>last Updated: $(date +"%Y-%m-%d %H:%M:%S")</div>" >>"$output_file"
|
2023-07-12 22:42:21 +03:00
|
|
|
|
|
|
|
echo "</div>
|
|
|
|
</body>
|
|
|
|
</html>" >>"$output_file"
|
|
|
|
|
|
|
|
nlog "Done, please see: $output_file."
|