From 1f9da3846f8e78cac52ea5a4c3840dfc391dca53 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Thu, 29 Jul 2021 00:10:21 -0400 Subject: [PATCH] reading time --- README.md | 2 +- modules/md | 2 +- modules/md-test | 10 ++++++++++ modules/readingtime | 14 ++++++++++++++ pinopress | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 modules/readingtime diff --git a/README.md b/README.md index b4e5b41..5b725d6 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ these have not been implemented yet, but modules are shellscripts that are calle here are some potential ideas for modules: - [ ] syntax highlight for code blocks -- [ ] blog average time to read +- [x] blog average time to read ## pinopress flavored markdown diff --git a/modules/md b/modules/md index 7831638..0decfa6 100755 --- a/modules/md +++ b/modules/md @@ -92,7 +92,7 @@ s/^# (.*)/

\1<\/h1>/ $!d } x -/(^$|^\s+$)/ !{ +/^\s*$/ !{ s/^/\n

/ s/$/\n<\/p>/ } diff --git a/modules/md-test b/modules/md-test index 3f20b0c..fc00240 100644 --- a/modules/md-test +++ b/modules/md-test @@ -69,3 +69,13 @@ code block ``` +hello, + +Many of you are probably feeling a little sad. This is ok. Sadness is a normal human emotion. I encourage you to watch the movie Inside Out - one of the best movies of all time. + +Try not to take your performance in this course as a barometer by which you should measure yourself. This is true for any course at any time but is especially true for this particular term where both the school and the students are learning to adjust to this new format. +There is also the written part to to this midterm which will likely boost everyone's average (if previous Crowdmark assessments are to be believed). As it stands at the moment, the grades so far are not out of line with previous years. +Specific to this course is the fact that the second half is generally easier to understand than the first half so hopefully this will give everyone a moral if not quantitative boost. +At the end of it all try hard to look at your effort and be proud of the work you put in. University in general requires a big adjustment and unfortunately for everyone starting new this year will likely require a few more adjustments over the coming years. One of the biggest, most important and rarely talked about benefits of university as a whole is just a general growth of the individual regardless of what discipline they ultimately decided to study. +A reflection for you. +- Math 137 diff --git a/modules/readingtime b/modules/readingtime new file mode 100755 index 0000000..7983314 --- /dev/null +++ b/modules/readingtime @@ -0,0 +1,14 @@ +#!/bin/sh + +## module for getting estimated time to read an article +## usage: +## readingtime [file] +## exports: +## READING_TIME in minutes + +## config vars +wordsPerMinute=250 + +# first clean special symbols and lines with whitespace +wordcount=`sed -e 's/[^A-Za-z0-9 ]//g' -e '/^\s*$/d' "$1" | wc -w` +export READING_TIME=$(expr $(expr $wordcount + $wordsPerMinute) / $wordsPerMinute) diff --git a/pinopress b/pinopress index 3623b2f..c12c485 100755 --- a/pinopress +++ b/pinopress @@ -73,6 +73,7 @@ $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md cat $(TEMPLATE_DIR)/head.template.html > "$@" # module pipeline starts here ./$(MODULE_DIR)/md "$^" >> "$@" + . ./$(MODULE_DIR)/readingtime "$^" # module pipeline ends here cat $(TEMPLATE_DIR)/foot.template.html >> "$@" envsubst < "$@" | sponge "$@" -- 2.20.1