-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (79 loc) · 2.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
SHELL=bash
PORT?=4000
HOST?=0.0.0.0
CONDA_ENV = street_science_community_website
PDF_DIR=_pdf
PDF_HOST?=127.0.0.1
SITE_URL=http://${PDF_HOST}:${PORT}
PROTOCOLS=$(shell find _site/protocols/ -name 'index.html' | sed 's/_site\/protocols\///')
CONDA = $(shell which conda)
ifeq ($(CONDA),)
CONDA=${HOME}/miniconda3/bin/conda
endif
CHROME=google-chrome-stable
ifeq ($(shell uname -s),Darwin)
CHROME=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
endif
default: help
clean: ## cleanup the project
@rm -rf _site
@rm -rf .sass-cache
@rm -rf .bundle
@rm -rf vendor
.PHONY: clean
create-env: ## create conda environment
if ${CONDA} env list | grep '^${CONDA_ENV}'; then \
${CONDA} env update -f environment.yml; \
else \
${CONDA} env create -f environment.yml; \
fi
.PHONY: create-env
ACTIVATE_ENV = source $(dir ${CONDA})activate ${CONDA_ENV}
install: clean ## install dependencies
$(ACTIVATE_ENV) && \
gem install bundler && \
bundle install
.PHONY: install
serve: ## run a local server
$(ACTIVATE_ENV) && \
bundle exec jekyll serve
.PHONY: serve
detached-serve: ## run a local server in detached mode
$(ACTIVATE_ENV) && \
bundle exec jekyll serve --detach -P ${PORT} -H ${PDF_HOST} ${FLAGS}
.PHONY: detached-serve
pdf: detached-serve ## generate the PDF of the protocols
mkdir -p $(PDF_DIR)
@for t in $(PROTOCOLS); do \
name="$(PDF_DIR)/$$(echo $$t | tr '/' '-' | sed -e 's/.html/-instructors.pdf/' -e 's/^-//' -e 's/-index//')"; \
${CHROME} \
--headless \
--disable-gpu \
--print-to-pdf="$$name" \
"$(SITE_URL)/protocols/$$t" \
2> /dev/null ; \
name="$(PDF_DIR)/$$(echo $$t | tr '/' '-' | sed -e 's/.html/-learners.pdf/' -e 's/^-//' -e 's/-index//')"; \
${CHROME} \
--headless \
--disable-gpu \
--print-to-pdf="$$name" \
"$(SITE_URL)/protocols/$$t?without-details" \
2> /dev/null ; \
done
${CHROME} \
--headless \
--disable-gpu \
--print-to-pdf="$(PDF_DIR)/beer-dna-sequencing-flongle-instructor.pdf" \
"$(SITE_URL)/protocols/beer-dna-sequencing?flongle" \
2> /dev/null
${CHROME} \
--headless \
--disable-gpu \
--print-to-pdf="$(PDF_DIR)/beer-dna-sequencing-flongle-learners.pdf" \
"$(SITE_URL)/protocols/beer-dna-sequencing?flongle?without-details" \
2> /dev/null
pkill -f jekyll
.PHONY: pdf
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help