|
2 | 2 | export PLOTLY_RENDERER=notebook_connected
|
3 | 3 |
|
4 | 4 | MD_DIR ?= python
|
| 5 | +UNCONV_DIR ?= unconverted/python |
5 | 6 | IPYNB_DIR ?= build/ipynb
|
6 | 7 | HTML_DIR ?= build/html
|
7 | 8 | FAIL_DIR ?= build/failures
|
8 |
| -MD_FILES := $(shell ls $(MD_DIR)/*) |
| 9 | +REDIR_DIR ?= build/html/redir |
| 10 | + |
| 11 | +MD_FILES := $(shell ls $(MD_DIR)/*.md) |
| 12 | +UNCONV_FILES := $(shell ls $(UNCONV_DIR)/*.md) |
| 13 | + |
9 | 14 | IPYNB_FILES := $(patsubst $(MD_DIR)/%.md,$(IPYNB_DIR)/%.ipynb,$(MD_FILES))
|
10 | 15 | HTML_FILES := $(patsubst $(MD_DIR)/%.md,$(HTML_DIR)/2019-07-03-%.html,$(MD_FILES))
|
| 16 | +NEXT_REDIR_FILES := $(patsubst $(MD_DIR)/%.md,$(REDIR_DIR)/2019-07-03-redirect-next-%.html,$(MD_FILES)) |
| 17 | +V3_REDIR_FILES := $(patsubst $(UNCONV_DIR)/%.md,$(REDIR_DIR)/2019-07-03-redirect-v3-%.html,$(UNCONV_FILES)) |
| 18 | + |
11 | 19 |
|
12 |
| -all: $(HTML_FILES) |
| 20 | +all: $(HTML_FILES) $(V3_REDIR_FILES) $(NEXT_REDIR_FILES) |
13 | 21 |
|
14 | 22 | .PRECIOUS: $(IPYNB_FILES)
|
15 | 23 |
|
16 | 24 | $(IPYNB_DIR)/%.ipynb: $(MD_DIR)/%.md
|
17 | 25 | @mkdir -p $(IPYNB_DIR)
|
18 |
| - @echo "[jupytext] $<" |
| 26 | + @echo "[jupytext] $<" |
19 | 27 | @jupytext $< --to notebook --quiet --output $@
|
20 | 28 |
|
21 | 29 | $(HTML_DIR)/2019-07-03-%.html: $(IPYNB_DIR)/%.ipynb
|
22 | 30 | @mkdir -p $(HTML_DIR)
|
23 | 31 | @mkdir -p $(FAIL_DIR)
|
24 |
| - @echo "[nbconvert] $<" |
| 32 | + @echo "[nbconvert] $<" |
25 | 33 | @jupyter nbconvert $< --to html --template nb.tpl \
|
26 | 34 | --output-dir $(HTML_DIR) --output 2019-07-03-$*.html \
|
27 | 35 | --execute > $(FAIL_DIR)/$* 2>&1 && rm -f $(FAIL_DIR)/$*
|
28 | 36 |
|
| 37 | + |
| 38 | +$(REDIR_DIR)/2019-07-03-redirect-next-%.html: $(IPYNB_DIR)/%.ipynb |
| 39 | + @mkdir -p $(REDIR_DIR) |
| 40 | + @echo "[next-redir] $<" |
| 41 | + @jupyter nbconvert $< --to html --template next_redirect.tpl \ |
| 42 | + --output-dir $(REDIR_DIR) --output 2019-07-03-redirect-next-$*.html |
| 43 | + |
| 44 | + |
| 45 | +$(REDIR_DIR)/2019-07-03-redirect-v3-%.html: $(UNCONV_DIR)/%.md |
| 46 | + @mkdir -p $(REDIR_DIR) |
| 47 | + @echo "[v3-redir] $<" |
| 48 | + @echo "---" > $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html |
| 49 | + @echo "permalink: python/$*/" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html |
| 50 | + @echo "redirect_to: https://plot.ly/python/v3/$*/" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html |
| 51 | + @echo "sitemap: true" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html |
| 52 | + @echo "---" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html |
0 commit comments