bgneal@0: PY=python
bgneal@0: PELICAN=pelican
bgneal@0: PELICANOPTS=
bgneal@0: 
bgneal@0: BASEDIR=$(CURDIR)
bgneal@0: INPUTDIR=$(BASEDIR)/content
bgneal@0: OUTPUTDIR=$(BASEDIR)/output
bgneal@0: CONFFILE=$(BASEDIR)/pelicanconf.py
bgneal@0: PUBLISHCONF=$(BASEDIR)/publishconf.py
bgneal@0: 
bgneal@0: FTP_HOST=localhost
bgneal@0: FTP_USER=anonymous
bgneal@0: FTP_TARGET_DIR=/
bgneal@0: 
bgneal@0: SSH_HOST=jaguar
bgneal@0: SSH_PORT=22
bgneal@0: SSH_USER=brian
bgneal@0: SSH_TARGET_DIR=/svr/www/deathofagremmie.com/public
bgneal@0: 
bgneal@0: S3_BUCKET=my_s3_bucket
bgneal@0: 
bgneal@0: CLOUDFILES_USERNAME=my_rackspace_username
bgneal@0: CLOUDFILES_API_KEY=my_rackspace_api_key
bgneal@0: CLOUDFILES_CONTAINER=my_cloudfiles_container
bgneal@0: 
bgneal@0: DROPBOX_DIR=~/Dropbox/Public/
bgneal@0: 
bgneal@0: DEBUG ?= 0
bgneal@0: ifeq ($(DEBUG), 1)
bgneal@0: 	PELICANOPTS += -D
bgneal@0: endif
bgneal@0: 
bgneal@0: help:
bgneal@0: 	@echo 'Makefile for a pelican Web site                                        '
bgneal@0: 	@echo '                                                                       '
bgneal@0: 	@echo 'Usage:                                                                 '
bgneal@0: 	@echo '   make html                        (re)generate the web site          '
bgneal@0: 	@echo '   make clean                       remove the generated files         '
bgneal@0: 	@echo '   make regenerate                  regenerate files upon modification '
bgneal@0: 	@echo '   make publish                     generate using production settings '
bgneal@0: 	@echo '   make serve [PORT=8000]           serve site at http://localhost:8000'
bgneal@0: 	@echo '   make devserver [PORT=8000]       start/restart develop_server.sh    '
bgneal@0: 	@echo '   make stopserver                  stop local server                  '
bgneal@0: 	@echo '   make ssh_upload                  upload the web site via SSH        '
bgneal@0: 	@echo '   make rsync_upload                upload the web site via rsync+ssh  '
bgneal@0: 	@echo '   make dropbox_upload              upload the web site via Dropbox    '
bgneal@0: 	@echo '   make ftp_upload                  upload the web site via FTP        '
bgneal@0: 	@echo '   make s3_upload                   upload the web site via S3         '
bgneal@0: 	@echo '   make cf_upload                   upload the web site via Cloud Files'
bgneal@0: 	@echo '   make github                      upload the web site via gh-pages   '
bgneal@0: 	@echo '                                                                       '
bgneal@0: 	@echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html'
bgneal@0: 	@echo '                                                                       '
bgneal@0: 
bgneal@0: html:
bgneal@0: 	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
bgneal@0: 
bgneal@0: clean:
bgneal@0: 	[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
bgneal@0: 
bgneal@0: regenerate:
bgneal@0: 	$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
bgneal@0: 
bgneal@0: serve:
bgneal@0: ifdef PORT
bgneal@0: 	cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
bgneal@0: else
bgneal@0: 	cd $(OUTPUTDIR) && $(PY) -m pelican.server
bgneal@0: endif
bgneal@0: 
bgneal@0: devserver:
bgneal@0: ifdef PORT
bgneal@0: 	$(BASEDIR)/develop_server.sh restart $(PORT)
bgneal@0: else
bgneal@0: 	$(BASEDIR)/develop_server.sh restart
bgneal@0: endif
bgneal@0: 
bgneal@0: stopserver:
bgneal@0: 	kill -9 `cat pelican.pid`
bgneal@0: 	kill -9 `cat srv.pid`
bgneal@0: 	@echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
bgneal@0: 
bgneal@0: publish:
bgneal@0: 	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
bgneal@0: 
bgneal@0: ssh_upload: publish
bgneal@0: 	scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
bgneal@0: 
bgneal@0: rsync_upload: publish
bgneal@0: 	rsync -e "ssh -p $(SSH_PORT)" -P -rvz --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
bgneal@0: 
bgneal@0: dropbox_upload: publish
bgneal@0: 	cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
bgneal@0: 
bgneal@0: ftp_upload: publish
bgneal@0: 	lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
bgneal@0: 
bgneal@0: s3_upload: publish
bgneal@0: 	s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed
bgneal@0: 
bgneal@0: cf_upload: publish
bgneal@0: 	cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
bgneal@0: 
bgneal@0: github: publish
bgneal@0: 	ghp-import $(OUTPUTDIR)
bgneal@0: 	git push origin gh-pages
bgneal@0: 
bgneal@0: .PHONY: html help clean regenerate serve devserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github