WEBROOT := https://f3nx.neocities.org PAGES := $(shell find -L page -name '*.html') PAGES := $(patsubst %.html,../%/index.html,$(PAGES)) POSTS := $(shell find -L post -name '*.html') POSTS := $(patsubst %.html,../%/index.html,$(POSTS)) TITLE_SUFFIX := &\#9851; SED_REMOVE_HTML_TAGS := sed -e 's/<[^>]*>//g' SED_REMOVE_AND := sed -e 's/\ / /g' TR_REMOVE := tr -d '\n\0' # Count all words in file $1 (without HTML tags) and divide through WORDS_READ_PER_MINUTE := 200 define reading_time $(shell echo "["$(shell echo $(shell $(SED_REMOVE_HTML_TAGS) $(1) \ | wc -w) / $(WORDS_READ_PER_MINUTE) | bc)) min] endef all: ../index.html ../feed.xml $(PAGES) $(POSTS) # Index page (variable: @WEBROOT@) # Variable "est" para poner un estado o texto como "sin terminar" o "actualizado" ../index.html: $(POSTS) template/* Makefile $(info HTML $@) @ echo '' > $@.tmp @ cat template/head.html >> $@.tmp @ echo 'Inicio $(TITLE_SUFFIX)' >> $@.tmp @ cat template/header.html >> $@.tmp @ echo "
" >> $@.tmp @ cat template/home.html >> $@.tmp @ # Write each post into an extra file with stripped new lines, then @ # write all posts into one file @ for f in $(POSTS); do \ url=$(WEBROOT)/$${f/.html//}; \ grep -m1 '' $$f >> $@.post.tmp; \ grep -m1 '' $$f >> $@.post.tmp; \ grep -m1 '' $$f >> $@.post.tmp; \ grep -m1 '> $@.post.tmp; \ tr -d '\n\t' < $@.post.tmp >> $@.posts.tmp; \ echo "
" >> $@.posts.tmp; \ rm $@.post.tmp; \ done @ # Sort all posts (by date) and add them to index.html @ #Buscando una solucion para DD/MM/YYYY por ahora se queda en formato ISO @ #Searching for a DD/MM/YYYY solution, now is ISO format @ cat $@.posts.tmp | sort -r >> $@.tmp @ rm $@.posts.tmp @ echo "
" >> $@.tmp @ cat template/footer.html >> $@.tmp @ sed -i 's~@WEBROOT@~$(WEBROOT)~g' $@.tmp @ mv $@.tmp $@ # Posts and pages (variables: @WEBROOT@, @SELF@, @ERT@) # Parte del lenguaje/language part @LANG@ y lang del .html ../%/index.html: %.html template/* Makefile $(info HTML $@) @ mkdir -p $(dir $@) @ echo '' > $@.tmp @ echo -n '' $< | $(SED_REMOVE_HTML_TAGS) | $(TR_REMOVE)\ >> $@.tmp @ echo '">' >> $@.tmp @ cat template/head.html >> $@.tmp @ echo '' >> $@.tmp @ grep '<a class="h1" href="@SELF@"' $< | $(SED_REMOVE_HTML_TAGS) \ >> $@.tmp @ echo ' $(TITLE_SUFFIX)' >> $@.tmp @ cat template/header.html >> $@.tmp @ cat $< template/footer.html >> $@.tmp @ sed -i 's~@WEBROOT@~$(WEBROOT)~g' $@.tmp @ sed -i 's~@SELF@~$(WEBROOT)/$(patsubst ../%index.html,%,$@)~g' \ $@.tmp @ sed -i 's~@LANG@~$(WEBROOT)/$(patsubst ../%index.html,%,$*)~g' \ $@.tmp @ sed -i 's~@ERT@~$(call reading_time,$<)~g' $@.tmp @ mv $@.tmp $@ # RSS feed ../feed.xml: template/* Makefile $(POSTS) $(info RSS $@) @ echo '' > $@.tmp @ echo '' >> $@.tmp @ echo '' >> $@.tmp @ echo '' >> $@.tmp @ echo 'Blog de f3nx' >> $@.tmp @ echo 'Blog de f3nx' >> $@.tmp @ echo 'https://f3nx.neocities.org/' >> $@.tmp @ for f in $(POSTS); do \ echo '' >> $@.tmp; \ \ echo '' >> $@.tmp; \ grep '<a class="h1" href="' $$f | $(SED_REMOVE_HTML_TAGS) \ | $(SED_REMOVE_AND) >> $@.tmp; \ echo '' >> $@.tmp; \ \ url="$${f/\/index.html//}"; \ url="$(WEBROOT)$${url/..\///}"; \ echo "$$url" >> $@.tmp; \ echo "$$url" >> $@.tmp; \ \ echo '' >> $@.tmp; \ done @ echo '' >> $@.tmp @ echo '' >> $@.tmp @ mv $@.tmp $@ clean: $(info CLEAN) @ rm -r ../index.html ../*.tmp ../feed.xml ../page ../post \ 2> /dev/null || true .PHONY: clean all