summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-23 12:06:42 +0100
committerYorhel <git@yorhel.nl>2008-12-23 12:06:42 +0100
commitc59111e989844e670aea7a1e6af3bdd134e6cebc (patch)
tree13c2b72f8179e285baa365ea054f5123c8336699
parentc435aa0b2b60e785d2b5447e751c761736f8852c (diff)
Added skin selector to profile page
-rw-r--r--data/global.pl3
-rw-r--r--lib/VNDB/DB/Users.pm2
-rw-r--r--lib/VNDB/Handler/Users.pm7
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm3
-rw-r--r--util/dump.sql1
-rw-r--r--util/updates/update_2.1.sql4
6 files changed, 16 insertions, 4 deletions
diff --git a/data/global.pl b/data/global.pl
index bb4bfe4a..8b5b8297 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -13,11 +13,12 @@ our %O = (
# VNDB-specific options (object_data)
-our %S = (
+our %S = (%S,
version => `cd $VNDB::ROOT; git describe` =~ /^(.+)$/ && $1,
url => 'http://vndb.org',
url_static => 'http://s.vndb.org',
site_title => 'Yet another VNDB clone',
+ skin_default => 'test',
cookie_domain => '.vndb.org',
cookie_key => 'any-private-string-here',
sharedmem_key => 'VNDB',
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index 501bb8bb..6f1a13c6 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -64,7 +64,7 @@ sub dbUserEdit {
my %h;
defined $o{$_} && ($h{$_.' = ?'} = $o{$_})
- for (qw| username mail rank show_nsfw show_list |);
+ for (qw| username mail rank show_nsfw show_list skin |);
$h{'passwd = decode(?, \'hex\')'} = $o{passwd}
if defined $o{passwd};
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index daba59e6..10cf07ad 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -299,6 +299,7 @@ sub edit {
{ name => 'mail', template => 'mail' },
{ name => 'usrpass', required => 0, minlength => 4, maxlength => 64, template => 'asciiprint' },
{ name => 'usrpass2', required => 0, minlength => 4, maxlength => 64, template => 'asciiprint' },
+ { name => 'skin', enum => [ '', keys %{$self->{skins}} ], required => 0, default => '' },
{ name => 'flags_list', required => 0, default => 0 },
{ name => 'flags_nsfw', required => 0, default => 0 },
);
@@ -308,6 +309,7 @@ sub edit {
$o{username} = $frm->{usrname} if $frm->{usrname};
$o{rank} = $frm->{rank} if $frm->{rank};
$o{mail} = $frm->{mail};
+ $o{skin} = $frm->{skin};
$o{passwd} = md5_hex($frm->{usrpass}) if $frm->{usrpass};
$o{show_list} = $frm->{flags_list} ? 1 : 0;
$o{show_nsfw} = $frm->{flags_nsfw} ? 1 : 0;
@@ -321,6 +323,7 @@ sub edit {
$frm->{usrname} ||= $u->{username};
$frm->{rank} ||= $u->{rank};
$frm->{mail} ||= $u->{mail};
+ $frm->{skin} ||= $u->{skin};
$frm->{flags_list} = $u->{show_list} if !defined $frm->{flags_list};
$frm->{flags_nsfw} = $u->{show_nsfw} if !defined $frm->{flags_nsfw};
@@ -341,7 +344,7 @@ sub edit {
$self->authCan('usermod') ? (
[ input => short => 'usrname', name => 'Username' ],
[ select => short => 'rank', name => 'Rank', options => [
- map [ $_, $self->{user_ranks}[$_][0] ], 1..$#{$self->{user_ranks}} ] ],
+ map [ $_, $self->{user_ranks}[$_][0] ], 1..$#{$self->{user_ranks}} ] ],
) : (
[ static => label => 'Username', content => $frm->{usrname} ],
),
@@ -353,6 +356,8 @@ sub edit {
[ passwd => short => 'usrpass2', name => 'Confirm pass.' ],
[ part => title => 'Options' ],
+ [ select => short => 'skin', name => 'Prefered skin', options => [
+ map [ $_ eq $self->{skin_default} ? '' : $_, $self->{skins}{$_} ], sort keys %{$self->{skins}} ] ],
[ check => short => 'flags_list', name =>
qq|Allow other people to see my visual novel list (<a href="/u$uid/list">/u$uid/list</a>) |.
qq|and wishlist (<a href="/u$uid/wish">/u$uid/wish</a>)| ],
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index eb71b819..8f067a36 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -12,13 +12,14 @@ our @EXPORT = qw|htmlHeader htmlFooter|;
sub htmlHeader { # %options->{ title, js, noindex, search }
my($self, %o) = @_;
+ my $skin = $self->authInfo->{skin} || $self->{skin_default};
# heading
html;
head;
title $o{title};
Link rel => 'shortcut icon', href => '/favicon.ico', type => 'image/x-icon';
- Link rel => 'stylesheet', href => $self->{url_static}.'/s/test/style.css', type => 'text/css', media => 'all';
+ Link rel => 'stylesheet', href => $self->{url_static}.'/s/'.$skin.'/style.css', type => 'text/css', media => 'all';
if($o{js}) {
script type => 'text/javascript', src => $self->{url_static}.'/f/forms.js'; end;
}
diff --git a/util/dump.sql b/util/dump.sql
index 848ddd34..b8c7fa54 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -185,6 +185,7 @@ CREATE TABLE users (
show_list boolean NOT NULL DEFAULT TRUE,
c_votes integer NOT NULL DEFAULT 0,
c_changes integer NOT NULL DEFAULT 0
+ skin varchar(128) NOT NULL DEFAULT '',
);
-- vn
diff --git a/util/updates/update_2.1.sql b/util/updates/update_2.1.sql
new file mode 100644
index 00000000..7ae8fecf
--- /dev/null
+++ b/util/updates/update_2.1.sql
@@ -0,0 +1,4 @@
+
+-- skin selector
+ALTER TABLE users ADD COLUMN skin varchar(128) NOT NULL DEFAULT '';
+