From 97dd750380de2176b6f43f8bc9c27ec8122cadd3 Mon Sep 17 00:00:00 2001 From: trianta Date: Sat, 10 Oct 2009 04:14:18 -0400 Subject: --- doc/sandbox.mdwn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index 242ffb327..e326319da 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -57,8 +57,10 @@ Bulleted list [[!progress percent=27]] +[[!progress percent=78]] + ----- -This SandBox is also a [[blog]]! +This **SandBox** is also a [[blog]]! [[!inline pages="sandbox/* and !*/Discussion" rootpage="sandbox" show="4" archive="yes"]] -- cgit v1.2.3 From 800d165037ee9bc3362e21048ab07bdd120dcfe0 Mon Sep 17 00:00:00 2001 From: Jogo Date: Sat, 10 Oct 2009 04:22:41 -0400 Subject: --- doc/plugins/lockedit/discussion.mdwn | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 doc/plugins/lockedit/discussion.mdwn diff --git a/doc/plugins/lockedit/discussion.mdwn b/doc/plugins/lockedit/discussion.mdwn new file mode 100644 index 000000000..b058b2b07 --- /dev/null +++ b/doc/plugins/lockedit/discussion.mdwn @@ -0,0 +1,21 @@ +This plugin not only locks pages but ensures too a user is logged in. This seems to me redundant with signedit. I propose : + + 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); + + if (defined $config{locked_pages} && length $config{locked_pages} && + pagespec_match($page, $config{locked_pages}, + user => $session->param("name"), + ip => $ENV{REMOTE_ADDR}, + )) { + return sprintf(gettext("%s is locked and cannot be edited"), + htmllink("", "", $page, noimageinline => 1)); + } + + return undef; + } -- cgit v1.2.3 From 9900d6164aca858587b1c603e2fdc53a78f880b9 Mon Sep 17 00:00:00 2001 From: Jogo Date: Sun, 11 Oct 2009 03:18:32 -0400 Subject: --- doc/sandbox.mdwn | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index e326319da..8aedcbb9e 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -1,10 +1,5 @@ This is the [[SandBox]], a page anyone can edit to try out ikiwiki (version [[!version ]]). -Here's a paragraph. - -Here's another one with *emphasised* text. - -test 2 # Header -- cgit v1.2.3 From 22ed3f388b6433c512ca7a026d868861ea1990ea Mon Sep 17 00:00:00 2001 From: Jogo Date: Sun, 11 Oct 2009 04:34:17 -0400 Subject: --- doc/plugins/contrib/groupfile.mdwn | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 doc/plugins/contrib/groupfile.mdwn diff --git a/doc/plugins/contrib/groupfile.mdwn b/doc/plugins/contrib/groupfile.mdwn new file mode 100644 index 000000000..e5c0ded42 --- /dev/null +++ b/doc/plugins/contrib/groupfile.mdwn @@ -0,0 +1,105 @@ +[[!template id=plugin name=groupfile core=0 author="[[Jogo]]"]] + +This plugin add a `group(groupname)` function to [[ikiwiki/PageSpec]], which is true +only if the actual user is member of the group named `groupname`. + +Groups membership are read from a file. The syntax of this file is very close to +usual `/etc/passwd` Unix file : the group's name, followed by a colon, followed by +a coma separated list of user's names. For exemple : + + dev:toto,foo + i18n:zorba + +----- + + #!/usr/bin/perl + # GroupFile plugin. + # by Joseph Boudou + + package IkiWiki::Plugin::groupfile; + + use warnings; + use strict; + use IkiWiki 3.00; + + sub import { + hook(type => 'getsetup', id => 'groups', call => \&get_setup); + } + + sub get_setup () { + return ( + plugin => { + safe => 0, + rebuild => 0, + }, + group_file => { + type => 'string', + example => '/etc/ikiwiki/group', + description => 'group file location', + safe => 0, + rebuild => 0, + }, + ); + } + + my $users_of = 0; + + sub get_groups () { + if (not $users_of) { + + if (not defined $config{group_file}) { + return 'group_file option not set'; + } + + open my $file, '<', $config{group_file} + or return 'Unable to open group_file'; + + $users_of = {}; + READ: + while (<$file>) { + next READ if (/^\s*$/); + + if (/^(\w+):([\w,]+)/) { + %{ $users_of->{$1} } = map { $_ => 1 } split /,/, $2; + } + else { + $users_of = "Error at group_file:$."; + last READ; + } + } + + close $file; + } + + return $users_of; + } + + package IkiWiki::PageSpec; + + sub match_group ($$;@) { + shift; + my $group = shift; + my %params = @_; + + if (not exists $params{user}) { + return IkiWiki::ErrorReason->new('no user specified'); + } + if (not defined $params{user}) { + return IkiWiki::FailReason->new('not logged in'); + } + + my $users_of = IkiWiki::Plugin::groupfile::get_groups(); + if (not ref $users_of) { + return IkiWiki::ErrorReason->new($users_of); + } + + if (exists $users_of->{$group}{ $params{user} }) { + return IkiWiki::SuccessReason->new("user is member of $group"); + } + else { + return IkiWiki::FailReason->new( + "user $params{user} isn't member of $group"); + } + } + + 1 -- cgit v1.2.3