From 649ccb033ca2b122d9f0422dac95185ca8cf9582 Mon Sep 17 00:00:00 2001 From: dozens Date: Sat, 3 Feb 2024 17:53:22 -0700 Subject: [PATCH] updates - remove zx - parameterize the date for pdf and ingredient scripts --- README.md | 23 +++++++----- bin/ingredients.sh | 24 +++++++++++++ bin/pdf.sh | 80 +++++++++++++++++++++++++++++++++++++++++ dist/2024-01-29-02.pdf | Bin 11933 -> 11934 bytes dist/2024-02-05-09.pdf | Bin 12008 -> 12016 bytes justfile | 78 ++-------------------------------------- 6 files changed, 120 insertions(+), 85 deletions(-) create mode 100644 bin/ingredients.sh create mode 100644 bin/pdf.sh diff --git a/README.md b/README.md index ce0c1d9..0974d39 100644 --- a/README.md +++ b/README.md @@ -79,18 +79,23 @@ lunch: chipotle bowl dinner: Lemon Couscous w Salmon and roast broccoli ``` -the justfile contains scrips for creating a `.rem` file for remind(1). -(from there you can use the `rem2ics` utility to create a calendar file, -or `rem2ps` to create a pdf.) -it also can create a simple pdf menu via groff and tbl. -finally it print a list of ingredients needed for next week's menu -so you can plan your shoping. +Scrips: + +- the justfile contains scrips for creating a `.rem` file for remind(1). + (from there you can use the `rem2ics` utility to create a calendar file, + or `rem2ps` to create a pdf.) + +- `/bin/pdf.sh` + will create a simple pdf menu via groff and tbl. + +- `/bin/indredients.sh` + will print a list of ingredients based on the week's menu + so you can plan your shoping. ## YOU WILL NEED - recutils - groff -- zx ## GETTING STARTED @@ -103,7 +108,7 @@ so you can plan your shoping. This might eventually become part of the backend for supervegan.neocities.org -- [ ] remove zx dep (i thought it would make dates easier in the beginning) -- [ ] parameterize the date for which the week should be calculated. +- [x] remove zx dep (i thought it would make dates easier in the beginning) +- [x] parameterize the date for which the week should be calculated. - [ ] quantity for recipe ingredient? - [ ] yield for recipe? diff --git a/bin/ingredients.sh b/bin/ingredients.sh new file mode 100644 index 0000000..5c3a369 --- /dev/null +++ b/bin/ingredients.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh +if [ $# -eq 0 ] +then + begin=$(gdate -d'Last Sun') + end=$(gdate -d'Last Sun +6 days') +else + mydate=$1 + shift + begin=`gdate -d "$mydate -$(gdate --date="$mydate" +%u) days"` + end=`gdate -d "$begin" -d'+7 days'` +fi + +recsel db/menu.rec -e "date >> '$begin'" \ +| recsel -e "date << '$end'" -P breakfast,lunch,dinner -C \ +| sort \ +| uniq \ +| xargs -I % recsel db/recipes.rec \ + -t meal \ + -j recipe \ + -e "name = '%'" \ + -G name \ + -P recipe_ingredient \ +| sort + diff --git a/bin/pdf.sh b/bin/pdf.sh new file mode 100644 index 0000000..20b7962 --- /dev/null +++ b/bin/pdf.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env sh +if [ $# -eq 0 ] +then + mydate=$(gdate) +else + mydate=$1 + shift +fi + + +firstday=`gdate -d "$mydate -$(gdate --date="$mydate" +%u) days" +%F` +lastday=`gdate -d "$firstday +6 days" +%F` +firstdayout=`gdate -d"$firstday +1 days" +%F` +lastdayout=`gdate -d"$firstday +5 days" +%d` +firstdaygroff=`gdate -d"$firstday +1 days" +"%B %_d, %Y"` +lastdaygroff=`gdate -d"$firstday +5 days" +"%B %_d, %Y"` + + +tmpl=$( +cat<> '$firstday'" \ +| recsel -e "date << '$lastday'" \ +| recsel -p breakfast \ +| recfmt '.ad l +{{breakfast}} +T};T{ +' +) +T} +.sp +Lunch;T{ +$( +recsel db/menu.rec -e "date >> '$firstday'" \ +| recsel -e "date << '$lastday'" \ +| recsel -p lunch \ +| recfmt '.ad l +{{lunch}} +T};T{ +' +) +T} +.sp +Dinner;T{ +$( +recsel db/menu.rec -e "date >> '$firstday'" \ +| recsel -e "date << '$lastday'" \ +| recsel -p dinner \ +| recfmt '.ad l +{{dinner}} +T};T{ +' +) +T} +.TE +EOF +) + + +echo "$tmpl" \ +| groff -t -ms -Tpdf -d paper=letterl -P-pletterl \ +> dist/"$firstdayout"-"$lastdayout".pdf + diff --git a/dist/2024-01-29-02.pdf b/dist/2024-01-29-02.pdf index ebaeb0e96733c1b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FixS!P7^VmbO(MKW0@S zJ6-mU#P#KOc0928UZA*gc?)a5d41&k1yd747Bi^dxaxZT(A3P`CGWawrC+T`V^`*x zD*WV5_7JWJ{9mhaoJNx^-#eo+xt#ulQk#GEuVKyEKAP2GmXjpxb793 zX+p{tq3g02KHDgAJ2A|jeah2w`{MI{HTJO^eSDTH*j^tO)yy@$=$zW*!b6*~?$6m# zpQ181;OPI2Kg*(>*zyZ!T)n!>c;U5>tkp5Gp@oT}BJ&o=+%4MLv`V(Ud~Z_}$E)np zy-jWl4OMo>9b7E9RR7$S>J^(a%C9A>{|NNha(n;NP@%(C?^85d|MPjfO`h}hqN`{1 z`j{zOz8`k={5>;%%9i=sdM%fC*4<6Nd4~OP!gJ30#T}b&iR7 zo8|P^`G=kyXt=cdafHGF$GP+VFZi`)`!v`8In{diUvIc`R+azd=}Eyp-R2E`T&r#L z-u^k*nl4)$E&o=z=`F|U^4mK!a@A$GZ*e*F@>u@&KYyO4T+}vObISb_|Aj8kyvcsd z>Fh>^#wMl)CX@Ft+rZeH|1%%b6f-qdFaQCCJOwT=!_d&g++^}~U8{OC3p6PMBO^lt zbTJcSV+=7fLjw%GW+ujl=z7gf&CSroEX^#gw;t F1pvGkiH!gN diff --git a/justfile b/justfile index b102af1..7010490 100644 --- a/justfile +++ b/justfile @@ -16,85 +16,11 @@ rem: # build menu pdf from menu.rec pdf: - #!/usr/bin/env zx - const curr = new Date() - const firstday = new Date(curr.setDate(curr.getDate() - curr.getDay())); - const lastday = new Date(curr.setDate(curr.getDate() - curr.getDay()+6)); - const options = { - year: "numeric", - month: "long", - day: "numeric", - }; - const rec = await $`recsel db/menu.rec -e ${'date >> "' + firstday + '"'}`.quiet() - .pipe($`recsel -e ${'date << "' + lastday + '"'}`).quiet() - const bkfst = await $`echo ${rec}`.quiet() - .pipe($`recsel -p breakfast`).quiet() - .pipe($`recfmt '.ad l - {{{{breakfast}} - T};T{ - '`).quiet() - const lunch = await $`echo ${rec}`.quiet() - .pipe($`recsel -p lunch`).quiet() - .pipe($`recfmt '.ad l - {{{{lunch}} - T};T{ - '`).quiet() - const dinner = await $`echo ${rec}`.quiet() - .pipe($`recsel -p dinner`).quiet() - .pipe($`recfmt '.ad l - {{{{dinner}} - T};T{ - '`).quiet() - const firstdaygroff = new Date(firstday.setDate(firstday.getDate()+1 - firstday.getDay())).toLocaleString('en-US', options); - const lastdaygroff = new Date(lastday.setDate(lastday.getDate() - lastday.getDay()+5)).toLocaleString('en-US', options); - const tmpl=` - .ce - .I - chez brun - .sp 2 - .LP - .ps 14 - ${firstdaygroff} - ${lastdaygroff} - .ps - .sp 3 - .LP - .TS - center expand tab(;); - l | lp+2 lp+2 lp+2 lp+2 lp+2 - - | - - - - - - l | l l l l l. - ;Monday;Tuesday;Wednesday;Thursday;Friday - Breakfast;T{ - ${bkfst} - T} - .sp - Lunch;T{ - ${lunch} - T} - .sp - Dinner;T{ - ${dinner} - T} - .TE` - await $`echo ${tmpl}`.quiet() - .pipe($`groff -t -ms -Tpdf -d paper=letterl -P-pletterl > dist/${new Date(firstdaygroff).toISOString().slice(0, 10)}-${new Date(lastdaygroff).toISOString().slice(8,10)}.pdf`) + sh bin/pdf.sh # build menus! menu: rem pdf # shopping list shopping: - #!/usr/bin/env sh - begin=$(gdate -d'next sun') - end=$(gdate -d'next sun +7 days') - recsel db/menu.rec -e "date >> '$begin'" \ - | recsel -e "date << '$end'" -P breakfast,lunch,dinner -C \ - | sort \ - | uniq \ - | xargs -I % recsel db/recipes.rec \ - -t meal \ - -j recipe \ - -e "name = '%'" \ - -G name \ - -P recipe_ingredient \ - | sort + sh bin/ingredients.sh