prefs page implemented
parent
b7d3a12c5c
commit
5fe80a6371
|
@ -2,6 +2,8 @@ ikiwiki uses the HTML::Template module as its template engine. This
|
||||||
supports things like conditionals and loops in templates and is pretty easy
|
supports things like conditionals and loops in templates and is pretty easy
|
||||||
to learn.
|
to learn.
|
||||||
|
|
||||||
|
I aim to keep almost all html out of ikiwiki and in the templates.
|
||||||
|
|
||||||
It ships with some basic templates which can be customised:
|
It ships with some basic templates which can be customised:
|
||||||
|
|
||||||
* `templates/page.tmpl` - Used for displaying all regular wiki pages.
|
* `templates/page.tmpl` - Used for displaying all regular wiki pages.
|
||||||
|
@ -12,15 +14,17 @@ It ships with some basic templates which can be customised:
|
||||||
* `templates/passwordmail.tmpl` - Not a html template, this is used to
|
* `templates/passwordmail.tmpl` - Not a html template, this is used to
|
||||||
generate the mail with the user's password in it.
|
generate the mail with the user's password in it.
|
||||||
|
|
||||||
If you like, you can add this to further customise it:
|
If you like, you can add these to further customise it:
|
||||||
|
|
||||||
* `templates/signin.tmpl` - If it exists, it is used for customising the
|
* `templates/signin.tmpl` - If it exists, it is used for customising the
|
||||||
layout of the SignIn form and all assciated forms. The misc.tmpl is
|
layout of the SignIn form and all assciated forms. The misc.tmpl is
|
||||||
wrapped around this, so it should only be a template for the form.
|
wrapped around this, so it should only be a template for the form.
|
||||||
|
* `templates/prefs.tmpl` - If it exists, it is used for customising the
|
||||||
|
layout of the Prefs form and all assciated forms. The misc.tmpl is
|
||||||
|
wrapped around this, so it should only be a template for the form.
|
||||||
|
|
||||||
Note that the SignIn form is implemented using CGI::FormBuilder, which
|
Note that the SignIn and Prefs forms are implemented using
|
||||||
interfaces to HTML::Template, so not all of it can be customised with
|
CGI::FormBuilder, which interfaces to HTML::Template, so not all of it can
|
||||||
templates, although most of it can, by creating this template. Without
|
be customised with templates, although most of it can, by creating these
|
||||||
the template, CGI::FormBuilder creates the page body by itself.
|
templates. Without the templates, CGI::FormBuilder creates the page bodies
|
||||||
|
by itself.
|
||||||
I aim to keep almost all html out of ikiwiki and in the templates.
|
|
||||||
|
|
|
@ -110,10 +110,6 @@ Some wikis will need the abiity to lock a page, or the whole wiki, so that only
|
||||||
|
|
||||||
Probably it's ok if locking is only supported for web commits.
|
Probably it's ok if locking is only supported for web commits.
|
||||||
|
|
||||||
## User settings page
|
|
||||||
|
|
||||||
A cgi page to allow a user to log out and to edit their prefs, including password, email, and anything we add later (subscriptions, etc).
|
|
||||||
|
|
||||||
## Logo
|
## Logo
|
||||||
|
|
||||||
ikiwiki needs a logo. I'm thinking something simple like the word "ikiwiki" with the first "k" backwards; drawn to show that it's "wiki" reflected.
|
ikiwiki needs a logo. I'm thinking something simple like the word "ikiwiki" with the first "k" backwards; drawn to show that it's "wiki" reflected.
|
||||||
|
|
90
ikiwiki
90
ikiwiki
|
@ -339,6 +339,7 @@ sub finalize ($$$) { #{{{
|
||||||
|
|
||||||
if (length $config{cgiurl}) {
|
if (length $config{cgiurl}) {
|
||||||
$template->param(editurl => "$config{cgiurl}?do=edit&page=$page");
|
$template->param(editurl => "$config{cgiurl}?do=edit&page=$page");
|
||||||
|
$template->param(prefsurl => "$config{cgiurl}?do=prefs");
|
||||||
if ($config{svn}) {
|
if ($config{svn}) {
|
||||||
$template->param(recentchangesurl => "$config{cgiurl}?do=recentchanges");
|
$template->param(recentchangesurl => "$config{cgiurl}?do=recentchanges");
|
||||||
}
|
}
|
||||||
|
@ -883,7 +884,26 @@ sub userinfo_get ($$) { #{{{
|
||||||
return $userdata->{$user}->{$field};
|
return $userdata->{$user}->{$field};
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
sub userinfo_set ($$) { #{{{
|
sub userinfo_set ($$$) { #{{{
|
||||||
|
my $user=shift;
|
||||||
|
my $field=shift;
|
||||||
|
my $value=shift;
|
||||||
|
|
||||||
|
eval q{use Storable};
|
||||||
|
my $userdata=eval{ Storable::lock_retrieve("$config{srcdir}/.ikiwiki/userdb") };
|
||||||
|
if (! defined $userdata || ! ref $userdata ||
|
||||||
|
! exists $userdata->{$user} || ! ref $userdata->{$user}) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$userdata->{$user}->{$field}=$value;
|
||||||
|
my $oldmask=umask(077);
|
||||||
|
my $ret=Storable::lock_store($userdata, "$config{srcdir}/.ikiwiki/userdb");
|
||||||
|
umask($oldmask);
|
||||||
|
return $ret;
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
sub userinfo_setall ($$) { #{{{
|
||||||
my $user=shift;
|
my $user=shift;
|
||||||
my $info=shift;
|
my $info=shift;
|
||||||
|
|
||||||
|
@ -905,7 +925,7 @@ sub cgi_signin ($$) { #{{{
|
||||||
|
|
||||||
eval q{use CGI::FormBuilder};
|
eval q{use CGI::FormBuilder};
|
||||||
my $form = CGI::FormBuilder->new(
|
my $form = CGI::FormBuilder->new(
|
||||||
title => "$config{wikiname} signin",
|
title => "signin",
|
||||||
fields => [qw(do page from name password confirm_password email)],
|
fields => [qw(do page from name password confirm_password email)],
|
||||||
header => 1,
|
header => 1,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
|
@ -932,7 +952,7 @@ sub cgi_signin ($$) { #{{{
|
||||||
$form->field(name => "confirm_password", type => "password", required => 0);
|
$form->field(name => "confirm_password", type => "password", required => 0);
|
||||||
$form->field(name => "email", required => 0);
|
$form->field(name => "email", required => 0);
|
||||||
if ($q->param("do") ne "signin") {
|
if ($q->param("do") ne "signin") {
|
||||||
$form->text("You need to log in before you can edit pages.");
|
$form->text("You need to log in first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->submitted) {
|
if ($form->submitted) {
|
||||||
|
@ -1010,7 +1030,7 @@ sub cgi_signin ($$) { #{{{
|
||||||
}
|
}
|
||||||
elsif ($form->submitted eq 'Register') {
|
elsif ($form->submitted eq 'Register') {
|
||||||
my $user_name=$form->field('name');
|
my $user_name=$form->field('name');
|
||||||
if (userinfo_set($user_name, {
|
if (userinfo_setall($user_name, {
|
||||||
'email' => $form->field('email'),
|
'email' => $form->field('email'),
|
||||||
'password' => $form->field('password'),
|
'password' => $form->field('password'),
|
||||||
'regdate' => time
|
'regdate' => time
|
||||||
|
@ -1059,6 +1079,64 @@ sub cgi_signin ($$) { #{{{
|
||||||
}
|
}
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
sub cgi_prefs ($$) { #{{{
|
||||||
|
my $q=shift;
|
||||||
|
my $session=shift;
|
||||||
|
|
||||||
|
eval q{use CGI::FormBuilder};
|
||||||
|
my $form = CGI::FormBuilder->new(
|
||||||
|
title => "preferences",
|
||||||
|
fields => [qw(do name password confirm_password email)],
|
||||||
|
header => 0,
|
||||||
|
method => 'POST',
|
||||||
|
validate => {
|
||||||
|
confirm_password => {
|
||||||
|
perl => q{eq $form->field("password")},
|
||||||
|
},
|
||||||
|
email => 'EMAIL',
|
||||||
|
},
|
||||||
|
required => 'NONE',
|
||||||
|
javascript => 0,
|
||||||
|
params => $q,
|
||||||
|
action => $q->request_uri,
|
||||||
|
template => (-e "$config{templatedir}/prefs.tmpl" ?
|
||||||
|
"$config{templatedir}/prefs.tmpl" : "")
|
||||||
|
);
|
||||||
|
my @buttons=("Save Preferences", "Logout", "Cancel");
|
||||||
|
|
||||||
|
my $user_name=$session->param("name");
|
||||||
|
$form->field(name => "do", type => "hidden");
|
||||||
|
$form->field(name => "name", disabled => 1,
|
||||||
|
value => $user_name, force => 1);
|
||||||
|
$form->field(name => "password", type => "password");
|
||||||
|
$form->field(name => "confirm_password", type => "password");
|
||||||
|
|
||||||
|
if (! $form->submitted) {
|
||||||
|
$form->field(name => "email", value => userinfo_get($user_name, "email"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($form->submitted eq 'Logout') {
|
||||||
|
$session->delete();
|
||||||
|
print $q->redirect($config{url});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elsif ($form->submitted eq 'Cancel') {
|
||||||
|
print $q->redirect($config{url});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elsif ($form->submitted eq "Save Preferences" && $form->validate) {
|
||||||
|
foreach my $field (qw(password email)) {
|
||||||
|
if (length $form->field($field)) {
|
||||||
|
userinfo_set($user_name, $field, $form->field($field)) || error("failed to set $field");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$form->text("Preferences saved.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print $session->header();
|
||||||
|
print misctemplate($form->title, $form->render(submit => \@buttons));
|
||||||
|
} #}}}
|
||||||
|
|
||||||
sub cgi_editpage ($$) { #{{{
|
sub cgi_editpage ($$) { #{{{
|
||||||
my $q=shift;
|
my $q=shift;
|
||||||
my $session=shift;
|
my $session=shift;
|
||||||
|
@ -1268,6 +1346,7 @@ sub cgi () { #{{{
|
||||||
|
|
||||||
# Everything below this point needs the user to be signed in.
|
# Everything below this point needs the user to be signed in.
|
||||||
if ((! $config{anonok} && ! defined $session->param("name") ||
|
if ((! $config{anonok} && ! defined $session->param("name") ||
|
||||||
|
! defined $session->param("name") ||
|
||||||
! userinfo_get($session->param("name"), "regdate")) || $do eq 'signin') {
|
! userinfo_get($session->param("name"), "regdate")) || $do eq 'signin') {
|
||||||
cgi_signin($q, $session);
|
cgi_signin($q, $session);
|
||||||
|
|
||||||
|
@ -1282,6 +1361,9 @@ sub cgi () { #{{{
|
||||||
if ($do eq 'create' || $do eq 'edit') {
|
if ($do eq 'create' || $do eq 'edit') {
|
||||||
cgi_editpage($q, $session);
|
cgi_editpage($q, $session);
|
||||||
}
|
}
|
||||||
|
elsif ($do eq 'prefs') {
|
||||||
|
cgi_prefs($q, $session);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
error("unknown do parameter");
|
error("unknown do parameter");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
<a href="<TMPL_VAR HISTORYURL>">History</a>
|
<a href="<TMPL_VAR HISTORYURL>">History</a>
|
||||||
</TMPL_IF>
|
</TMPL_IF>
|
||||||
|
|
||||||
|
<TMPL_IF NAME="PREFSURL">
|
||||||
|
<a href="<TMPL_VAR PREFSURL>">Preferences</a>
|
||||||
|
</TMPL_IF>
|
||||||
|
|
||||||
<TMPL_VAR DISCUSSIONLINK><br>
|
<TMPL_VAR DISCUSSIONLINK><br>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
Loading…
Reference in New Issue