From 89cc7cbfa6db1e7c9dfb21a11da4bc44657f7521 Mon Sep 17 00:00:00 2001 From: notkoutsie Date: Wed, 12 Jul 2023 22:42:21 +0300 Subject: [PATCH] initial commit --- LICENCE | 19 +++++++++++ noter.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ writer.sh | 15 ++++++++ 3 files changed, 134 insertions(+) create mode 100644 LICENCE create mode 100755 noter.sh create mode 100755 writer.sh diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..2db9dae --- /dev/null +++ b/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2023 koutsie + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/noter.sh b/noter.sh new file mode 100755 index 0000000..4152efb --- /dev/null +++ b/noter.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# noter 1.0 - @k@layer8.space - mit + +nlog() { + local ORANGE='\033[0;33m' + local NO_COLOR='\033[0m' + echo -e "${ORANGE}[noter] | ${1} ${NO_COLOR}" +} + +generate_note_html() { + local note_date="$(date -d "$(basename "$1" .txt)" +"%B %d, %Y")" + echo "
" + echo "

$note_date

" + echo "
$(cat "$1")
" + echo "
" +} + +if [ ! -d "notes" ]; then + nlog "Error: 'notes' folder not found!" + exit 1 +fi + +notecount=$(find notes -name "*.txt" ! -empty | wc -l) + +# Create HTML file +output_file="notes.html" +echo " + + + $notecount notes | noter + + + + + + + + + + +

notes

" >"$output_file" + +# loop for every note in notes +nlog "generating page..." +for file in $(ls -r notes/*.txt); do + nlog "processing: $file" + if [ -f "$file" ] && [ -s "$file" ]; then + generate_note_html "$file" >>"$output_file" + fi +done + +# bottom navigation +echo "" >>"$output_file" +echo "
Last Updated: $(date +"%Y-%m-%d %H:%M:%S")
" >>"$output_file" + +echo "
+ +" >>"$output_file" + +nlog "Done, please see: $output_file." diff --git a/writer.sh b/writer.sh new file mode 100755 index 0000000..300e411 --- /dev/null +++ b/writer.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# writer 1.0 - @k@layer8.space - mit + +nlog() { + local ORANGE='\033[0;33m' + local NO_COLOR='\033[0m' + echo -e "${ORANGE}[noter] | ${1} ${NO_COLOR}" +} + +mkdir -p notes +current_date=$(date +%Y-%m-%d) +nlog "opening note notes/$current_time.txt" +filename="notes/${current_date}.txt" +nano "$filename" +./noter.sh