re-adding noter as a submodule
This commit is contained in:
parent
384f289335
commit
715c87d4f2
8 changed files with 6 additions and 342 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "noter"]
|
||||||
|
path = noter
|
||||||
|
url = https://code.criminallycute.fi/siina/noter
|
|
@ -1,5 +1,7 @@
|
||||||
# siina.monster
|
# 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`.
|
Writing notes is done via `make write` and updating the live site is through `make publish`.
|
||||||
|
|
||||||
To do both, simply use `make`.
|
To do both, simply use `make`.
|
||||||
|
|
1
noter
Submodule
1
noter
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 0024f62f27c26139650defce61b437e9ef03982f
|
|
@ -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.
|
|
|
@ -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/
|
|
100
noter/config.sh
100
noter/config.sh
|
@ -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 <<EOF and EOF
|
|
||||||
site_css=$(cat <<EOF
|
|
||||||
/* font by https://www.1001fonts.com/users/junkohanhero/ */
|
|
||||||
@font-face { font-family: header; src: url(scratch_x_black.ttf); }
|
|
||||||
body {
|
|
||||||
background-color: #0f0f0f;
|
|
||||||
color: #fff;
|
|
||||||
font-family: 'Arial Rounded MT', sans-serif;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
/* font legibility optimizations */
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
}
|
|
||||||
.container {
|
|
||||||
max-width: 800px;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 15px;
|
|
||||||
}
|
|
||||||
.note {
|
|
||||||
background-color: #181717;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
font-family: "header", sans-serif;
|
|
||||||
}
|
|
||||||
h3 {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
note {
|
|
||||||
color: #fff;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
color: #00ff62b5;
|
|
||||||
font-family: "Lucida Console", "Courier New", monospace;
|
|
||||||
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: 13px;
|
|
||||||
}
|
|
||||||
a:link, a:visited, a:hover, a:active {
|
|
||||||
color: #B2A4D4;
|
|
||||||
font-style: normal;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
/* le tableee */
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border: 1px solid #fff;
|
|
||||||
border-radius: 8px;
|
|
||||||
overflow: hidden;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
padding: 10px 15px;
|
|
||||||
border: 1px solid #fff;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
background: #1f1f1f;
|
|
||||||
text-align: left;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
background: #0b0b0b;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)
|
|
192
noter/noter.sh
192
noter/noter.sh
|
@ -1,192 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# noter 1.3.0 - "nice configs" - @k@layer8.space - mit
|
|
||||||
|
|
||||||
# a pretty nifty little logging utility!
|
|
||||||
nlog() {
|
|
||||||
local ORANGE='\033[0;33m'
|
|
||||||
local NO_COLOR='\033[0m'
|
|
||||||
local calling_function=${FUNCNAME[1]}
|
|
||||||
|
|
||||||
echo -e "${ORANGE}[noter] ${calling_function} | ${1} ${NO_COLOR}"
|
|
||||||
}
|
|
||||||
|
|
||||||
nlog "sourcing config.sh"
|
|
||||||
noter_dir=$(dirname "$0")
|
|
||||||
source $noter_dir/config.sh
|
|
||||||
|
|
||||||
# Override publish dir if passed as cli arg
|
|
||||||
[[ ! -z "$1" ]] && nlog "overriding publish_dir to $1" && publish_dir="$1"
|
|
||||||
|
|
||||||
if [ ! -d "notes" ]; then
|
|
||||||
nlog "Error: 'notes' folder not found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
checksetting() {
|
|
||||||
# Use this function to check for a setting without repetition
|
|
||||||
# Eg:
|
|
||||||
# checksetting "yourmom" "$isyourmom"
|
|
||||||
if [ "$2" = true ]; then
|
|
||||||
nlog "$1 set to $2"
|
|
||||||
echo "$1" >>"$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: <code>) 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 '(?<=<img src=").*?(?=")' "$1"); do
|
|
||||||
# Check if the loading attribute already exists
|
|
||||||
if ! grep -q "src=\"$img\" loading=\"lazy\"" "$1"; then
|
|
||||||
# Add the loading attribute if it doesn't exist
|
|
||||||
sed -i "s|<img src=\"$img\"|<img src=\"$img\" loading=\"lazy\"|g" "$1"
|
|
||||||
fi
|
|
||||||
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)'>$note_date</a></h4>"
|
|
||||||
echo "$(cat "$1")</br>"
|
|
||||||
echo "</div>"
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# 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; s/'"'"'/\'/g' <<< "$content"
|
|
||||||
}
|
|
||||||
|
|
||||||
# im sorry for these crimes against humanity
|
|
||||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
|
|
||||||
<rss version=\"2.0\">
|
|
||||||
<channel>
|
|
||||||
<title>$(xml_escape "$site_title")</title>
|
|
||||||
<link>$site_link</link>
|
|
||||||
<description>$(xml_escape "$site_description")</description>
|
|
||||||
<pubDate>$rss_pubdate</pubDate>
|
|
||||||
<lastBuildDate>$rss_pubdate</lastBuildDate>
|
|
||||||
<docs>https://cyber.harvard.edu/rss/rss.html</docs>
|
|
||||||
<generator>noter</generator>" >"$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 " <item>
|
|
||||||
<title>$(xml_escape "$note_title")</title>
|
|
||||||
<link>$note_link</link>
|
|
||||||
<description>$(xml_escape "$note_description")</description>
|
|
||||||
<pubDate>$note_date</pubDate>
|
|
||||||
</item>" >>"$rss_file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "</channel>
|
|
||||||
</rss>" >>"$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 "<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset='utf-8'>
|
|
||||||
<title>$notecount notes | $site_title</title>
|
|
||||||
<meta property='og:title' content='$site_title' />
|
|
||||||
<meta property='og:description' content='$site_description' />
|
|
||||||
<meta property='og:type' content='blog' />
|
|
||||||
<meta property='og:generator' content='noter' />
|
|
||||||
<!-- those who seek, shall see - but thy shall be prepared... -->
|
|
||||||
<link rel='icon' type='image/png' href='$(givefavicon "$favicon")'>
|
|
||||||
<link rel='alternate' type='application/atom+xml' title="rss" href='/feed.xml' />
|
|
||||||
<meta name='last-generated' content='$(date +"%Y-%m-%d %H:%M:%S")' />
|
|
||||||
<style>
|
|
||||||
$site_css
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='container'>
|
|
||||||
<h1>$site_title</h1><br>
|
|
||||||
<center> <a rel='me' href='https://social.criminallycute.fi/@siina'>fedi</a> | <a href="feed.xml">rss</a> | <a href="https://criminallycute.fi/">criminally cute</a> </center>" >"$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 "<div class='generated-with'>generated with <a href='https://code.criminallycute.fi/siina/noter'>noter</a></div>" "$showgenerator"
|
|
||||||
checksetting "<div class='back-to-top'><a href='#'>Back to Top</a></div>" "$backtotop"
|
|
||||||
checksetting "<div class='last-updated'>last Updated: $(date +"%Y-%m-%d %H:%M:%S")</div>" "$lastupdated"
|
|
||||||
|
|
||||||
|
|
||||||
echo "</div>
|
|
||||||
</body>
|
|
||||||
</html>" >>"$output_file"
|
|
||||||
|
|
||||||
nlog "Done, please see: $output_file."
|
|
|
@ -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}"
|
|
Reference in a new issue