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: For comments 2 to 4 Created April 2, 2018, 10:36 p.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,80 @@
+# Puppet: <%= @title %>
+
+root /var/www/<%= @domain %>;
+index index;
+default_type text/html;
+charset utf-8;
+
+set $index_page "index";
+
+<% if @custom_config %>
+<%= @custom_config %>
+<% 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 $lang en;
mathias 2018/04/05 01:12:31 Abbreviation without any reason? https://www.youtu
f.lopez 2018/04/10 02:45:40 Acknowledged.
+ set $region "";
+
+ if ($http_accept_language ~ ^(\w\w)\b)
+ {
+ set lang $1;
+ }
+ if ($http_accept_language ~ ^\w\w-(\w\w)\b)
+ {
+ set $region $1;
+ }
+
+ if ($arg_fb_locale ~ ^(\w\w)_(\w\w)$)
+ {
+ set $lang $1;
+ set $region $2;
+ }
+
+ # Redirect canonical URLs to language-specific versions
+
+ if (-e "$document_root/${preferredLang}_$preferredRegion$uri")
+ {
+ rewrite ^(.*) /${lang}_$region last;
+ }
+ if (-e "$document_root/$preferredLang$uri")
+ {
+ rewrite ^(.*) /$lang$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])(/.+)
+{
+ 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