omoidasu

a flashcard review system built on oboeru
git clone anongit@rnpnr.xyz:omoidasu.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 11e0ec90d8aa8adee41cf3d693993cf1dd221d58
Parent: 8d5cd6850cdb24b9a1884d69803bc917cc0b7e18
Author: Randy Palamar
Date:   Mon, 23 Aug 2021 19:28:07 -0600

make deck DELIM configurable

also reverse sort deck for easier reading

Diffstat:
Mdeck2data | 4+++-
Mgencard | 13+++++++++----
Mnextcardid | 7+++++--
Momoidasu | 3+++
4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/deck2data b/deck2data @@ -4,6 +4,8 @@ # takes a deck file and converts all cards to html # outputs 1 per line in the form "cardid\tfront\tback" +. ./config + usage() { echo "usage: $0 cards.deck" exit 1 @@ -14,7 +16,7 @@ usage() { deck=$(echo "$1" | cut -d '.' -f 1) while read line; do - id=$(echo "$line" | cut -f 1) + id=$(echo "$line" | cut -d $DELIM -f 1) path="$deck"/"$id" front=$(smu "$path"/front.md | tr -d '\n' | rubify | sed -e 's;src="\([^"]*\)";src="/_/'$path'/\1";g' \ diff --git a/gencard b/gencard @@ -20,12 +20,16 @@ die() { } trap die EXIT INT TERM +line=$(grep "$DELIM$2\$" $1) +[ "$line" ] && echo "$2 already in deck:" && echo "$line" && exit 1 + id=$(nextcardid "$1") time=$(date $TIMEFMT) -printf "%s\t%s\t%s\t%d\t%s\n" "$id" "$time" "$time" 0 "$2" >> "$1" +printf "%s"$DELIM"%s"$DELIM"%s"$DELIM"%d"$DELIM"%s\n" \ + "$id" "$time" "$time" 0 "$2" >> "$1" -sort "$1">|"$tmp" +sort -r "$1">|"$tmp" mv "$tmp" "$1" deck=$(echo "$1" | cut -d '.' -f 1) @@ -34,6 +38,7 @@ front=${FRONT_TEMP:-front} back=${BACK_TEMP:-back} mkdir -p $path -cp $front $back $path/ +sed s:==TARGET==:$2:g "$front" >> "$path/$front" +sed s:==TARGET==:$2:g "$back" >> "$path/$back" -$EDITOR "$path/$back" "$path/$front" +$EDITOR "$path/$back" "$path/$front" "$path/extra.html" "$1" diff --git a/nextcardid b/nextcardid @@ -1,11 +1,14 @@ #!/bin/sh +. ./config + # finds and outputs the next missing id in deck ledger [ ! -f "$1" ] && echo 0 && exit 0 -awk '{ +sort "$1" \ +| awk -F $DELIM '{ w = length($1); for (i = p + 1; i < $1; i++) { exit } -} {p = $1} END {printf "%0"w"i\n", p + 1}' $1 +} {p = $1} END {printf "%0"w"i\n", p + 1}' diff --git a/omoidasu b/omoidasu @@ -24,6 +24,9 @@ FILTER=rubify # used in config.h when compiling oboeru. backup timestamp can be anything TIMEFMT="+%Y年%m月%d日%H時%M分" +# ledger field delimiter +DELIM="\t" + # templates to use for new cards. the variables can be commented or empty # the default names will be "front" and "back" FRONT_TEMP="front.md"