diff options
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/anonok.pm | 16 | ||||
-rw-r--r-- | IkiWiki/Plugin/lockedit.pm | 61 | ||||
-rw-r--r-- | IkiWiki/Plugin/opendiscussion.pm | 22 | ||||
-rw-r--r-- | IkiWiki/Plugin/openid.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Plugin/passwordauth.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Plugin/signinedit.pm | 25 | ||||
-rw-r--r-- | IkiWiki/Plugin/skeleton.pm | 9 |
7 files changed, 135 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/anonok.pm b/IkiWiki/Plugin/anonok.pm new file mode 100644 index 000000000..3e2a746e6 --- /dev/null +++ b/IkiWiki/Plugin/anonok.pm @@ -0,0 +1,16 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::anonok; + +use warnings; +use strict; +use IkiWiki; + +sub import { #{{{ + hook(type => "canedit", id => "anonok", call => \&canedit,); +} # }}} + +sub canedit ($$$) { #{{{ + return ""; +} #}}} + +1 diff --git a/IkiWiki/Plugin/lockedit.pm b/IkiWiki/Plugin/lockedit.pm new file mode 100644 index 000000000..587f7ee54 --- /dev/null +++ b/IkiWiki/Plugin/lockedit.pm @@ -0,0 +1,61 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::lockedit; + +use warnings; +use strict; +use IkiWiki; + +sub import { #{{{ + hook(type => "canedit", id => "lockedit", call => \&canedit); + hook(type => "formbuilder_setup", id => "lockedit", + call => \&formbuilder_setup); +} # }}} + +sub canedit ($$) { #{{{ + my $page=shift; + my $cgi=shift; + my $session=shift; + + my $user=$session->param("name"); + return undef if defined $user && IkiWiki::is_admin($user); + + foreach my $admin (@{$config{adminuser}}) { + if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"))) { + return sprintf(gettext("%s is locked by %s and cannot be edited"), + htmllink("", "", $page, 1), + IkiWiki::userlink($admin)); + } + } + + return undef; +} #}}} + +sub formbuilder_setup (@) { #{{{ + my %params=@_; + + my $form=$params{form}; + my $session=$params{session}; + my $cgi=$params{cgi}; + my $user_name=$session->param("name"); + + if ($form->title eq "preferences") { + $form->field(name => "locked_pages", size => 50, + comment => "(".htmllink("", "", "PageSpec", 1).")"); + if (! IkiWiki::is_admin($user_name)) { + $form->field(name => "locked_pages", type => "hidden"); + } + if (! $form->submitted) { + $form->field(name => "locked_pages", force => 1, + value => IkiWiki::userinfo_get($user_name, "locked_pages")); + } + if ($form->submitted && $form->submitted eq 'Save Preferences') { + if (defined $form->field("locked_pages")) { + IkiWiki::userinfo_set($user_name, "locked_pages", + $form->field("locked_pages")) || + error("failed to set locked_pages"); + } + } + } +} #}}} + +1 diff --git a/IkiWiki/Plugin/opendiscussion.pm b/IkiWiki/Plugin/opendiscussion.pm new file mode 100644 index 000000000..4b1a432b2 --- /dev/null +++ b/IkiWiki/Plugin/opendiscussion.pm @@ -0,0 +1,22 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::opendiscussion; + +use warnings; +use strict; +use IkiWiki; + +sub import { #{{{ + hook(type => "canedit", id => "opendiscussion", call => \&canedit); +} # }}} + +sub canedit ($$) { #{{{ + my $page=shift; + my $cgi=shift; + my $session=shift; + + my $discussion=gettext("discussion"); + return "" if $page=~/\/\Q$discussion\E$/; + return undef; +} #}}} + +1 diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 4a7255069..5d387fbc6 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -59,7 +59,7 @@ sub formbuilder_setup (@) { #{{{ elsif ($form->title eq "preferences") { if (! defined $form->field(name => "name")) { $form->field(name => "OpenID", disabled => 1, value => - $session->param("name"), size => 30, force => 1); + $session->param("name"), size => 50, force => 1); } } } diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index 7ffc12080..3007dd4ff 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -21,7 +21,7 @@ sub formbuilder_setup (@) { #{{{ my $cgi=$params{cgi}; if ($form->title eq "signin" || $form->title eq "register") { - $form->field(name => "name", required => 0, size => 30); + $form->field(name => "name", required => 0, size => 50); $form->field(name => "password", type => "password", required => 0); if ($form->submitted eq "Register" || $form->submitted eq "Create Account") { diff --git a/IkiWiki/Plugin/signinedit.pm b/IkiWiki/Plugin/signinedit.pm new file mode 100644 index 000000000..04532f4dc --- /dev/null +++ b/IkiWiki/Plugin/signinedit.pm @@ -0,0 +1,25 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::signinedit; + +use warnings; +use strict; +use IkiWiki; + +sub import { #{{{ + hook(type => "canedit", id => "signinedit", call => \&canedit, + last => 1); +} # }}} + +sub canedit ($$$) { #{{{ + my $page=shift; + my $cgi=shift; + my $session=shift; + + # Have the user sign in, if they are not already. This is why the + # hook runs last, so that any hooks that don't need the user to + # signin can override this. + IkiWiki::needsignin($cgi, $session); + return ""; +} #}}} + +1 diff --git a/IkiWiki/Plugin/skeleton.pm b/IkiWiki/Plugin/skeleton.pm index feb0f7419..06b184b0a 100644 --- a/IkiWiki/Plugin/skeleton.pm +++ b/IkiWiki/Plugin/skeleton.pm @@ -21,6 +21,7 @@ sub import { #{{{ hook(type => "change", id => "skeleton", call => \&change); hook(type => "cgi", id => "skeleton", call => \&cgi); hook(type => "auth", id => "skeleton", call => \&auth); + hook(type => "canedit", id => "skeleton", call => \&canedit); hook(type => "formbuilder_setup", id => "skeleton", call => \&formbuilder_setup); hook(type => "formbuilder", id => "skeleton", call => \&formbuilder); hook(type => "savestate", id => "savestate", call => \&savestate); @@ -105,6 +106,14 @@ sub auth ($$) { #{{{ debug("skeleton plugin running in auth"); } #}}} +sub canedit ($$$) { #{{{ + my $page=shift; + my $cgi=shift; + my $session=shift; + + debug("skeleton plugin running in canedit"); +} #}}} + sub formbuilder_setup (@) { #{{{ my %params=@_; |