2 # Cookbook Name:: mediawiki
3 # Resource:: mediawiki_skin
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 # http://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 :skin, :kind_of => String, :name_attribute => true
23 property :site, :kind_of => String, :required => true
24 property :source, :kind_of => String
25 property :template, :kind_of => String
26 property :variables, :kind_of => Hash, :default => {}
27 property :version, :kind_of => String
28 property :repository, :kind_of => String
29 property :revision, :kind_of => String
30 property :update_site, :kind_of => [TrueClass, FalseClass], :default => true
33 if new_resource.source
34 remote_directory skin_directory do
36 source new_resource.source
37 owner node[:mediawiki][:user]
38 group node[:mediawiki][:group]
40 files_owner node[:mediawiki][:user]
41 files_group node[:mediawiki][:group]
45 skin_repository = new_resource.repository || default_repository
46 skin_revision = new_resource.revision || "REL#{skin_version}".tr(".", "_")
50 repository skin_repository
51 revision skin_revision
52 enable_submodules true
53 user node[:mediawiki][:user]
54 group node[:mediawiki][:group]
55 ignore_failure skin_repository.start_with?("git://github.com/wikimedia/mediawiki-skins")
59 if new_resource.template # ~FC023
60 declare_resource :template, "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.skin}.inc.php" do
62 source new_resource.template
63 user node[:mediawiki][:user]
64 group node[:mediawiki][:group]
66 variables new_resource.variables
69 skin_script = "#{skin_directory}/#{new_resource.skin}.php"
71 file "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.skin}.inc.php" do
72 content "<?php require_once('#{skin_script}');\n"
73 user node[:mediawiki][:user]
74 group node[:mediawiki][:group]
76 only_if { ::File.exist?(skin_script) }
82 directory skin_directory do
87 file "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.skin}.inc.php" do
94 node[:mediawiki][:sites][new_resource.site][:directory]
97 def mediawiki_directory
102 "#{mediawiki_directory}/skins/#{new_resource.skin}"
106 new_resource.version || node[:mediawiki][:sites][new_resource.site][:version]
109 def default_repository
110 "git://github.com/wikimedia/mediawiki-skins-#{new_resource.skin}.git"
116 notifies :update, "mediawiki_site[#{site}]"
118 site_directory = node[:mediawiki][:sites][site][:directory]
120 notifies :create, "template[#{site_directory}/w/LocalSettings.php]"
121 notifies :run, "execute[#{site_directory}/w/maintenance/update.php]"