2 # Cookbook Name:: mediawiki
3 # Provider:: 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.
27 if new_resource.source
28 remote_directory skin_directory do
30 source new_resource.source
31 owner node[:mediawiki][:user]
32 group node[:mediawiki][:group]
34 files_owner node[:mediawiki][:user]
35 files_group node[:mediawiki][:group]
39 skin_repository = new_resource.repository || default_repository
40 skin_reference = if new_resource.tag
41 "refs/tags/#{new_resource.tag}"
43 "REL#{skin_version}".tr(".", "_")
48 repository skin_repository
49 reference skin_reference
50 enable_submodules true
51 user node[:mediawiki][:user]
52 group node[:mediawiki][:group]
53 ignore_failure skin_repository.start_with?("git://github.com/wikimedia/mediawiki-skins")
57 if new_resource.template # ~FC023
58 template "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.name}.inc.php" do
60 source new_resource.template
61 user node[:mediawiki][:user]
62 group node[:mediawiki][:group]
64 variables new_resource.variables
67 skin_script = "#{skin_directory}/#{new_resource.name}.php"
69 file "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.name}.inc.php" do
71 content "<?php require_once('#{skin_script}');\n"
72 user node[:mediawiki][:user]
73 group node[:mediawiki][:group]
75 only_if { ::File.exist?(skin_script) }
81 directory skin_directory do
86 file "#{mediawiki_directory}/LocalSettings.d/Skin-#{new_resource.name}.inc.php" do
94 node[:mediawiki][:sites][new_resource.site][:directory]
97 def mediawiki_directory
102 "#{mediawiki_directory}/skins/#{new_resource.name}"
106 new_resource.version || node[:mediawiki][:sites][new_resource.site][:version]
109 def default_repository
110 "git://github.com/wikimedia/mediawiki-skins-#{new_resource.name}.git"