Ajout : plugin IkiWiki createpage.pm
authorJulien Moutinho <julm@cyclocoop.org>
Wed, 24 Sep 2014 16:32:11 +0000 (18:32 +0200)
committerJulien Moutinho <julm@cyclocoop.org>
Wed, 24 Sep 2014 16:32:11 +0000 (18:32 +0200)
.ikiwiki/lib/IkiWiki/Plugin/createpage.pm [new file with mode: 0644]
ikiwiki.setup
local.css

diff --git a/.ikiwiki/lib/IkiWiki/Plugin/createpage.pm b/.ikiwiki/lib/IkiWiki/Plugin/createpage.pm
new file mode 100644 (file)
index 0000000..40594e1
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+       # This file is une extension à IkiWiki
+       # permettant d’ajouter une action de création de page aux pages.
+       # Copyright (C) 2014  Julien Moutinho
+       #
+       # This program is free software: you can redistribute it and/or modify
+       # it under the terms of the GNU General Public License as published
+       # by the Free Software Foundation, either version 3 of the License,
+       # or any later version.
+       #
+       # This program is distributed in the hope that it will be useful,
+       # but WITHOUT ANY WARRANTY; without even the implied warranty
+       # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+       # See the GNU General Public License for more details.
+       #
+       # You should have received a copy of the GNU General Public License
+       # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+package IkiWiki::Plugin::createpage;
+use strict;
+use warnings;
+use IkiWiki 3.00;
+sub import {
+       IkiWiki::hook
+        ( type => "getsetup"
+        , id   => "createpage"
+        , call => \&hook_preprocess_getsetup );
+       IkiWiki::hook
+        ( type => "pageactions"
+        , id   => "createpage"
+        , call => \&hook_preprocess_pageactions );
+ }
+sub hook_preprocess_getsetup () {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => 1,
+                       section => "misc",
+        },
+ }
+sub hook_preprocess_pageactions (@) {
+       my %params = @_;
+       my $page = $params{page};
+       my $form = "";
+       if ($IkiWiki::config{cgiurl}) {
+               $form =<<EOT;
+<form method="get" action="$IkiWiki::config{cgiurl}" id="newpageform">
+       <input type="hidden" name="from" value="$page"/>
+       <input type="text" name="page" value="" class="input" placeholder="Chemin/Nouvelle_page"/>
+       <button name="do" value="create" class="button">Créer</button>
+</form>
+EOT
+        }
+       return ($form);
+ }
+
+1;
index e23d544..5aae0fa 100644 (file)
@@ -106,6 +106,7 @@ BEGIN {
                 brokenlinks
                 comments
                 conditional
+                createpage
                 cutpaste
                 editdiff
                 editpage
index 36184e7..ca532ae 100644 (file)
--- a/local.css
+++ b/local.css
@@ -485,6 +485,27 @@ body {
        width:auto;
  }
 
+
+#newpageform {
+       margin: 0 0 0 0;
+       padding: 0 0 0 0;
+ }
+#newpageform button {
+       background-color:transparent;
+       border:none;
+       color:#005A9C;
+       font-family: sans-serif;
+       font-size: 100%;
+       margin: 0 0 0 0;
+       padding: 0 0 0 0;
+ }
+#newpageform input.input {
+       background-color:#eee;
+       border:0px solid #666;
+       margin: 0 0 0 0;
+       padding: 2px 2px 0 2px;
+ }
+
 @media print {
        #container #sidebar {
                display: none;