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 "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 "#{mediawiki_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
67 extension_script = "#{extension_directory}/#{new_resource.name}.php"
69 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
71 content "<?php require_once('#{extension_script}');\n"
72 user node[:mediawiki][:user]
73 group node[:mediawiki][:group]
75 only_if { ::File.exist?(extension_script) }
81 directory extension_directory do
86 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{new_resource.name}.inc.php" do
94 node[:mediawiki][:sites][new_resource.site][:directory]
97 def mediawiki_directory
101 def extension_directory
102 "#{mediawiki_directory}/extensions/#{new_resource.name}"
105 def extension_version
106 new_resource.version || node[:mediawiki][:sites][new_resource.site][:version]
109 def default_repository
110 "git://github.com/wikimedia/mediawiki-extensions-#{new_resource.name}.git"