summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-07-21 03:15:57 +0200
committerYorhel <git@yorhel.nl>2015-07-21 03:15:57 +0200
commit6f15f1d2d1f23983e0262e8e9565356dc9a2c4e7 (patch)
tree8e98469103f1e6f55a96df808310cb8cc6cb54e7 /lib/VNDB
parent0032d62652c6168316fd9429d17604b61a812598 (diff)
Add profile option for default visible tag categories on VN pages
The name of the profile setting isn't very clear. Not sure what to do with it.
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/Handler/Users.pm7
-rw-r--r--lib/VNDB/Handler/VNPage.pm5
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index 32b1d205..0068768d 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -375,6 +375,7 @@ sub edit {
{ post => 'hide_list', required => 0, default => 0, enum => [0,1] },
{ post => 'show_nsfw', required => 0, default => 0, enum => [0,1] },
{ post => 'tags_all', required => 0, default => 0, enum => [0,1] },
+ { post => 'tags_cat', required => 0, multi => 1, enum => [qw|cont ero tech|] },
{ post => 'skin', required => 0, default => $self->{skin_default}, enum => [ keys %{$self->{skins}} ] },
{ post => 'customcss', required => 0, maxlength => 2000, default => '' },
);
@@ -383,6 +384,9 @@ sub edit {
if(!$frm->{_err}) {
$frm->{skin} = '' if $frm->{skin} eq $self->{skin_default};
$self->dbUserPrefSet($uid, $_ => $frm->{$_}) for (qw|skin customcss show_nsfw tags_all hide_list |);
+
+ my $tags_cat = join(',', sort @{$frm->{tags_cat}}) || 'none';
+ $self->dbUserPrefSet($uid, tags_cat => $tags_cat eq $self->{default_tags_cat} ? '' : $tags_cat);
my %o;
if($self->authCan('usermod')) {
$o{username} = $frm->{usrname} if $frm->{usrname};
@@ -402,6 +406,7 @@ sub edit {
$frm->{mail} ||= $u->{mail};
$frm->{perms} ||= [ grep $u->{perm} & $self->{permissions}{$_}, keys %{$self->{permissions}} ];
$frm->{$_} //= $u->{prefs}{$_} for(qw|skin customcss show_nsfw tags_all hide_list|);
+ $frm->{tags_cat} ||= [ split /,/, $u->{prefs}{tags_cat}||$self->{default_tags_cat} ];
$frm->{ign_votes} = $u->{ign_votes} if !defined $frm->{ign_votes};
$frm->{skin} ||= $self->{skin_default};
@@ -437,6 +442,8 @@ sub edit {
[ check => short => 'hide_list', name => mt '_usere_flist', "/u$uid/list", "/u$uid/votes", "/u$uid/wish" ],
[ check => short => 'show_nsfw', name => mt '_usere_fnsfw' ],
[ check => short => 'tags_all', name => mt '_usere_ftags' ],
+ [ select => short => 'tags_cat', name => mt('_usere_tagcats'), multi => 1, size => 3, options => [
+ map [ $_, mt '_tagcat_'.$_ ], qw|cont ero tech| ] ],
[ select => short => 'skin', name => mt('_usere_skin'), width => 300, options => [
map [ $_, $self->{skins}{$_}[0].($self->debug?" [$_]":'') ], sort { $self->{skins}{$a}[0] cmp $self->{skins}{$b}[0] } keys %{$self->{skins}} ] ],
[ textarea => short => 'customcss', name => mt '_usere_css' ],
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index ef808d82..669ea7b7 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -625,9 +625,8 @@ sub page {
if(@$t) {
div id => 'tagops';
# NOTE: order of these links is hardcoded in JS
- a href => '#cont', lc mt '_tagcat_cont';
- a href => '#ero', lc mt '_tagcat_ero';
- a href => '#tech', lc mt '_tagcat_tech';
+ my $tags_cat = $self->authPref('tags_cat') || $self->{default_tags_cat};
+ a href => "#$_", $tags_cat =~ /\Q$_/ ? (class => 'tsel') : (), lc mt "_tagcat_$_" for qw|cont ero tech|;
a href => '#', class => 'sec tsel', mt '_vnpage_tags_spoil0';
a href => '#', mt '_vnpage_tags_spoil1';
a href => '#', mt '_vnpage_tags_spoil2';