summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile149
1 files changed, 149 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index acb94d9..ec33082 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,152 @@
+
+MD_CMD=npx remark --rc-path remarkrc
+# pup is from github.com/ericchiang/pup
+CATCH_CMD=pup
+HTML_MINIFIER_CMD=htmlmin
+BASE_HTML=tmp/left.htm tmp/headers.htm
+ALL_ARTICLES=$(wildcard articles/*.md)
+ALL_ARTICLES_OUT=$(ALL_ARTICLES:.md=.html)
+ALL_ARTICLES_INTRO_OUT=$(addprefix articles/tmp/,$(shell cat articles_intro_out))
+ALL_NOTES_OUT=$(addprefix notes/,$(shell cat notes/notes_out))
+ALL_NOTES_TMP=$(addprefix notes/tmp/,$(shell cat notes/notes_out))
+ALL_NOTES_TMP_OUT=$(ALL_NOTES_TMP:.html=.hml)
+ALL_NOTES_CARDS_OUT=$(ALL_NOTES_TMP:.html=_card.htm)
+
+SCRIPT_JS=s/js/main.js
+SHEET_CSS=s/css/style.css
+
+
+# Creation des articles, puis des bases et enfin de l'index
+# Les bases en premiers
+# Puis les articles
+# Et enfin index (qui possède une liste des introductions des articles)
+all: $(ALL_ARTICLES_OUT) $(BASE_HTML) index.html contact/index.html $(SHEET_CSS) $(SCRIPT_JS) $(ALL_NOTES_OUT) notes/index.html
+.PHONY: all
+
+# > Création des articles depuis le markdown
+# On compile le fichier md vers html (tmp/%.htm)
+# On rajoute les headers (tmp/%_header.htm)
+# On fini d'ajouter le squelette HTML (articles/%.html
+articles/%.html: articles/%.md $(BASE_HTML) headers.m4 articles/article.m4
+ @echo "> Création des articles"
+ mkdir -p articles/tmp
+ cat $< | $(MD_CMD) > $(addprefix articles/tmp/,$(notdir $(@:.html=.htm)))
+ m4 -D TITLE_TITLE="`echo Licornes, hérissons et renards`" headers.m4 > $(addprefix articles/tmp/,$(notdir $(basename $@)_header.htm))
+ m4 -D tmpFileNameArticle=$(addprefix articles/tmp/,$(notdir $(@:.html=.htm))) -D linkFileNameArticle=$(<:.md=) -D HEADER_HEADER=$(addprefix articles/tmp/,$(notdir $(basename $@)_header.htm)) -D CANONIC="https://ache.one/$@" articles/article.m4 | $(HTML_MINIFIER_CMD) > $@
+
+# > Création des introductions des articles
+# On conserve le titre principale (dans tmp/%_intro.htm)
+# On y ajoute les deux premiers paragraphe (tmp/%_intro.html)
+#
+articles/tmp/%_intro.html: articles/%.html articles/intro.m4
+ @echo "> Création des introductions d'articles"
+ mkdir -p articles/tmp
+ @cat $< | $(CATCH_CMD) "h1" > $(@:.html=.htm)
+ @cat $< | $(CATCH_CMD) "h1 + p" | sed 's/res\//articles\/res\//' >> $(@:.html=.htm)
+ m4 -D tmpFileNameArticle=$(@:.html=.htm) -D linkFileNameArticle=$(<:.html=) articles/intro.m4 > $@
+
+
+# > Création de la liste des introductions d'articles pour la page principale
+# On assemble juste les introductions d'articles ensemble
+tmp/articles.htm: $(ALL_ARTICLES_INTRO_OUT) articles_intro_out
+ @echo "> Création de la liste des introductions d'articles"
+ mkdir -p tmp
+ cat $(ALL_ARTICLES_INTRO_OUT) > $@
+
+#####################################################################
+#### NOTES
+#####################################################################
+
+notes/index.html: notes/tmp/index.htm notes/tmp/notes_cards.htm
+# On rajoute les headers (tmp/%_header.htm)
+# On fini d'ajouter le squelette HTML (notes/%.html
+notes/%.html: notes/tmp/%.htm notes/tmp/notes_cards.htm
+ @echo "> Création des notes ($@)"
+ m4 -D tmpFileNameNote=$(addprefix notes/tmp/,$(notdir $(@:.html=.htm))) -D linkFileNameNote=$(<:.md=) -D HEADER_HEADER=$(addprefix notes/tmp/,$(notdir $(basename $@)_header.htm)) -D CANONIC="https://ache.one/$@" notes/note.m4 | $(HTML_MINIFIER_CMD) > $@
+
+notes/tmp/%.htm: notes/%.md
+ @echo
+ @echo "# Compile temporaire de la note $@"
+ mkdir -p notes/tmp
+ cat $< | $(MD_CMD) > $@
+
+# > Création des notes depuis le markdown
+# On compile le fichier md vers html (tmp/%.htm)
+# On rajoute les headers (tmp/%_header.htm)
+# On fini d'ajouter le squelette HTML (notes/%.html
+notes/%.html: notes/tmp/%.htm notes/tmp/notes_cards.htm
+ @echo "> Création des notes ($@)"
+ m4 -D TITLE_TITLE="`echo Licornes, hérissons et renards`" headers.m4 > $(addprefix notes/tmp/,$(notdir $(basename $@)_header.htm))
+ m4 -D tmpFileNameNote=$(addprefix notes/tmp/,$(notdir $(@:.html=.htm))) -D linkFileNameNote=$(<:.md=) -D HEADER_HEADER=$(addprefix notes/tmp/,$(notdir $(basename $@)_header.htm)) -D CANONIC="https://ache.one/$@" notes/note.m4 | $(HTML_MINIFIER_CMD) > $@
+
+# > Création de la liste des notes (format cartes)
+# On assemble juste les cartes de notes ensemble
+notes/tmp/notes_cards.htm: $(ALL_NOTES_CARDS_OUT)
+ @echo "> Création de la liste des cartes de notes"
+ mkdir -p tmp
+ cat $(ALL_NOTES_CARDS_OUT) > $@
+
+# > Création des cartes de chaque note
+notes/tmp/%_card.htm: notes/tmp/%.htm notes/notes_out
+ @echo "> Création de carte de note : $@ (need $<)"
+ mkdir -p tmp
+ cat $< | $(CATCH_CMD) "h1" > $@.tmp
+ cat $< | $(CATCH_CMD) "p:last-child" | sed 's/res\//notes\/res\//' >> $@.tmp
+ m4 -D tmpCard=$@.tmp notes/card.m4 > $@
+
+
+
+####################################################################
+### MAIN PAGE
+####################################################################
+
+# > Création de la page principale
+# On se sert du menu de gauche, du header, et de la liste des introductions
+# d'articles
+index.html: index.m4 $(BASE_HTML) tmp/articles.htm
+ @echo "> Création de la page principale"
+ m4 $< | $(HTML_MINIFIER_CMD) > $@
+
+
+# > Création de la page de contact
+# On compile le markdown en html (contact.htm)
+# On ajoute l'entête avec m4 (contact_header.html)
+# On ajoute le reste du squelette avec m4 (contact.html)
+contact/index.html: contact/index.md headers.m4 articles/article.m4
+ @echo "> Création de la page de contact"
+ $(MD_CMD) $< > $(@:.html=.htm)
+ m4 -D TITLE_TITLE="`grep h1 $(@:.html=.htm) | cut -d'>' -f 2 | cut -d'<' -f 1`" headers.m4 > $(basename $@)_header.html
+ m4 -D tmpFileNameArticle=$(@:.html=.htm) -D linkFileNameArticle=$(<:.md=) -D HEADER_HEADER=$(basename $@)_header.html -D CANONIC="https://ache.one/contact" articles/article.m4 | $(HTML_MINIFIER_CMD) > $@
+
+
+# > Création du menu de gauche
+# En se servant des logo dans s/img, on assemble le tout avec m4.
+tmp/left.htm: s/imgM/twitterLogo.svg s/imgM/mastoLogo.svg s/imgM/gitLogo.svg s/imgM/acheLogo.svg left.m4
+ @echo "> Création du menu de gauche"
+ mkdir -p tmp
+ m4 left.m4 > $@
+
+
+# > Création de l'entête principale
+# Tout est fait par le fichier headers.m4. On définit simplement le titre.
+tmp/headers.htm: headers.m4
+ @echo "> Création de l'entête principale"
+ m4 -D TITLE_TITLE="Licornes, hérissons et renards - 🦄 🦔 🦊" -D CANONIC="https://ache.one" headers.m4 > $@
+
+# > Création du fichier principale JavaScript
+# À partir du script `prepare` de npm.
+# En utilisant babel puis uglify-js
+$(SCRIPT_JS): src/js/*
+ mkdir -p s/js
+ npm run-script prepare
+
+# > Création du fichier principale CSS
+# À partir de sassc, un compilateur SCSS écrit en C.
+$(SHEET_CSS): src/css/*
+ mkdir -p s/css
+ sassc -t compressed src/css/design.scss > s/css/style.css
+
+
# > Fonctions de nettoyage
# .PHONY sert à indiquer une commande (sinon un fichier clean poserait problème)
# Un tiret devant une commande indique d'ignorer une éventuelle erreur.