From f0f758803cc2b142853579586c5cebc12e223a97 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 29 Dec 2018 02:10:04 +0100 Subject: Add stark❕ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- makefile | 160 +++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 110 insertions(+), 50 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index 7bdcc0c..f8906dc 100644 --- a/makefile +++ b/makefile @@ -1,62 +1,122 @@ MD_CMD=remark --rc-path remarkrc CATCH_CMD=pup -BASE_HTML=left.htm headers.htm -ALL_ARTICLES=$(wildcard article/*.md) +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=$(ALL_ARTICLES:.md=_intro.html) - -all: $(ALL_ARTICLES_OUT) $(BASE_HTML) index.html contact/index.html - -article/%.html: article/%.md $(BASE_HTML) - cat $< | ${MD_CMD} > ${@:.html=.htm} - m4 -D TITLE_TITLE="`echo Licornes, hérissons et renards`" headers.m4 > ${basename $@}_header.html - m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=} -D HEADER_HEADER=${basename $@}_header.html -D CANONIC="/$@" article/article.m4 > $@ - -article/%_intro.html: article/%.html - cat $< | ${CATCH_CMD} "h1" > ${@:.html=.htm} - cat $< | ${CATCH_CMD} "h1 + p" | sed 's/res\//article\/res\//' >> ${@:.html=.htm} - cat $< | ${CATCH_CMD} "h1 + p + p" >> ${@:.html=.htm} - m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.html=} article/intro.m4 > $@ - -articles.htm: $(ALL_ARTICLES_INTRO_OUT) +ALL_ARTICLES_INTRO_OUT=$(addprefix articles/tmp/,$(notdir $(ALL_ARTICLES:.md=_intro.html))) + +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) + + +# > 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) + @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="/$@" 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 + @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) + cat $< | $(CATCH_CMD) "h1 + p + p" >> $(@:.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) + @echo "> Création de la liste des introductions d'articles" + mkdir -p tmp cat $(ALL_ARTICLES_INTRO_OUT) > $@ -headers_index.htm: - m4 -D TITLE_TITLE="Licornes, hérissons et renards" -D CANONIC="/" headers.m4 > $@ +# > 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) > $@ -index.html: index.m4 $(BASE_HTML) headers_index.htm articles.htm - m4 $< > $@ +# > 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 - ${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="/contact" article/article.m4 > $@ - -left.htm: res/twitterLogo.svg res/mastoLogo.svg res/gitLogo.svg res/acheLogo.svg left.m4 - m4 left.m4 > left.htm - -headers.htm: headers.m4 - m4 headers.m4 > headers.htm - + @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="/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/img/twitterLogo.svg s/img/mastoLogo.svg s/img/gitLogo.svg s/img/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="/" headers.m4 > $@ + +# > Création du fichier principale JavaScript +# À partir du script `prepare` de npm. +# En utilisant babel puis uglify-js +$(SCRIPT_JS): src/js/* + npm run-script prepare + +# > Création du fichier principale CSS +# À partir de sassc, un compilateur SCSS écrit en C. +$(SHEET_CSS): src/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. +.PHONY: clean clean: - rm -f $(BASE_HTML) - rm -f articles.htm - rm -f $(ALL_ARTICLES:.md=_intro.htm) - rm -f $(ALL_ARTICLES:.md=.htm) - rm -f article/*.htm - rm -f article/*_header.html - rm -f contact/*.htm - rm -f contact/*_header.html - rm -f headers_index.htm - -mrproper: clean - rm -f index.html - rm -f $(ALL_ARTICLES_OUT) - rm -f $(ALL_ARTICLES_INTRO_OUT) - rm -f contact/index.html - - - + @echo "Clean" + -rm -f $(BASE_HTML) + -rm -f articles.htm + -rm -f $(ALL_ARTICLES:.md=_intro.htm) + -rm -f $(ALL_ARTICLES:.md=.htm) + -rm -f articles/*.htm + -rm -f articles/*_header.html + -rm -f contact/*.htm + -rm -f contact/*_header.html + -rm -rf tmp/ + +.PHONY: mrclean +mrclean: clean + -rm -f index.html + -rm -f $(ALL_ARTICLES_OUT) + -rm -f $(ALL_ARTICLES_INTRO_OUT) + -rm -f $(SHEET_CSS) + -rm -f $(SCRIPT_JS) + -rm -f contact/index.html -- cgit v1.2.3-54-g00ecf