supprimé
[cyclowiki.git] / .ikiwiki / lib / IkiWiki / Plugin / createpage.pm
1 #!/usr/bin/perl
2 # This file is une extension à IkiWiki
3 # permettant d’ajouter une action de création de page aux pages.
4 # Copyright (C) 2014 Julien Moutinho
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published
8 # by the Free Software Foundation, either version 3 of the License,
9 # or any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty
13 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package IkiWiki::Plugin::createpage;
19 use strict;
20 use warnings;
21 use IkiWiki 3.00;
22 sub import {
23 IkiWiki::hook
24 ( type => "getsetup"
25 , id => "createpage"
26 , call => \&hook_preprocess_getsetup );
27 IkiWiki::hook
28 ( type => "pageactions"
29 , id => "createpage"
30 , call => \&hook_preprocess_pageactions );
31 }
32 sub hook_preprocess_getsetup () {
33 return
34 plugin => {
35 safe => 1,
36 rebuild => 1,
37 section => "misc",
38 },
39 }
40 sub hook_preprocess_pageactions (@) {
41 my %params = @_;
42 my $page = $params{page};
43 my $form = "";
44 if ($IkiWiki::config{cgiurl}) {
45 $form =<<EOT;
46 <form method="get" action="$IkiWiki::config{cgiurl}" id="newpageform">
47 <input type="hidden" name="from" value="$page"/>
48 <input type="text" name="page" value="" class="input" placeholder="Chemin/Nouvelle_page"/>
49 <button name="do" value="create" class="button">Créer</button>
50 </form>
51 EOT
52 }
53 return ($form);
54 }
55
56 1;