diff --git a/Makefile b/Makefile index a1d79a1..d5ba539 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,46 @@ # Generate my website out of org-mode/gemini files # # maybe check https://themattchan.com/blog/2017-02-28-make-site-generator.html +# From https://github.com/fcanas/bake/blob/master/Makefile +# Finally https://www.arsouyes.org/blog/2017/10_Static_website/ -source := src -output := _site -sources := $(shell find $(source) -name '*.org') -htmls := $(patsubst %.org,%.html,$(subst $(source),$(output),$(sources))) +all: allatend +SRC_DIR ?= src +DST_DIR ?= _site +SRC_RAW_FILES := $(shell find $(SRC_DIR) -type f) +DST_RAW_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES)) +ALL += $(DST_RAW_FILES) -assetssources := $(shell find $(source) -type f ! -path '*.org') -assets := $(subst $(source),$(output),$(assetssources)) +$(DST_DIR)/% : $(SRC_DIR)/% + mkdir -p "$(dir $@)" + cp "$<" "$@" -all: $(htmls) $(assets) -$(output)/%.css: $(source)/%.css - mkdir -p $(shell dirname $@) - cp $< $@ +EXT := .org +SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)") +DST_PANDOC_FILES ?= $(subst $(EXT),.html, \ + $(subst $(SRC_DIR),$(DST_DIR), \ + $(SRC_PANDOC_FILES))) -# # recipe for converting an org-mode file into html using Pandoc -# $(output)/%.html: $(source)/%.org -# mkdir -p $(shell dirname $@) -# pandoc \ -# --from org \ -# --to html5 \ -# --css=/css/y.css \ -# --toc \ -# -s \ -# --standalone \ -# $< \ -# -o $@ +ALL += $(DST_PANDOC_FILES) -.PHONY: clean + +TEMPLATE ?= templates/post.html +CSS = /css/y.css +PANDOC := pandoc \ + -c $(CSS) \ + --template=$(TEMPLATE) \ + --from org \ + --to html5 \ + --standalone + + +$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(TEMPLATE) + mkdir -p $(dir $@) + $(PANDOC) $< \ + --output $@ + +allatend: $(ALL) clean: - rm -rf $(output)/* + rm -rf $(DST_DIR)/* diff --git a/engine/mkrss.sh b/engine/mkrss.sh index f964ee5..01383f0 100755 --- a/engine/mkrss.sh +++ b/engine/mkrss.sh @@ -19,7 +19,7 @@ rssauthor="yann@esposito.host (Yann Esposito)" rssimgurl="https://her.esy.fun/img/FlatAvatar.png" # HTML Accessors (similar to CSS accessors) -dateaccessor='.article-date' +dateaccessor='.yyydate' contentaccessor='#content' # title and keyword shouldn't be changed titleaccessor='title' @@ -27,11 +27,12 @@ keywordsaccessor='meta[name=keywords]::attr(content)' formatdate() { # format the date for RSS - local d=$1 + local d="$1" + # echo "DEBUG DATE: $d" >&2 LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z' } -finddate(){ < $1 hxselect -c $dateaccessor } +finddate(){ < $1 hxselect -c $dateaccessor | sed 's/\[//g;s/\]//g;s/ .*$//' } findtitle(){ < $1 hxselect -c $titleaccessor } getcontent(){ < $1 hxselect $contentaccessor | \ diff --git a/engine/optim-classes.sh b/engine/optim-classes.sh index 2b5d0e7..ad16dda 100755 --- a/engine/optim-classes.sh +++ b/engine/optim-classes.sh @@ -16,7 +16,7 @@ retrieve_classes_in_css () { classes=( $( {retrieve_classes_in_html; retrieve_classes_in_css}| \ egrep "^CLASS: [^ ]*$" |\ sort -u | \ - awk 'length($2)>2 && $2 !~ /(web-file-size|article-date|example|src)/ {print length($2),$2}'|\ + awk 'length($2)>2 && $2 !~ /(gzwebfilesize|webfilesize|yyydate|example|src)/ {print length($2),$2}'|\ sort -rn | \ awk '{print $2}') ) diff --git a/engine/update-file-size.sh b/engine/update-file-size.sh index c366b3b..d12d4de 100755 --- a/engine/update-file-size.sh +++ b/engine/update-file-size.sh @@ -21,7 +21,7 @@ type -a filelist if (($#>0)); then filelist=( $* ) else - filelist=( $webdir/**/*.html(.) ) + filelist=( $webdir/*/*.html(.) $webdir/posts/*.html ) fi for fic in $filelist; do @@ -73,6 +73,6 @@ for fic in $filelist; do gzsizeinfos="$gzsizeinfos)" fi print -- $sizeinfos - perl -pi -e 's#()[^<]*()#$1'"$sizeinfos"'$2#;s#()[^<]*()#$1'"$gzsizeinfos"'$2#' $fic + perl -pi -e 's#()[^<]*()#$1'"$sizeinfos"'$2#;s#()[^<]*()#$1'"$gzsizeinfos"'$2#' $fic done rm -rf $tmpdir diff --git a/src/css/fonts/SIL Open Font License.txt b/src/css/fonts/SIL_Open_Font_License.txt similarity index 100% rename from src/css/fonts/SIL Open Font License.txt rename to src/css/fonts/SIL_Open_Font_License.txt diff --git a/templates/post.html b/templates/post.html new file mode 100644 index 0000000..d3a8cc2 --- /dev/null +++ b/templates/post.html @@ -0,0 +1,62 @@ + + + + + + $title$ + + + + + + + + +
+
+
+
+
+
+
+

$title$

+
+ $date$ on + + $author$'s blog +
+
+ $description$ +
+
+
+
+ $body$ +
+ => This article is also available on gemini +
+
+
+ +
+
+
+ + diff --git a/templates/post.mustache b/templates/post.mustache index c0f5587..c9c42b8 100644 --- a/templates/post.mustache +++ b/templates/post.mustache @@ -3,10 +3,10 @@ - {{title}} - - - + $title$ + + + @@ -18,21 +18,21 @@

{{title}}

- on + on - {{author}}'s blog - + $author$'s blog - source - gmi - pdf -
- {{description}} + $description$
- {{{body}}} + $body$
=> This article is also available on gemini