2 # Cookbook Name:: mediawiki
3 # Definition:: mediawiki_extension
5 # Copyright 2013, 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 define :mediawiki_extension, :action => [ :enable ] do
23 site_directory = node[:mediawiki][:sites][site][:site_directory]
24 mediawiki_directory = node[:mediawiki][:sites][site][:directory]
25 extension_directory = "#{mediawiki_directory}/extensions/#{name}"
26 source = params[:source]
27 template = params[:template]
30 remote_directory extension_directory do
33 owner node[:mediawiki][:user]
34 group node[:mediawiki][:group]
36 files_owner node[:mediawiki][:user]
37 files_group node[:mediawiki][:group]
41 repository = params[:repository] || "git://github.com/wikimedia/mediawiki-extensions-#{name}.git"
42 version = params[:version] || node[:mediawiki][:sites][site][:version]
45 reference = "refs/tags/#{tag}"
47 reference = "refs/heads/REL#{version}".tr(".", "_")
50 git extension_directory do
55 enable_submodules true
56 user node[:mediawiki][:user]
57 group node[:mediawiki][:group]
58 ignore_failure repository.start_with?("git://github.com/wikimedia/mediawiki-extensions")
59 notifies :run, resources(:execute => "#{mediawiki_directory}/maintenance/update.php")
64 template "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
67 user node[:mediawiki][:user]
68 group node[:mediawiki][:group]
70 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")
74 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
75 action :create_if_missing
76 user node[:mediawiki][:user]
77 group node[:mediawiki][:group]
79 content "<?php require_once('#{extension_directory}/#{name}.php');\n"
80 only_if do File.exist?("#{extension_directory}/#{name}.php") end
81 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")