Skip to content

Commit 624a8c2

Browse files
redirections for next/v3 swap
1 parent 8f9d2b1 commit 624a8c2

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

Makefile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,51 @@
22
export PLOTLY_RENDERER=notebook_connected
33

44
MD_DIR ?= python
5+
UNCONV_DIR ?= unconverted/python
56
IPYNB_DIR ?= build/ipynb
67
HTML_DIR ?= build/html
78
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+
914
IPYNB_FILES := $(patsubst $(MD_DIR)/%.md,$(IPYNB_DIR)/%.ipynb,$(MD_FILES))
1015
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+
1119

12-
all: $(HTML_FILES)
20+
all: $(HTML_FILES) $(V3_REDIR_FILES) $(NEXT_REDIR_FILES)
1321

1422
.PRECIOUS: $(IPYNB_FILES)
1523

1624
$(IPYNB_DIR)/%.ipynb: $(MD_DIR)/%.md
1725
@mkdir -p $(IPYNB_DIR)
18-
@echo "[jupytext] $<"
26+
@echo "[jupytext] $<"
1927
@jupytext $< --to notebook --quiet --output $@
2028

2129
$(HTML_DIR)/2019-07-03-%.html: $(IPYNB_DIR)/%.ipynb
2230
@mkdir -p $(HTML_DIR)
2331
@mkdir -p $(FAIL_DIR)
24-
@echo "[nbconvert] $<"
32+
@echo "[nbconvert] $<"
2533
@jupyter nbconvert $< --to html --template nb.tpl \
2634
--output-dir $(HTML_DIR) --output 2019-07-03-$*.html \
2735
--execute > $(FAIL_DIR)/$* 2>&1 && rm -f $(FAIL_DIR)/$*
2836

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

nb.tpl

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,13 @@
22
{%- block header -%}
33
---
44
{% for k in nb.metadata.get("plotly") -%}
5-
{%- if k == "permalink" -%}
6-
permalink: {{ nb.metadata.get("plotly")[k].replace("python/", "python/next/") }}
7-
{% elif k == "redirect_from" -%}
8-
redirect_from: {{ nb.metadata.get("plotly")[k].replace("python/", "python/next/") }}
9-
{% elif k == "language" -%}
10-
language: python/next
11-
{% else -%}
125
{{ k }}: {{ nb.metadata.get("plotly")[k] }}
13-
{% endif -%}
14-
{%- endfor -%}
6+
{% endfor -%}
157
---
168
{{ super() }}
179
{{ '{% raw %}' }}
1810
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.js"></script>
1911

20-
<div style="margin: 20px auto; width: 75%; background: #f4f4f8; padding: 20px; font-weight: 400; line-height: 1.85; text-align: center;">
21-
<strong>Note:</strong> this is <em>pre-release documentation</em> for the upcoming version 4 of Plotly.py.<br/>
22-
See our <a href="https://plot.ly/python/next/getting-started" style="color: #2391fe">Getting Started</a> guide for v4 installation instructions,
23-
or head on over to the <a href="https://plot.ly/python" style="color: #2391fe">current v3 docs</a>
24-
</div>
25-
2612
{%- endblock header-%}
2713

2814

next_redirect.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
permalink: {{ nb.metadata.get("plotly")["permalink"].replace("python/", "python/next/") }}
3+
redirect_to: https://plot.ly/{{ nb.metadata.get("plotly")["permalink"] }}
4+
sitemap: false
5+
---

0 commit comments

Comments
 (0)