Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/adblockplus/templates/web/static.conf.erb

Issue 29733731: #7320 - Introduce helpcenter role (Closed)
Patch Set: Created March 27, 2018, 3:53 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/adblockplus/templates/web/static.conf.erb
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/adblockplus/templates/web/static.conf.erb
@@ -0,0 +1,79 @@
+# Puppet: <%= @title %>
mathias 2018/03/27 14:46:52 Please don't simply copy from our legacy. There's
+
+root /var/www/<%= @domain %>;
+index index;
+default_type text/html;
+charset utf-8;
+
+set $index_page "index";
+
+<% if @custom_config %>
+ <%= @custom_config %>
mathias 2018/03/27 14:46:52 We know the two spaces in front of the custom conf
f.lopez 2018/03/27 19:29:50 Acknowledged.
+<% end %>
+
+location /
+{
+ expires 1d;
+
+ # Redirect server/language root
+
+ rewrite ^/$ /$index_page last;
+ rewrite ^/(\w\w(_\w\w)?)$ /$1/ permanent;
+ rewrite ^/(\w\w(_\w\w)?)/$ /$1/$index_page last;
+
+ # Match Accept-Language header against available languages
+
+ set $preferredLang en;
+ set $preferredRegion "";
mathias 2018/03/27 14:46:52 Please avoid camel case where possible, and always
f.lopez 2018/03/27 19:29:51 Acknowledged.
+ if ($http_accept_language ~ ^(\w\w)\b)
mathias 2018/03/27 14:46:52 An empty line in front of this block would be appr
f.lopez 2018/03/27 19:29:51 Acknowledged.
+ {
+ set $preferredLang $1;
+ }
+ if ($http_accept_language ~ ^\w\w-(\w\w)\b)
+ {
+ set $preferredRegion $1;
+ }
+
+ if ($arg_fb_locale ~ ^(\w\w)_(\w\w)$)
+ {
+ set $preferredLang $1;
+ set $preferredRegion $2;
+ }
+
+ # Redirect canonical URLs to language-specific versions
+
+ if (-e "$document_root/${preferredLang}_$preferredRegion$uri")
+ {
+ rewrite ^(.*) /${preferredLang}_$preferredRegion$1 last;
+ }
+ if (-e "$document_root/$preferredLang$uri")
+ {
+ rewrite ^(.*) /$preferredLang$1 last;
+ }
+ if (-e "$document_root/en$uri")
+ {
+ rewrite ^(.*) /en$1 last;
+ }
+}
+
+# Redirect language URIs if no translations are found for the requested page
+
+location ~ ^/([a-z][a-z]\_[A-Z][A-Z])(/.+)
mathias 2018/03/27 14:46:52 Why use [a-z] here but \w above? Why use [A-Z] her
f.lopez 2018/03/27 19:29:51 Not sure, gonna try it with \w, I reused what we a
f.lopez 2018/03/28 16:05:09 This is because how the translations pages are bui
+{
+ if (!-e "$document_root$uri")
+ {
+ # if there is no language+region translation, try parent language URI
+ # example /es_MX/page -> /es/page
+ rewrite ^/([a-z][a-z])\_([A-Z][A-Z])(/.+) /$1$3 redirect;
+ }
+}
+
+location ~ ^/([a-z][a-z])(/.+)
+{
+ if (!-e "$document_root$uri")
+ {
+ # if there is no language translation, try canonical page for default language
+ # example /es/page -> /page
+ rewrite ^/([a-z][a-z])(/.+) $2 redirect;
+ }
+}

Powered by Google App Engine
This is Rietveld