Skip to content

Commit 5129ea7

Browse files
committed
re-introduce plugin and redirects needed for production
1 parent a815c9f commit 5129ea7

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
13+
# Nginx configuration files
14+
[*.{conf,sigil}]
15+
indent_style = space
16+
indent_size = 4
17+
18+
# Markdown files
19+
[*.md]
20+
trim_trailing_whitespace = false
21+
22+
# Shell scripts
23+
[*.sh]
24+
indent_style = space
25+
indent_size = 4
26+
27+
# Python files
28+
[*.py]
29+
indent_style = space
30+
indent_size = 4
31+
32+
# YAML files
33+
[*.{yml,yaml}]
34+
indent_style = space
35+
indent_size = 2

nginx.conf.sigil

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,85 @@ map $version_number $proxy_host {
77
"2" "newbook-2.cakephp.org";
88
}
99

10+
# Map for .next versions (development/pre-release docs)
11+
map $next_version $next_host {
12+
default "";
13+
"5.next" "newbook-5next.cakephp.org";
14+
"4.next" "newbook-4next.cakephp.org";
15+
"3.next" "newbook-3next.cakephp.org";
16+
}
17+
18+
# Map for legacy 1.x versions
19+
map $legacy_version $legacy_host {
20+
default "";
21+
"1.3" "newbook-13.cakephp.org";
22+
"1.2" "newbook-12.cakephp.org";
23+
"1.1" "newbook-11.cakephp.org";
24+
}
25+
26+
# Plugin latest version map
27+
map $plugin_name $plugin_latest {
28+
default "";
29+
"authentication" "3";
30+
"authorization" "3";
31+
"bake" "3";
32+
"chronos" "3";
33+
"debugkit" "5";
34+
"elasticsearch" "5";
35+
"migrations" "5";
36+
"phinx" "0";
37+
"queue" "2";
38+
}
39+
40+
# Plugin version to host mapping
41+
map "$plugin_name-$plugin_version" $plugin_host {
42+
default "";
43+
44+
# Authentication
45+
"authentication-1" "authentication-docs.cakephp.org";
46+
"authentication-2" "authentication-docs-2.cakephp.org";
47+
"authentication-3" "authentication-docs-3.cakephp.org";
48+
49+
# Authorization
50+
"authorization-1" "authorization-docs.cakephp.org";
51+
"authorization-2" "authorization-docs-2.cakephp.org";
52+
"authorization-3" "authorization-docs-3.cakephp.org";
53+
54+
# Bake
55+
"bake-1" "bake-docs.cakephp.org";
56+
"bake-2" "bake-docs-2.cakephp.org";
57+
"bake-3" "bake-docs-3.cakephp.org";
58+
59+
# Chronos
60+
"chronos-1" "chronos-docs.cakephp.org";
61+
"chronos-2" "chronos-docs-2.cakephp.org";
62+
"chronos-3" "chronos-docs-3.cakephp.org";
63+
64+
# DebugKit
65+
"debugkit-3" "debugkit-docs.cakephp.org";
66+
"debugkit-4" "debugkit-docs-4.cakephp.org";
67+
"debugkit-5" "debugkit-docs-5.cakephp.org";
68+
69+
# Elasticsearch
70+
"elasticsearch-2" "elasticsearch-docs.cakephp.org";
71+
"elasticsearch-3" "elasticsearch-docs-3.cakephp.org";
72+
"elasticsearch-4" "elasticsearch-docs-4.cakephp.org";
73+
"elasticsearch-5" "elasticsearch-docs-5.cakephp.org";
74+
75+
# Migrations
76+
"migrations-2" "migrations-docs.cakephp.org";
77+
"migrations-3" "migrations-docs-3.cakephp.org";
78+
"migrations-4" "migrations-docs-4.cakephp.org";
79+
"migrations-5" "migrations-docs-5.cakephp.org";
80+
81+
# Phinx
82+
"phinx-0" "phinx-docs.cakephp.org";
83+
84+
# Queue
85+
"queue-1" "queue-docs-1.cakephp.org";
86+
"queue-2" "queue-docs-2.cakephp.org";
87+
}
88+
1089
server {
1190
listen [::]:80;
1291
listen 80;
@@ -58,6 +137,49 @@ server {
58137
return 301 /5.x/$1;
59138
}
60139

140+
# ========================================
141+
# Version root and language redirects
142+
# ========================================
143+
144+
# Redirect .next version roots to English index
145+
location ~ ^/(5|4|3)\.next/?$ {
146+
return 301 /$1.next/en/;
147+
}
148+
# Redirect .next version with language code
149+
location ~ "^/(5|4|3)\.next/([a-z]{2})/?$" {
150+
return 301 /$1.next/$2/;
151+
}
152+
153+
# Redirect bare version numbers to version.x format with English
154+
# /5 → /5.x/en/
155+
location ~ ^/([2-5])/?$ {
156+
return 301 /$1.x/en/;
157+
}
158+
159+
# Redirect version with language code to .x format
160+
# /5/en → /5.x/en/, /5/ja → /5.x/ja/
161+
location ~ "^/([2-5])/([a-z]{2})/?$" {
162+
return 301 /$1.x/$2/;
163+
}
164+
165+
# Legacy 1.x version root redirects
166+
location ~ ^/(1\.[123])/?$ {
167+
return 301 /$1/en/;
168+
}
169+
location ~ "^/(1\.[123])/([a-z]{2})/?$" {
170+
return 301 /$1/$2/;
171+
}
172+
173+
# ========================================
174+
# Backward compatibility redirects
175+
# ========================================
176+
177+
# Redirect long version numbers to short .x format
178+
# /5.0/something → /5.x/something
179+
location ~ "^/(5|4|3|2)\.0/(.*)$" {
180+
return 301 /$1.x/$2;
181+
}
182+
61183
# Rewrite old style URLs to new .x format
62184
# /5/en/something.html -> /5.x/something.html (remove /en/)
63185
location ~ "^/([2-9]|[1-9][0-9]+)/en/(.*)$" {
@@ -74,6 +196,128 @@ server {
74196
return 301 /$1.x/$2;
75197
}
76198

199+
# ========================================
200+
# Development/pre-release documentation (.next versions)
201+
# ========================================
202+
203+
location ~ "^/(5|4|3)\.next/(.*)" {
204+
set $next_version $1.next;
205+
set $request_path $2;
206+
207+
# Cache static assets
208+
if ($request_path ~* ^(public|fonts|assets)/) {
209+
expires 1y;
210+
add_header Cache-Control "public, immutable";
211+
}
212+
213+
proxy_intercept_errors on;
214+
error_page 404 403 /$next_version/404.html;
215+
216+
proxy_set_header Host $next_host;
217+
proxy_pass http://localhost:80/$request_path;
218+
}
219+
220+
# ========================================
221+
# Legacy 1.x documentation
222+
# ========================================
223+
224+
location ~ "^/(1\.[123])/(.*)" {
225+
set $legacy_version $1;
226+
set $request_path $2;
227+
228+
# Cache static assets
229+
if ($request_path ~* ^(public|fonts|assets)/) {
230+
expires 1y;
231+
add_header Cache-Control "public, immutable";
232+
}
233+
234+
proxy_intercept_errors on;
235+
error_page 404 403 /$legacy_version/404.html;
236+
237+
proxy_set_header Host $legacy_host;
238+
proxy_pass http://localhost:80/$request_path;
239+
}
240+
241+
# ========================================
242+
# PLUGIN DOCUMENTATION
243+
# ========================================
244+
# Plugins: authentication, authorization, bake, chronos, debugkit,
245+
# elasticsearch, migrations, phinx, queue
246+
247+
# Backwards compatibility aliases (X.x → X format)
248+
location ~ "^/(authentication|authorization)/(1\.1|2\.[x0])/?(.*)"
249+
{
250+
rewrite ^/authentication/1\.1/?(.*) /authentication/1/$1 redirect;
251+
rewrite ^/authentication/2\.[x0]/?(.*) /authentication/2/$1 redirect;
252+
rewrite ^/authorization/1\.1/?(.*) /authorization/1/$1 redirect;
253+
rewrite ^/authorization/2\.[x0]/?(.*) /authorization/2/$1 redirect;
254+
}
255+
256+
location ~ "^/(bake|chronos)/([12])\.x/?(.*)"
257+
{
258+
rewrite ^/(bake|chronos)/([12])\.x/?(.*) /$1/$2/$3 redirect;
259+
}
260+
261+
location ~ "^/debugkit/([34])\.x/?(.*)"
262+
{
263+
rewrite ^/debugkit/([34])\.x/?(.*) /debugkit/$1/$2 redirect;
264+
}
265+
266+
location ~ "^/elasticsearch/2\.x/?(.*)"
267+
{
268+
rewrite ^/elasticsearch/2\.x/?(.*) /elasticsearch/2/$1 redirect;
269+
}
270+
271+
location ~ "^/migrations/2\.x/?(.*)"
272+
{
273+
rewrite ^/migrations/2\.x/?(.*) /migrations/2/$1 redirect;
274+
}
275+
276+
# Plugin root redirects to latest version
277+
location ~ ^/(authentication|authorization|bake|chronos|debugkit|elasticsearch|migrations|phinx|queue)/?$ {
278+
set $plugin_name $1;
279+
return 301 /$plugin_name/$plugin_latest/en/;
280+
}
281+
282+
# Plugin /latest redirects
283+
location ~ ^/(authentication|authorization|bake|chronos|debugkit|elasticsearch|migrations|phinx|queue)/latest/?$ {
284+
set $plugin_name $1;
285+
return 301 /$plugin_name/$plugin_latest/en/;
286+
}
287+
288+
location ~ ^/(authentication|authorization|bake|chronos|debugkit|elasticsearch|migrations|phinx|queue)/latest/(.*)$ {
289+
set $plugin_name $1;
290+
return 301 /$plugin_name/$plugin_latest/$2;
291+
}
292+
293+
# Plugin version root redirects (version → version/en/)
294+
location ~ ^/(authentication|authorization|bake|chronos|debugkit|elasticsearch|migrations|phinx|queue)/([0-9]+)/?$ {
295+
return 301 /$1/$2/en/;
296+
}
297+
298+
# Plugin proxy pass (unified for all plugins using maps)
299+
location ~ ^/(authentication|authorization|bake|chronos|debugkit|elasticsearch|migrations|phinx|queue)/([0-9]+)/?(.*)$ {
300+
set $plugin_name $1;
301+
set $plugin_version $2;
302+
set $request_path $3;
303+
304+
# Cache static assets
305+
if ($request_path ~* ^(public|fonts|assets)/) {
306+
expires 1y;
307+
add_header Cache-Control "public, immutable";
308+
}
309+
310+
proxy_intercept_errors on;
311+
error_page 404 403 /$plugin_name/$plugin_version/404.html;
312+
313+
proxy_set_header Host $plugin_host;
314+
proxy_pass http://localhost:80/$request_path;
315+
}
316+
317+
# ========================================
318+
# Main version documentation (2.x - 5.x)
319+
# ========================================
320+
77321
# Proxy pass to version specific containers using map
78322
location ~ "^/([2-9]|[1-9][0-9]+)\.x/(.*)" {
79323
set $version_number $1;

0 commit comments

Comments
 (0)