From ef93af79357952020414f9261894acc1d686fc7d Mon Sep 17 00:00:00 2001 From: William Yardley Date: Thu, 29 Sep 2016 15:52:06 -0700 Subject: [PATCH] try to improve spacing in generated configs (Issue #742) --- templates/conf.d/nginx.conf.erb | 3 +-- templates/vhost/vhost_header.erb | 1 - templates/vhost/vhost_ssl_footer.erb | 2 +- templates/vhost/vhost_ssl_header.erb | 5 ++--- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 850a89003..f7340ee1c 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -11,8 +11,8 @@ worker_rlimit_nofile <%= @worker_rlimit_nofile %>; pid <%= @pid %>; <% end -%> error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>; - <% if @nginx_cfg_prepend -%> + <%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%> <%- @nginx_cfg_prepend.sort_by{|k,v| k}.each do |key,value| -%> <%- Array(value).each do |asubvalue| -%> @@ -60,7 +60,6 @@ http { tcp_nopush on; <%- end -%> <% end -%> - server_tokens <%= @server_tokens %>; types_hash_max_size <%= @types_hash_max_size %>; diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 55dabf41e..82ca37916 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -151,7 +151,6 @@ server { access_log <%= @access_log_real %>; error_log <%= @error_log_real %>; - <% if @error_pages -%> <%- @error_pages.keys.sort.each do |key| -%> error_page <%= key %> <%= @error_pages[key] %>; diff --git a/templates/vhost/vhost_ssl_footer.erb b/templates/vhost/vhost_ssl_footer.erb index 69b04e941..90d0e4e85 100644 --- a/templates/vhost/vhost_ssl_footer.erb +++ b/templates/vhost/vhost_ssl_footer.erb @@ -1,4 +1,4 @@ -<% if @include_files %> +<% if @include_files -%> <%- @include_files.each do |file| -%> include <%= file %>; <%- end -%> diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index 25ddf7fa5..6613b28d6 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -83,15 +83,13 @@ server { access_log <%= @ssl_access_log_real %>; error_log <%= @ssl_error_log_real %>; - <% if @error_pages -%> <%- @error_pages.keys.sort.each do |key| -%> error_page <%= key %> <%= @error_pages[key] %>; <%- end -%> <% end -%> - - <% if @vhost_cfg_prepend -%> + <%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> @@ -107,6 +105,7 @@ server { <%- end -%> <% end -%> <% if @vhost_cfg_ssl_prepend -%> + <%- @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%>