3 # Resource:: wordpress_theme
5 # Copyright:: 2015, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 default_action :create
22 property :theme, :kind_of => String, :name_property => true
23 property :site, :kind_of => String, :required => true
24 property :source, :kind_of => String
25 property :version, :kind_of => String
26 property :repository, :kind_of => String
27 property :revision, :kind_of => String
28 property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true
31 if new_resource.source
32 remote_directory theme_directory do
34 source new_resource.source
35 owner node[:wordpress][:user]
36 group node[:wordpress][:group]
38 files_owner node[:wordpress][:user]
39 files_group node[:wordpress][:group]
43 theme_repository = new_resource.repository || default_repository
45 if theme_repository.end_with?(".git")
46 git theme_directory do
48 repository theme_repository
49 revision new_resource.revision
50 user node[:wordpress][:user]
51 group node[:wordpress][:group]
54 subversion theme_directory do
56 repository theme_repository
57 user node[:wordpress][:user]
58 group node[:wordpress][:group]
59 ignore_failure theme_repository.start_with?("https://themes.svn.wordpress.org/")
66 directory theme_directory do
74 node[:wordpress][:sites][new_resource.site][:directory]
78 "#{site_directory}/wp-content/themes/#{new_resource.theme}"
81 def default_repository
82 "https://themes.svn.wordpress.org/#{new_resource.theme}/#{new_resource.version}"
87 notifies :reload, "service[apache2]" if reload_apache