From a92b8fb4cb840526c8271fb23bee0df7fd3a0a99 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 15 Oct 2014 16:58:24 +0100 Subject: [PATCH] Add parameter for AddDefaultCharset virtual host directive --- README.md | 4 ++++ manifests/vhost.pp | 11 +++++++++++ spec/defines/vhost_spec.rb | 5 ++++- templates/vhost/_charsets.erb | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 templates/vhost/_charsets.erb diff --git a/README.md b/README.md index a0c84b9cc..fda2cd990 100644 --- a/README.md +++ b/README.md @@ -882,6 +882,10 @@ Specifies the use of either a LogFormat nickname or a custom format string for t Specifies that only requests with particular environment variables be logged. Defaults to 'undef'. +#####`add_default_charset` + +Sets [AddDefaultCharset](http://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset), a default value for the media charset, which is added to text/plain and text/html responses. + #####`add_listen` Determines whether the vhost creates a Listen statement. The default value is 'true'. diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 8e5e7a4e6..fd942fe5e 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -105,6 +105,7 @@ $passenger_min_instances = undef, $passenger_start_timeout = undef, $passenger_pre_start = undef, + $add_default_charset = undef, ) { # The base class must be included first because it is used by parameter defaults if ! defined(Class['apache']) { @@ -800,6 +801,16 @@ content => template('apache/vhost/_passenger.erb'), } + # Template uses: + # - $add_default_charset + if $add_default_charset { + concat::fragment { "${name}-charsets": + target => "${priority_real}-${filename}.conf", + order => 300, + content => template('apache/vhost/_charsets.erb'), + } + } + # Template uses no variables concat::fragment { "${name}-file_footer": target => "${priority_real}-${filename}.conf", diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index a65e48a86..3eac5ffb4 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -238,7 +238,8 @@ 'passenger_ruby' => '/usr/bin/ruby1.9.1', 'passenger_min_instances' => '1', 'passenger_start_timeout' => '600', - 'passenger_pre_start' => 'http://localhost/myapp' + 'passenger_pre_start' => 'http://localhost/myapp', + 'add_default_charset' => 'UTF-8', } end let :facts do @@ -312,6 +313,7 @@ it { is_expected.to contain_concat__fragment('rspec.example.com-fastcgi') } it { is_expected.to contain_concat__fragment('rspec.example.com-suexec') } it { is_expected.to contain_concat__fragment('rspec.example.com-passenger') } + it { is_expected.to contain_concat__fragment('rspec.example.com-charsets') } it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') } end context 'not everything can be set together...' do @@ -390,6 +392,7 @@ it { is_expected.to_not contain_concat__fragment('rspec.example.com-custom_fragment') } it { is_expected.to_not contain_concat__fragment('rspec.example.com-fastcgi') } it { is_expected.to_not contain_concat__fragment('rspec.example.com-suexec') } + it { is_expected.to_not contain_concat__fragment('rspec.example.com-charsets') } it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') } end end diff --git a/templates/vhost/_charsets.erb b/templates/vhost/_charsets.erb new file mode 100644 index 000000000..ef83def4b --- /dev/null +++ b/templates/vhost/_charsets.erb @@ -0,0 +1,4 @@ +<% if @add_default_charset -%> + + AddDefaultCharset <%= @add_default_charset %> +<% end -%>