Compare commits

...

6 Commits

Author SHA1 Message Date
nytpu 8f89ccd9c1 added gemlog archive link 2020-10-14 10:01:28 -06:00
nytpu 534e7a625e
Merge branch 'personal-config' of https://tildegit.org/nytpu/gemlog.sh into personal-config 2020-10-14 10:00:31 -06:00
nytpu fb4f1d8550 a 2020-10-14 09:58:22 -06:00
nytpu eca7580a72 f 2020-10-14 09:55:00 -06:00
nytpu 76a7052972 changed feed_web_url 2020-10-14 09:47:20 -06:00
nytpu b65180d651 updated to add separators between years and months 2020-10-14 09:46:41 -06:00
2 changed files with 40 additions and 9 deletions

View File

@ -3,9 +3,13 @@
Utility for writing and managing gemini logs (gemlogs) and atom feeds without
needing a cgi script.
After 0.2.0, I'm no longer having my personal configuration on master, but as
I'm replacing it with placeholder data, it may have a conflict for this one
upgrade. Sorry for the inconvenience.
Dependencies:
other than `toot` you really should have all these installed if you're on linux.
* bash and all its goodies (duh)
* `bash` and all its goodies (duh)
* `perl`
* `date`
* `tr`

View File

@ -28,14 +28,24 @@ make_globals() {
gemlog_feed="atom.xml" # filename of the atom feed
number_of_feed_articles="50" # maximum number of posts added to atom feed
feed_base_url="https://nytpu.com/files/" # base url that the feed is hosted at
feed_base_url="gemini://nytpu.com/gemlog/" # base url that the feed is hosted at
feed_web_url="https://nytpu.com/files/" # base url that the feed is hosted at on the web
index="index.gmi" # main page of gemlog, not recommended to change
use_year_divider=true # separate posts from different years with a heading?
# these 2 are exclusive, and use_month_divider_nl takes priority if both are set
use_month_divider_nl=true # separate posts from different months with a newline?
use_month_divider_hd=false # separate posts from different months with a heading?
gemlog_sh_link="https://tildegit.org/nytpu/gemlog.sh" # link to the utility, you should change this if you've made substantial non-configuration changes
# don't change these
gemlog_sh_link="https://tildegit.org/nytpu/gemlog.sh" # link to the utility, you should change this if you modified it substantially
date_format_8601="+%Y-%m-%dT%H:%M:%S%:z" # *formal* ISO-8601 format including time zone
date_format_8601_timeless="+%Y-%m-%dT12:00:00%:z" # *formal* ISO-8601 format including time zone
date_format_8601_timeless="+%Y-%m-%dT12:00:00%:z" # *formal* ISO-8601 format with fixed preset time
monthnames=( "invalid" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" )
}
get_post_title() {
@ -69,7 +79,7 @@ make_atom() {
EOF
n=0
while IFS='' read -r i; do
((n >= number_of_feed_articles)) && break
((n >= $number_of_feed_articles)) && break
printf "\n <entry>\n <title>"
get_post_title "$i" | tr -d '\n'
printf "</title>\n <id>$global_url${i#'./'}</id>\n"
@ -108,12 +118,29 @@ build_entries() {
_│ TECH GEMLOG │ by nytpu
(_/_______________/
```
EOF
curyear=""
curmonth=""
while IFS='' read -r i; do
post=$(basename $i)
title=$(get_post_title "$i")
pubdate=$(echo $i | perl -ne '/^(\d{4}-\d{2}-\d{2}).*/; print $1')
newcuryear=$(echo $i | perl -ne '/^(\d{4})-\d{2}-\d{2}.*/; print $1')
newcurmonth=$(echo $i | perl -ne '/^\d{4}-(\d{2})-\d{2}.*/; print $1')
if [ "$newcuryear" != "$curyear" ] && $use_year_divider; then
printf "\n\n## $newcuryear\n"
curyear="$newcuryear"
fi
if [ "$newcurmonth" != "$curmonth" ]; then
if $use_month_divider_nl; then
printf "\n"
elif $use_month_divider_hd; then
printf "\n### ${monthnames[${newcurmonth#0}]}\n\n"
fi
curmonth="$newcurmonth"
fi
printf "=> $global_url$post $pubdate$title\n"
done < <(ls -r [[:digit:]]*.gmi)
@ -127,9 +154,9 @@ EOF
=> /gemlog/old/ click here to view an archive of my old gemlog
=> $feed_base_url$gemlog_feed this gemlog has an atom feed at: $feed_base_url$gemlog_feed
=> gemini://nytpu.com/gemlog/$gemlog_feed or through gemini at: gemini://nytpu.com/gemlog/$gemlog_feed
=> $feed_web_url$gemlog_feed or through the web at: $feed_web_url$gemlog_feed
=> https://tildegit.org/nytpu/gemlog.sh generated with gemlog.sh
=> $gemlog_sh_link generated with gemlog.sh
EOF
} 3>&1 >"$indexfile"
@ -145,7 +172,7 @@ toot() {
then
echo "tooting..."
# change this if you want the toot to have different content
printf "new gemlog post: ${title}\n\ngemini://nytpu.com/gemlog/${filename}" | toot post
printf "new gemlog post: ${title}\n\n${global_url}${filename}\n" | toot post
fi
}