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.reference
41 new_resource.reference
42 elsif new_resource.tag
43 "refs/tags/#{new_resource.tag}"
45 "REL#{extension_version}".tr(".", "_")
48 git extension_directory do
50 repository extension_repository
51 reference extension_reference
52 enable_submodules true
53 user node[:mediawiki][:user]
54 group node[:mediawiki][:group]
55 ignore_failure extension_repository.start_with?("git://github.com/wikimedia/mediawiki-extensions")
59 if new_resource.template # ~FC023
60 template "#{mediawiki_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
62 source new_resource.template
63 user node[:mediawiki][:user]
64 group node[:mediawiki][:group]
66 variables new_resource.variables
69 extension_script = "#{extension_directory}/#{new_resource.name}.php"
71 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
73 content "<?php wfLoadExtension( '#{new_resource.name}' );\n"
74 user node[:mediawiki][:user]
75 group node[:mediawiki][:group]
77 only_if { ::File.exist?(extension_script) }
83 directory extension_directory do
88 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
96 node[:mediawiki][:sites][new_resource.site][:directory]
99 def mediawiki_directory
100 "#{site_directory}/w"
103 def extension_directory
104 "#{mediawiki_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"