From 715c87d4f2abe24234c3c4d6a549887ffab1b36a Mon Sep 17 00:00:00 2001 From: Siina Mashek Date: Sat, 17 Feb 2024 18:16:39 +0200 Subject: [PATCH] re-adding noter as a submodule --- .gitmodules | 3 + README.md | 2 + noter | 1 + noter/LICENCE | 19 ----- noter/README.md | 7 -- noter/config.sh | 100 ------------------------- noter/noter.sh | 192 ------------------------------------------------ noter/writer.sh | 24 ------ 8 files changed, 6 insertions(+), 342 deletions(-) create mode 100644 .gitmodules create mode 160000 noter delete mode 100644 noter/LICENCE delete mode 100644 noter/README.md delete mode 100644 noter/config.sh delete mode 100755 noter/noter.sh delete mode 100755 noter/writer.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f80111a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "noter"] + path = noter + url = https://code.criminallycute.fi/siina/noter diff --git a/README.md b/README.md index 78d81c2..bebde21 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # siina.monster +Copy `noter/config.example.sh` to `noter/config.sh` and edit. This file will not be version controlled. + 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 new file mode 160000 index 0000000..0024f62 --- /dev/null +++ b/noter @@ -0,0 +1 @@ +Subproject commit 0024f62f27c26139650defce61b437e9ef03982f diff --git a/noter/LICENCE b/noter/LICENCE deleted file mode 100644 index 2db9dae..0000000 --- a/noter/LICENCE +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 9c3b588..0000000 --- a/noter/README.md +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index c3a7327..0000000 --- a/noter/config.sh +++ /dev/null @@ -1,100 +0,0 @@ -showgenerator="true" -backtotop="true" -lastupdated="true" -rssfeed="true" - -site_title="siina.monster" -site_description="thoughts and things and stuff" -site_link="https://siina.monster/" -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="$publish_dir/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 | $site_title - - - - - - - - - - - -
-

$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 deleted file mode 100755 index 8125088..0000000 --- a/noter/writer.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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}"