DESTDIR =

DBDIR = $(shell if [ -d /srv/manuels.freeduc.science ]; then echo /srv/manuels.freeduc.science; else echo .; fi)
SAVEDIR = $(DBDIR)/media/sauvegarde

all: aide/output/index.html

aide/output/index.html : $(shell ls aide/content/pages/*)
	make -C aide html

clean:
	find . -name "*~" | xargs rm -f

savedb:
	@python3 $(DBDIR)/savedb.py $(DBDIR)

stats_dev:
	@echo "Décompte des lignes codées par l'auteur"
	@echo "======================================="
	@echo
	@total=0; \
	n=$$(cat $$(find manuels -name "*.py"| grep -v migrat) | wc -l); \
	echo "- $${n} lignes en langage Python (application manuels)."; total=$$((total + n)); \
	n=$$(cat $$(find gestion -name "*.py"| grep -v migrat) | wc -l); \
	echo "- $${n} lignes en langage Python (module gestion)."; total=$$((total + n)); \
	n=$$(cat $$(find gestion -name "*.html") | wc -l); \
	echo "- $${n} lignes en langage HTML."; total=$$((total + n)); \
	n=$$(cat $$(find gestion/static -name "*.css"| grep -v jquery) | wc -l); \
	echo "- $${n} lignes en langage CSS."; total=$$((total + n)); \
	n=$$(cat $$(find gestion/static -name "*.js"| grep -v jquery) | wc -l); \
	echo "- $${n} lignes en langage Javascript."; total=$$((total + n)); \
	echo; echo $$total lignes en tout.

rsync_upload: aide/output/index.html
	rsync -av --delete --exclude="db*" --exclude="*archive*" --exclude="media" * freeduc.science:/srv/manuels.freeduc.science/
	ssh freeduc.science "cd /srv/manuels.freeduc.science; echo 'yes' | ./manage.py collectstatic; ./manage.py migrate"
	@echo "prochaines commandes : ssh freeduc.science, puis sudo service apache2 reload, et synchronisation de media/"
