From c7d0d07c249d62ebb7add0162ce05e899c84f060 Mon Sep 17 00:00:00 2001 From: dozens Date: Sat, 14 Aug 2021 20:47:17 -0600 Subject: [PATCH] feat: toad.md v0.0.1 --- 00001.md | 2 - Makefile | 2 +- bin/rss.sh | 18 +++++ bin/toad.md | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++ feed.xml | 91 ++++++++++++------------ rss.sh | 16 ----- src/00001.txt | 5 ++ 7 files changed, 261 insertions(+), 64 deletions(-) create mode 100755 bin/rss.sh create mode 100644 bin/toad.md delete mode 100755 rss.sh create mode 100644 src/00001.txt diff --git a/00001.md b/00001.md index bdf2302..e392884 100644 --- a/00001.md +++ b/00001.md @@ -4,13 +4,11 @@ (@)(@) {0,0} (~~~~) ./)_) (>vv<) " " - \ ya see, some people go real fast and other people they go real slow ``` - ``` (@)(@) {0,0} -- Hoo? (~~~~) ./)_) diff --git a/Makefile b/Makefile index 47d9143..c0ffdc0 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ default: rss.sh - ./rss.sh + ./bin/rss.sh diff --git a/bin/rss.sh b/bin/rss.sh new file mode 100755 index 0000000..cc49a63 --- /dev/null +++ b/bin/rss.sh @@ -0,0 +1,18 @@ +#bin/sh +echo "It's Pro Toad and Superb Owl" > feed.xml +echo "https://git.tilde.town/dozens/protoadandsuperbowlIt's Pro Toad and Superb Owl!/bin/sh" >> feed.xml + + +for f in $(find . -type f -iname '*.md' ! -name 'README.md' | sed 's/\.\///'); do + echo " + $f + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/$f + $(stat -f "%m%t%Sm %N" $f | cut -f2 | cut -f1-4 -d ' ') + > feed.xml + pandoc $f >> feed.xml + echo "]]> + " >> feed.xml +done + +echo '' >> feed.xml + diff --git a/bin/toad.md b/bin/toad.md new file mode 100644 index 0000000..30933a7 --- /dev/null +++ b/bin/toad.md @@ -0,0 +1,191 @@ +# toad.md + +> the pro toad and superb owl comic generator + +## about + +This program reads a script file and interpolates its contents with some ascii art, and then writes the result to stdout. + +The end goal is automating the creation of [Pro Toad and Superb Owl][ptso] comics. + +[ptso]: https://git.tilde.town/dozens/protoadandsuperbowl + +## usage + + $ retro toad.md path/to/script.txt > comic.txt + +## components + +the components of the program are: + +1. IO - open the text file, read it line by line, close the file, write to stdout + +2. input parser - there are 2 line types in the script file: + + - a text line, and + - a separator line: a special `---` line to separate panels. + +3. comic builder - build the first panel, the second panel (no input needed, just output tanel 2), and the 3rd panel (repeat steps needed for 1st panel) + +4. panel builder - for as long as art array has length, and as long as the current input line has length or until the input parser hits the separator line or the end of the file, call the line builder with the next line of the art array (if there is one) and the input line. + + If the input line has no length, and the next line is not the separator, have the line builder insert a "blank line" and get a new input line. + +5. line builder - given two strings, build a new string containing the first, and appending words from the second up to a total of ~80 cols. + +## argument validation + +print a helpful message if the script is called without an argument + +TODO: is `script:get-argument` an array? check to see if length equal zero + + 'ARGS s:put nl + script:get-argument a:length n:put + +## panels + +okay let's go + +There are two panels: one where toad speaks, and one where owl speaks. Let's save each to an array, one string per line. + +Here's toad (panels 1 & 3): + +~~~ +'toad var +{ +'_(@)(@)_____{0,0}__ +'_(~~~~)____./)_)___ +'_(>vv<)______"_"___ +'___________________ +'_____\_____________ +} !toad +~~~ + +Here's owl (panel 2): + +~~~ +'owl var +{ +'_(@)(@)_____{0,0}__--_Hoo? +'_(~~~~)____./)_)__________ +'_(>vv<)______"_"__________ +} !owl +~~~ + +Also here are some code fences, because we'll need those too: + +~~~ +:fences '``` s:put nl ; +~~~ + +## Input/output + +open the file for reading and save the file handle to `file` + +save the file fize. we'll use this to check for end of file. + +~~~ +'handle var +'size var + +#0 script:get-argument +file:open-for-reading !handle !size + +:get-line @handle file:read-line ; +~~~ + +## Input Parser + +TODO: this isn't tested or used anywhere yet. + +~~~ +{{ + :end-of-file? (-) @handle file:tell @size gteq? ; + :separator? (m-f) '--- eq? ; +---reveal--- + :end-of-section? (-f) separator? end-of-file? or ; +}} +~~~ + +## Line wrapping + +Here's a line wrapping module. + +~~~ +{{ + #0 'displayed var-n + #40 'wrap-at var-n + :wrap? dup @displayed + @wrap-at gt? ; + :display [ nl !displayed ] [ displayed v:inc-by ] choose s:put sp ; +---reveal--- + :s:put-wrapped (s-) ASCII:SPACE s:tokenize + [ dup s:length wrap? display ] a:for-each + #0 !displayed ; +}} +~~~ + +src: + + + + +## Panel 1 + +print out the first panel + +ascii art: + +~~~ +fences +@toad [ s:put nl ] a:for-each +~~~ + +text: + +~~~ +[ + get-line + dup s:put-wrapped + '--- s:eq? not + dup [ nl nl ] if +] while +nl fences nl nl +~~~ + +TODO: don't print `---` line. + + +## Panel 2 + +~~~ +fences +@owl [ s:put nl ] a:for-each +fences nl nl +~~~ + +## Panel 3 + +print the ascii: + +~~~ +fences +@toad [ s:put nl ] a:for-each +~~~ + +print the text: + +~~~ +[ + get-line dup s:put-wrapped + #0 + dup [ nl nl ] if +] while +nl fences +drop +~~~ + +TODO: loop till end of file + +## Conclusion + +That's all! That's the end diff --git a/feed.xml b/feed.xml index 3f38a93..262239e 100644 --- a/feed.xml +++ b/feed.xml @@ -1,9 +1,10 @@ It's Pro Toad and Superb Owl +https://git.tilde.town/dozens/protoadandsuperbowlIt's Pro Toad and Superb Owl!/bin/sh -00004.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00004.md -Feb 11 17:48:03 2021 -00004.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00004.md + Feb 11 17:48:03 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -25,12 +26,12 @@
        Yep! I guess you could say it
        was a SUPER BOWL PROTO AD!
]]>
-
+ -00001.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00001.md -Feb 10 12:25:55 2021 -00001.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00001.md + Feb 10 12:25:55 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -50,12 +51,12 @@
        yeah that's the real root cause
        of most workplace conflict
]]>
-
+ -00005.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00005.md -Feb 12 10:34:52 2021 -00005.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00005.md + Feb 12 10:34:52 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -78,12 +79,12 @@
        I can see some flowers and leaves
        and listen to the birds and stuff.
]]>
-
+ -00008.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00008.md -Feb 26 08:26:45 2021 -00008.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00008.md + Feb 26 08:26:45 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}  There was a sense of euphoria
  (~~~~)    ./)_)   while we were in flow, like we
@@ -108,12 +109,12 @@
   bros invited me to "do some lines" and at this point I
   can't remember if it was code or coke.
]]>
-
+ -00009.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00009.md -Apr 17 11:44:45 2021 -00009.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00009.md + Apr 17 11:44:45 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}  So I picked up a book in the 
  (~~~~)    ./)_)   middle of this epic fantasy series.
@@ -140,12 +141,12 @@
   if there's one thing this world needs more of, it's mother
   fucking dragons beating the shit out of nazis.
]]>
-
+ -00002.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00002.md -Feb 11 16:43:59 2021 -00002.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00002.md + Feb 11 16:43:59 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -166,12 +167,12 @@
        job either. But they keep giving me
        YAML and I keep ENGINEERING it!
]]>
-
+ -00006.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00006.md -Feb 13 14:11:29 2021 -00006.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00006.md + Feb 13 14:11:29 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}  Is there even such a thing
  (~~~~)    ./)_)   as "mainstream" anymore? I
@@ -203,12 +204,12 @@
  small STREAMS and countercultures as there
  are individual people.
]]>
-
+ -00007.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00007.md -Feb 26 08:11:25 2021 -00007.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00007.md + Feb 26 08:11:25 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -224,12 +225,12 @@
  (~~~~)    ./)_)
  (>vv<)      " "
]]>
-
+ -00003.md -https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00003.md -Feb 11 17:01:15 2021 -00003.md + https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/00003.md + Feb 11 17:01:15 2021 + Pro Toad and Superb Owl
 (@)(@)     {0,0}
  (~~~~)    ./)_)
@@ -247,5 +248,5 @@
      \
        Yeah, me neither.
]]>
-
+
diff --git a/rss.sh b/rss.sh deleted file mode 100755 index c4d7072..0000000 --- a/rss.sh +++ /dev/null @@ -1,16 +0,0 @@ -#bin/sh -echo "It's Pro Toad and Superb Owl" > feed.xml - -for f in $(find . -type f -iname '*.md' ! -name 'README.md' | sed 's/\.\///'); do - echo "" >> feed.xml - echo "$f" >> feed.xml - echo "https://git.tilde.town/dozens/protoadandsuperbowl/raw/branch/master/$f" >> feed.xml - echo "$(stat -f "%m%t%Sm %N" $f | cut -f2 | cut -f1-4 -d ' ')" >> feed.xml - echo "> feed.xml - pandoc $f >> feed.xml - echo "]]>" >> feed.xml - echo "" >> feed.xml -done - -echo '' >> feed.xml - diff --git a/src/00001.txt b/src/00001.txt new file mode 100644 index 0000000..37e2dca --- /dev/null +++ b/src/00001.txt @@ -0,0 +1,5 @@ +ya see, some people go real fast ya see, some people go real fast ya see, some people go real fast ya see, some people go real fast +and other people they go real slow +--- +yeah that's the real root cause of most workplace conflict +ayup