2 # Cookbook Name:: mediawiki
3 # Provider:: mediawiki_extension
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 extension_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 extension_repository = new_resource.repository || default_repository
40 extension_reference = if new_resource.tag
41 "refs/tags/#{new_resource.tag}"
43 "refs/heads/REL#{extension_version}".tr(".", "_")
46 git extension_directory do
48 repository extension_repository
49 reference extension_reference
50 enable_submodules true
51 user node[:mediawiki][:user]
52 group node[:mediawiki][:group]
53 ignore_failure extension_repository.start_with?("git://github.com/wikimedia/mediawiki-extensions")
57 if new_resource.template # ~FC023
58 template "#{site_directory}/LocalSettings.d/Ext-#{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
68 extension_script = "#{extension_directory}/#{new_resource.name}.php"
70 file "#{site_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
72 content "<?php require_once('#{extension_script}');\n"
73 user node[:mediawiki][:user]
74 group node[:mediawiki][:group]
76 only_if { ::File.exist?(extension_script) }
81 directory extension_directory do
86 if new_resource.template # ~FC023
87 file "#{site_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
92 file "#{site_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
100 node[:mediawiki][:sites][new_resource.site][:directory]
103 def extension_directory
104 "#{site_directory}/extensions/#{new_resource.name}"
107 def extension_version
108 new_resource.version || node[:mediawiki][:sites][new_resource.site][:version]
111 def default_repository
112 "git://github.com/wikimedia/mediawiki-extensions-#{new_resource.name}.git"