.PHONY: all publish push assets clean

all: publish assets clean

publish:
	@emacs --batch --no-init --load publish.el --funcall org-publish-all
	sed -i '/<title>&lrm;<\/title>/d' ./output/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/research/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/posts/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/teaching/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/teaching/economic-calculus/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/teaching/growth/index.html
	sed -i '/<title>&lrm;<\/title>/d' ./output/teaching/time-series/index.html
	sed -i 's/<pre class="src src-python">/<pre><code class="language-python">/g' ./output/posts/simulation-du-modele-de-solow/index.html
	sed -i 's/<\/pre>/<\/code><\/pre>/g' ./output/posts/simulation-du-modele-de-solow/index.html
	sed -i 's/<pre class="src src-python">/<pre><code class="language-python">/g' ./output/posts/modele-de-solow/index.html
	sed -i 's/<\/pre>/<\/code><\/pre>/g' ./output/posts/modele-de-solow/index.html
	sed -i 's/<pre class="src src-python">/<pre><code class="language-python">/g' ./output/posts/representer-graphiquement-une-serie-temporelle-du-pib/index.html
	sed -i 's/<\/pre>/<\/code><\/pre>/g' ./output/posts/representer-graphiquement-une-serie-temporelle-du-pib/index.html

assets:
	@rsync --recursive -avz assets/fonts output
	@rsync --recursive -avz assets/fontawesome output
	@rsync --recursive -avz assets/css output
	@rsync --recursive -avz assets/highlight output
	@rsync --recursive -avz assets/dynare output
	@rsync --recursive -avz assets/papers output
	@rsync --recursive -avz assets/thesis output
	@rsync --recursive -avz assets/oldies output
	@rsync assets/stepan.gpg-pub.asc output
	@rsync assets/favicon.ico output

clean:
	@rm -rf output/posts/.ltx
	@rm -rf output/posts/representation-ma-du-processus-ar2/.ltx
	@rm -rf output/posts/simulation-du-modele-de-solow/.ltx
	@rm -rf output/posts/modele-de-solow/.ltx
	@rm -rf output/posts/fonction-de-production-ces/.ltx

push: publish assets clean
	@rsync --recursive -avz --progress output/* ulysses:/home/www/stephane-adjemian.fr
