From 53a0d7379d093ae48e328598511701eef18792c1 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Sun, 17 May 2015 19:11:18 -0400 Subject: [PATCH] Added the ability to define the IndexStyleSheet setting for a directory --- README.md | 24 +++++++++++++++++++++--- spec/defines/vhost_spec.rb | 14 ++++++++++++++ templates/vhost/_directories.erb | 3 +++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 268b071b1..2d656a024 100644 --- a/README.md +++ b/README.md @@ -1924,9 +1924,10 @@ Allows configuration settings for [directory indexing](http://httpd.apache.org/d apache::vhost { 'sample.example.net': docroot => '/path/to/directory', directories => [ - { path => '/path/to/directory', - options => ['Indexes','FollowSymLinks','MultiViews'], - index_options => ['IgnoreCase', 'FancyIndexing', 'FoldersFirst', 'NameWidth=*', 'DescriptionWidth=*', 'SuppressHTMLPreamble'], + { path => '/path/to/directory', + directoryindex => 'disabled', # this is needed on Apache 2.4 or mod_autoindex doesn't work + options => ['Indexes','FollowSymLinks','MultiViews'], + index_options => ['IgnoreCase', 'FancyIndexing', 'FoldersFirst', 'NameWidth=*', 'DescriptionWidth=*', 'SuppressHTMLPreamble'], }, ], } @@ -1948,6 +1949,23 @@ Sets the [default ordering](http://httpd.apache.org/docs/current/mod/mod_autoind } ``` +######`index_style_sheet` + +Sets the [IndexStyleSheet](http://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexstylesheet) which adds a CSS stylesheet to the directory index. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + options => ['Indexes','FollowSymLinks','MultiViews'], + index_options => ['FancyIndexing'], + index_style_sheet => '/styles/style.css', + }, + ], + } +``` + ######`options` Lists the [Options](http://httpd.apache.org/docs/current/mod/core.html#options) for the given Directory block. diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 816fd99a1..73836d350 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -183,6 +183,12 @@ 'provider' => 'files', 'require' => 'all granted', }, + { 'path' => '/var/www/files/indexed_directory', + 'directoryindex' => 'disabled', + 'options' => ['Indexes','FollowSymLinks','MultiViews'], + 'index_options' => ['FancyIndexing'], + 'index_style_sheet' => '/styles/style.css', + }, ], 'error_log' => false, 'error_log_file' => 'httpd_error_log', @@ -360,6 +366,14 @@ :content => /^\s+Require all denied$/ ) } it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with( :content => /^\s+Require all granted$/ ) } + it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with( + :content => /^\s+Options\sIndexes\sFollowSymLinks\sMultiViews$/ ) } + it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with( + :content => /^\s+IndexOptions\sFancyIndexing$/ ) } + it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with( + :content => /^\s+IndexStyleSheet\s'\/styles\/style\.css'$/ ) } + it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with( + :content => /^\s+DirectoryIndex\sdisabled$/ ) } it { is_expected.to contain_concat__fragment('rspec.example.com-additional_includes') } it { is_expected.to contain_concat__fragment('rspec.example.com-logging') } it { is_expected.to contain_concat__fragment('rspec.example.com-serversignature') } diff --git a/templates/vhost/_directories.erb b/templates/vhost/_directories.erb index 1f45d2c0e..529d9bdff 100644 --- a/templates/vhost/_directories.erb +++ b/templates/vhost/_directories.erb @@ -46,6 +46,9 @@ <%- end -%> <%- if directory['index_order_default'] -%> IndexOrderDefault <%= Array(directory['index_order_default']).join(' ') %> + <%- end -%> + <%- if directory['index_style_sheet'] -%> + IndexStyleSheet '<%= directory['index_style_sheet'] %>' <%- end -%> <%- if directory['allow_override'] -%> AllowOverride <%= Array(directory['allow_override']).join(' ') %>