Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 1 | PY?=python3 |
| 2 | PELICAN?=pelican |
| 3 | PELICANOPTS= |
| 4 | |
| 5 | BASEDIR=$(CURDIR) |
| 6 | INPUTDIR=$(BASEDIR)/content |
| 7 | OUTPUTDIR=$(BASEDIR)/output |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 8 | OUTPUTDIR_THEME=$(OUTPUTDIR)/theme |
| 9 | OUTPUTDIR_PHOTOS=$(OUTPUTDIR)/photos |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 10 | CONFFILE=$(BASEDIR)/pelicanconf.py |
| 11 | PUBLISHCONF=$(BASEDIR)/publishconf.py |
| 12 | |
| 13 | FTP_HOST=localhost |
| 14 | FTP_USER=anonymous |
| 15 | FTP_TARGET_DIR=/ |
| 16 | |
| 17 | SSH_HOST=localhost |
| 18 | SSH_PORT=22 |
| 19 | SSH_USER=root |
| 20 | SSH_TARGET_DIR=/var/www |
| 21 | |
| 22 | S3_BUCKET=my_s3_bucket |
| 23 | |
| 24 | CLOUDFILES_USERNAME=my_rackspace_username |
| 25 | CLOUDFILES_API_KEY=my_rackspace_api_key |
| 26 | CLOUDFILES_CONTAINER=my_cloudfiles_container |
| 27 | |
| 28 | DROPBOX_DIR=~/Dropbox/Public/ |
| 29 | |
| 30 | GITHUB_PAGES_BRANCH=gh-pages |
| 31 | |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 32 | INSTALLSUDO ?= 0 |
| 33 | ifeq ($(INSTALLSUDO),1) |
| 34 | SUDO := sudo -E |
| 35 | endif |
| 36 | INSTALLFLAGS := $(INSTALLFLAGS) -rXaA |
| 37 | INSTALLDIR ?= |
| 38 | INSTALLDIR_THEME ?= |
| 39 | INSTALLDIR_PHOTOS ?= |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 40 | |
| 41 | DEBUG ?= 0 |
| 42 | ifeq ($(DEBUG), 1) |
| 43 | PELICANOPTS += -D |
| 44 | endif |
| 45 | |
| 46 | RELATIVE ?= 0 |
| 47 | ifeq ($(RELATIVE), 1) |
| 48 | PELICANOPTS += --relative-urls |
| 49 | endif |
| 50 | |
| 51 | help: |
| 52 | @echo 'Makefile for a pelican Web site ' |
| 53 | @echo ' ' |
| 54 | @echo 'Usage: ' |
| 55 | @echo ' make html (re)generate the web site ' |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 56 | @echo ' make clean-html remove all html files and folders ' |
| 57 | @echo ' make clean-theme remove output/theme ' |
| 58 | @echo ' make clean-photos remove output/photos ' |
| 59 | @echo ' make clean remove output folder ' |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 60 | @echo ' make regenerate regenerate files upon modification ' |
| 61 | @echo ' make publish generate using production settings ' |
| 62 | @echo ' make serve [PORT=8000] serve site at http://localhost:8000' |
| 63 | @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 ' |
| 64 | @echo ' make devserver [PORT=8000] start/restart develop_server.sh ' |
| 65 | @echo ' make stopserver stop local server ' |
| 66 | @echo ' make ssh_upload upload the web site via SSH ' |
| 67 | @echo ' make rsync_upload upload the web site via rsync+ssh ' |
| 68 | @echo ' make dropbox_upload upload the web site via Dropbox ' |
| 69 | @echo ' make ftp_upload upload the web site via FTP ' |
| 70 | @echo ' make s3_upload upload the web site via S3 ' |
| 71 | @echo ' make cf_upload upload the web site via Cloud Files' |
| 72 | @echo ' make github upload the web site via gh-pages ' |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 73 | @echo ' make install-html copy *.html, html folders locally ' |
| 74 | @echo ' make install-theme copy output/theme locally ' |
| 75 | @echo ' make install-photos copy output/photos locally ' |
| 76 | @echo ' make install copy output/* locally ' |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 77 | @echo ' ' |
| 78 | @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html ' |
| 79 | @echo 'Set the RELATIVE variable to 1 to enable relative urls ' |
| 80 | @echo ' ' |
| 81 | |
| 82 | html: |
| 83 | $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) |
| 84 | |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 85 | clean-html: |
| 86 | find "$(OUTPUTDIR)" -type f -name *.html -delete |
| 87 | find "$(OUTPUTDIR)" -type d -empty -delete |
| 88 | |
| 89 | clean-theme: |
| 90 | [ ! -d "$(OUTPUTDIR_THEME)" ] || rm -rf $(OUTPUTDIR_THEME) |
| 91 | |
| 92 | clean-photos: |
| 93 | [ ! -d "$(OUTPUTDIR_PHOTOS)" ] || rm -rf $(OUTPUTDIR_PHOTOS) |
| 94 | |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 95 | clean: |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 96 | [ ! -d "$(OUTPUTDIR)" ] || rm -rf $(OUTPUTDIR) |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 97 | |
| 98 | regenerate: |
| 99 | $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) |
| 100 | |
| 101 | serve: |
| 102 | ifdef PORT |
| 103 | cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT) |
| 104 | else |
| 105 | cd $(OUTPUTDIR) && $(PY) -m pelican.server |
| 106 | endif |
| 107 | |
| 108 | serve-global: |
| 109 | ifdef SERVER |
| 110 | cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER) |
| 111 | else |
| 112 | cd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0 |
| 113 | endif |
| 114 | |
| 115 | |
| 116 | devserver: |
| 117 | ifdef PORT |
| 118 | $(BASEDIR)/develop_server.sh restart $(PORT) |
| 119 | else |
| 120 | $(BASEDIR)/develop_server.sh restart |
| 121 | endif |
| 122 | |
| 123 | stopserver: |
| 124 | $(BASEDIR)/develop_server.sh stop |
| 125 | @echo 'Stopped Pelican and SimpleHTTPServer processes running in background.' |
| 126 | |
| 127 | publish: |
| 128 | $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS) |
| 129 | |
| 130 | ssh_upload: publish |
| 131 | scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) |
| 132 | |
| 133 | rsync_upload: publish |
| 134 | rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude |
| 135 | |
| 136 | dropbox_upload: publish |
| 137 | cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR) |
| 138 | |
| 139 | ftp_upload: publish |
| 140 | lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit" |
| 141 | |
| 142 | s3_upload: publish |
| 143 | s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve |
| 144 | |
| 145 | cf_upload: publish |
| 146 | cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) . |
| 147 | |
| 148 | github: publish |
| 149 | ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR) |
| 150 | git push origin $(GITHUB_PAGES_BRANCH) |
| 151 | |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 152 | install-html: |
| 153 | [ -d "$(OUTPUTDIR)" ] && [ -d "$(INSTALLDIR)" ] && \ |
| 154 | $(SUDO) rsync $(INSTALLFLAGS) --exclude=$(notdir $(OUTPUTDIR_THEME)) \ |
| 155 | --exclude=$(notdir $(OUTPUTDIR_PHOTOS)) $(OUTPUTDIR)/* $(INSTALLDIR) |
| 156 | |
| 157 | install-theme: |
| 158 | [ -d "$(OUTPUTDIR_THEME)" ] && [ -d "$(INSTALLDIR_THEME)" ] && \ |
| 159 | $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_THEME) $(INSTALLDIR_THEME)/ |
| 160 | |
| 161 | install-photos: |
| 162 | [ -d "$(OUTPUTDIR_PHOTOS)" ] && [ -d "$(INSTALLDIR_PHOTOS)" ] && \ |
| 163 | $(SUDO) rsync $(INSTALLFLAGS) $(OUTPUTDIR_PHOTOS) $(INSTALLDIR_PHOTOS)/ |
| 164 | |
| 165 | install: install-html install-theme install-photos |
Luigi Santivetti | f72f657 | 2020-02-17 23:11:56 +0000 | [diff] [blame] | 166 | |
| 167 | |
luigi | 38e2936 | 2020-04-04 22:42:06 +0100 | [diff] [blame^] | 168 | .PHONY: html help clean clean-html clean-theme clean-photos regenerate serve serve-global devserver stopserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github install install-html install-theme install-photos |