From f8d90931f81dfc087be94f8ca6347d097af1545d Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Sun, 31 Jan 2016 16:35:29 -0600 Subject: [PATCH] Cleanup whitespace in generated vhosts Correct handling of allow encoded slashes --- apache/vhosts/standard.tmpl | 72 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/apache/vhosts/standard.tmpl b/apache/vhosts/standard.tmpl index af58923..5973631 100644 --- a/apache/vhosts/standard.tmpl +++ b/apache/vhosts/standard.tmpl @@ -1,8 +1,8 @@ {# Define default values here so the template below can just focus on layout #} -{% from "apache/map.jinja" import apache with context %} -{% set sitename = site.get('ServerName', id) %} +{%- from "apache/map.jinja" import apache with context -%} +{%- set sitename = site.get('ServerName', id) -%} -{% set vals = { +{%- set vals = { 'interfaces': site.get('interface', '*').split(), 'port': site.get('port', '80'), @@ -13,7 +13,7 @@ 'DirectoryIndex': site.get('DirectoryIndex'), 'UseCanonicalName': site.get('UseCanonicalName'), - 'AllowEncodedSlashes': site.get('AllowEncodedSlashes'), + 'AllowEncodedSlashes': site.get('AllowEncodedSlashes', 'Off'), 'LogLevel': site.get('LogLevel', 'warn'), 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)), @@ -36,46 +36,46 @@ 'Allow': 'from all', 'Require': 'all granted', }, -} %} +} -%} {% for intf in vals.interfaces -%} Listen {{ intf }}:{{ vals.port }} {% endfor %} - + ServerName {{ vals.ServerName }} {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} - {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %} + {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif -%} - {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %} - {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %} - {% if site.get('AllowEncodedSlashes') != False %}AllowEncodedSlashes {{ vals.AllowEncodedSlashes }}{% endif %} + {% if site.get('DirectoryIndex') -%}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %} + {% if site.get('UseCanonicalName') -%}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %} + {% if site.get('AllowEncodedSlashes') != False -%}AllowEncodedSlashes {{ vals.AllowEncodedSlashes }}{% endif %} - {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %} - {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %} - {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %} + {% if site.get('LogLevel') != False -%}LogLevel {{ vals.LogLevel }}{% endif %} + {% if site.get('ErrorLog') != False -%}ErrorLog {{ vals.ErrorLog }}{% endif %} + {% if site.get('CustomLog') != False -%}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %} - {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %} - {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} + {% if site.get('DocumentRoot') != False -%}DocumentRoot {{ vals.DocumentRoot }}{% endif %} + {% if site.get('VirtualDocumentRoot') -%}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} - {% if site.get('SSLCertificateFile') %} + {%- if site.get('SSLCertificateFile') %} SSLEngine on SSLCertificateFile {{ site.SSLCertificateFile }} - {% if site.get('SSLCertificateKeyFile') %} + {%- if site.get('SSLCertificateKeyFile') %} SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }} - {% endif %} - {% if site.get('SSLCertificateChainFile') %} + {%- endif %} + {%- if site.get('SSLCertificateChainFile') %} SSLCertificateChainFile {{ site.SSLCertificateChainFile}} - {% endif %} - {% endif %} + {%- endif %} + {%- endif %} - {% for loc, path in site.get('Alias', {}).items() %} + {%- for loc, path in site.get('Alias', {}).items() %} Alias {{ loc }} {{ path }} - {% endfor %} + {%- endfor %} - {% for path, dir in site.get('Directory', {}).items() %} - {% set dvals = { + {%- for path, dir in site.get('Directory', {}).items() -%} + {%- set dvals = { 'Options': dir.get('Options', vals.Directory.Options), 'Order': dir.get('Order', vals.Directory.Order), 'Allow': dir.get('Allow', vals.Directory.Allow), @@ -84,7 +84,7 @@ Listen {{ intf }}:{{ vals.port }} 'Dav': dir.get('Dav', False), } %} - {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %} + {%- if path == 'default' %}{% set path = vals.Directory_default %}{% endif %} {% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %} @@ -101,10 +101,10 @@ Listen {{ intf }}:{{ vals.port }} {{ dir.Formula_Append|indent(8) }} {% endif %} - {% endfor %} + {%- endfor %} - {% for path, loc in site.get('Location', {}).items() %} - {% set lvals = { + {%- for path, loc in site.get('Location', {}).items() %} + {%- set lvals = { 'Order': loc.get('Order', vals.Location.Order), 'Allow': loc.get('Allow', vals.Location.Allow), 'Require': loc.get('Require', vals.Location.Require), @@ -112,21 +112,21 @@ Listen {{ intf }}:{{ vals.port }} } %} - {% if apache.use_require %} - {% if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %} + {%- if apache.use_require %} + {%- if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %} {% else %} - {% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %} - {% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %} + {%- if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %} + {%- if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %} {% endif %} - {% if lvals.get('Dav') != False %}Dav On{% endif %} + {%- if lvals.get('Dav') != False %}Dav On{% endif %} - {% if loc.get('Formula_Append') %} + {%- if loc.get('Formula_Append') %} {{ loc.Formula_Append|indent(8) }} {% endif %} {% endfor %} - {% if site.get('Formula_Append') %} + {%- if site.get('Formula_Append') %} {{ site.Formula_Append|indent(4) }} {% endif %}