diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f80111a..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "noter"] - path = noter - url = https://code.criminallycute.fi/siina/noter diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4af2300 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: write publish + +write: + ./noter/writer.sh public + +publish: + ssh siina.monster "cd /var/www/siina.monster && git pull" diff --git a/README.md b/README.md index c21e3ad..78d81c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # siina.monster -Writing notes is done via `./noter/writer.sh public` to ensure html ends up in `./public/`, which is a publicly served directory. +Writing notes is done via `make write` and updating the live site is through `make publish`. + +To do both, simply use `make`. diff --git a/noter b/noter deleted file mode 160000 index 5ec3c61..0000000 --- a/noter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ec3c6130c3bcf27208873f12fb7311a464bf6ef diff --git a/noter/LICENCE b/noter/LICENCE new file mode 100644 index 0000000..2db9dae --- /dev/null +++ b/noter/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/README.md b/noter/README.md new file mode 100644 index 0000000..9c3b588 --- /dev/null +++ b/noter/README.md @@ -0,0 +1,7 @@ +a simple note taking system, that also generates weboages with rss feeds! +made with bash. + +### see noter.sh for generation time options +### place your notes onto a foldier named "notes" in the directory noter.sh is in! + +example of what a page looks like: https://k0.tel/ \ No newline at end of file diff --git a/noter/config.sh b/noter/config.sh new file mode 100644 index 0000000..9c3f777 --- /dev/null +++ b/noter/config.sh @@ -0,0 +1,100 @@ +showgenerator="true" +backtotop="true" +lastupdated="true" +#rssfeed="true" + +site_title="koutsie's telenotes" +site_description="thoughts about mainly computers... maybe recipes and cats too?" +site_link="https://k0.tel/" +publish_dir="." + +# Put CSS between <>"$output_file" + fi +} + +givefavicon() { + local file_path="$1" + + if [ -f "$file_path" ]; then + local base64_data="$(base64 -w 0 "$file_path")" + echo "data:image/png;base64,$base64_data" + fi +} + +generate_note_html() { + # NOTE TO SELF: Figure out parsing html blocks (ie: ) so that we can apply styles for whole + # elements instead of doing what we're doing right now... + local note_date="$(date -d "$(basename "$1" .txt)" +"%B %d, %Y")" + for img in $(grep -oP '(?<=" + echo "
" + if [ "$2" = true ]; then + echo "

$(date -d "$(basename "$1" .txt)" +"%Y")

" + fi + echo "

$note_date

" + echo "$(cat "$1")
" + echo "
" +} + +generate_top_year_bar() { + local years=$(find notes -name "*.txt" ! -empty | cut -d'/' -f2 | cut -d'-' -f1 | sort -u | tac) + local 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+="$year" + done + top_bar+="

" + echo "$top_bar" +} + + +# this took way too long but fuck it +# im faster than Google at getting a +# feed going goddamit! +generate_rss_feed() { + nlog "generating rss feed" + local rss_file="feed.xml" + local rss_pubdate=$(date -u +"%a, %d %b %Y %H:%M:%S GMT") + + xml_escape() { + local content="$1" + sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' <<< "$content" + } + + # im sorry for these crimes against humanity + echo " + + + $(xml_escape "$site_title") + $site_link + $(xml_escape "$site_description") + $rss_pubdate + $rss_pubdate + https://cyber.harvard.edu/rss/rss.html + noter" >"$rss_file" + + # this works, don't touch. + for file in $(find notes -name '*.txt' -type f -print0 | sort -zr | xargs -0); do + if [ -f "$file" ] && [ -s "$file" ]; then + nlog "$file" + local note_date=$(date -d "$(basename "$file" .txt)" +"%a, %d %b %Y %H:%M:%S GMT") + local note_link="$rss_link#$(basename "$file" .txt)" + local note_title=$(basename "$file" .txt) + local note_description=$(head -n 1 "$file") + # Currently we use the first line of the note as the description + # This could be improved uppon by using a selector or something to grab + # the title for example from a h1 or something as (at least I) tend to + # use those when i type posts. + + echo " + $(xml_escape "$note_title") + $note_link + $(xml_escape "$note_description") + $note_date + " >>"$rss_file" + fi + done + + echo " + " >>"$rss_file" + + nlog "rss feed generated, please remember to move it too with the site: $rss_file" +} + +# why is this stray here, im too afraid to move it +# godspeed notecount... +notecount=$(find notes -name "*.txt" ! -empty | wc -l) + +if [ ! -d "${publish_dir}" ]; then + nlog "Creating ${publish_dir}" + mkdir -p "${publish_dir}" +fi +# Create HTML file +output_file="${publish_dir}/index.html" +echo " + + + + $notecount notes | noter + + + + + + + + + + + +
+

$site_title


+
fedi | rss | criminally cute
" >"$output_file" +generate_top_year_bar >>"$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 + +# generate page's rss feed +[[ $rssfeed == true ]] && generate_rss_feed + +# bottom navigation +nlog "applying settings" +checksetting "
generated with noter
" "$showgenerator" +checksetting "" "$backtotop" +checksetting "
last Updated: $(date +"%Y-%m-%d %H:%M:%S")
" "$lastupdated" + + +echo "
+ +" >>"$output_file" + +nlog "Done, please see: $output_file." diff --git a/noter/writer.sh b/noter/writer.sh new file mode 100755 index 0000000..8125088 --- /dev/null +++ b/noter/writer.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# writer 1.2 - @k@layer8.space - mit + +# Use the assigned editor, if any, else use nano +[[ ${EDITOR:-"unset"} == "unset" ]] && EDITOR=nano + +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" +$EDITOR "$filename" + +# Get writer's location in case executed elsewhere +noter_dir=$(dirname "$0") + +# Override publish dir if passed as cli arg +[[ ! -z "$1" ]] && publish_dir="$1" +"$noter_dir/noter.sh" "${publish_dir}" diff --git a/public/index.html b/public/index.html index 8c4c350..7c36ac8 100644 --- a/public/index.html +++ b/public/index.html @@ -10,7 +10,7 @@ - +