Makefile (3436B)
1 # /Make/ it happen 2 # :PROPERTIES: 3 # :header-args: :tangle /etc/nixos/www/vincent.demeester.fr/Makefile 4 # :header-args+: :comments org 5 # :ID: 6191455e-95bc-4abc-a5f5-a62606ab2ea7 6 # :END: 7 # 8 # In order to publish this website, I am using [[file:make.org][make]]. In a nutshell, I am going to define a 9 # few target to get the content from my notes, export org files into html and copy more or 10 # less everything to the =public= folder. I will also define a clean and a publish target. 11 # 12 # The first part of my =Makefile= will be to define some constants that I want to use later 13 # on. Those are mainly to easily change where to look for the notes or where the emacs 14 # configuration is. 15 16 17 EMACS = 18 ifndef EMACS 19 EMACS = "emacs" 20 endif 21 22 DOTEMACS = 23 ifndef DOTEMACS 24 DOTEMACS = "~/.config/emacs" 25 endif 26 27 PUBLISH = 28 ifndef PUBLISH 29 PUBLISH = vincent.demeester.fr 30 endif 31 32 NOTES = ~/desktop/org/notes 33 34 35 36 # The default target will be name =build=. 37 38 39 all: build 40 41 # Building =public/= and publishing it 42 # :PROPERTIES: 43 # :ID: 853f3d6b-f385-4091-9f9e-b04d17794e5c 44 # :END: 45 # 46 # To build the website, we will be using [[file:emacs.org][Emacs]] in batch mode, with some shared library *and* 47 # the actual [[id:631ced7a-f3f7-4a77-81a8-4a1884a6c4d4][publish]] script. 48 49 50 .PHONY: build 51 build: publish.el publish-common.el build-articles 52 @echo "Publishing... with current Emacs configurations." 53 ${EMACS} --debug-init --batch --directory $(DOTEMACS)/lisp/ --directory $(DOTEMACS)/lisp/vorg/ \ 54 --load publish-common.el --load publish.el \ 55 --funcall org-publish-all 56 57 .PHONY: build-articles 58 build-articles: $(NOTES) 59 rsync -arv --delete --copy-links --exclude='*.private.org' --exclude='*.db' $(NOTES)/ articles/ 60 61 $(NOTES): 62 $(error $(NOTES) doesn't exists…) 63 64 65 66 # The =publish= target is gonna be really simple: I just need to copy the content to 67 # =~/desktop/sites= on the current machine, and the rest is automated. 68 69 70 #rsync -a --progress --copy-links --delete public/assets/.fancyindex/ ~/desktop/sites/dl.sbr.pm/.fancyindex/ 71 #rsync -a --progress --copy-links --delete public/ ~/desktop/sites/${PUBLISH}/ 72 .PHONY: publish 73 publish: build 74 rsync -ave ssh --progress --copy-links --delete public/assets/.fancyindex/ kerkouane.vpn:/var/www/dl.sbr.pm/.fancyindex/ 75 rsync -ave ssh --progress --copy-links --delete public/ kerkouane.vpn:/var/www/${PUBLISH}/ 76 77 # Local server 78 # :PROPERTIES: 79 # :ID: 0e26a52e-5f66-42c6-934d-b45cfc9745b2 80 # :END: 81 # 82 # Let's use =miniserve= (using [[file:nix.org][Nix]] with =nix-shell=) to serve the static website locally to 83 # validate my changes. 84 85 86 .PHONY: serve 87 serve: 88 nix-shell -p miniserve --command "miniserve --port=8181 --index=index.html public/" 89 90 # Final nits of the =Makefile= 91 # :PROPERTIES: 92 # :ID: 5bec22c8-491b-4e03-855a-4b5f859473cf 93 # :END: 94 # 95 # One of the final step is to install the git hooks if any. I tend to have this target in all my 96 # personal =Makefile= at least. Let's also define a =pre-commit= target that will hold 97 # anything we need to do at =pre-commit=. 98 99 100 .PHONY: install-hooks 101 install-hooks: 102 if [ -e .git ]; then nix-shell -p git --run 'git config core.hooksPath .githooks'; fi 103 104 .PHONY: pre-commit 105 pre-commit: README.md 106 107 108 109 # And the final target is the =clean= one. This will remove any compile emacs-lisp file 110 # (=*.elc=), the =public= folder, and some org-mode metadata. 111 112 113 .PHONY: clean 114 clean: 115 @echo "Cleaning up.." 116 @-rm -rvf *.elc 117 @-rm -rvf public 118 @-rm -rv ~/.org-timestamps/*