diff options
author | Yorhel <git@yorhel.nl> | 2011-02-05 18:33:55 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2011-02-05 18:33:55 +0100 |
commit | bccc7326a43020e44aea345b803adaceaa90f2a2 (patch) | |
tree | 2efd0a89131865c616960f76771429893145c3d5 | |
parent | 99b0bb54556d4300676056e8afe606d859e6417b (diff) |
Group tags on /v+/tagmod by their category
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | data/lang.txt | 7 | ||||
-rw-r--r-- | data/script.js | 8 | ||||
-rw-r--r-- | data/style.css | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Handler/Tags.pm | 63 |
6 files changed, 59 insertions, 26 deletions
@@ -1,5 +1,6 @@ 2.18 - - Added category field to tags (content/ero/technical) + - Group tags on /v+/tagmod by their category 2.17 - 2011-02-04 - Allow moderators to overrule VN tag votes diff --git a/data/lang.txt b/data/lang.txt index a3911210..c93a7998 100644 --- a/data/lang.txt +++ b/data/lang.txt @@ -4569,6 +4569,13 @@ cs*: hu : Kicsoda? nl : Wie? +:_tagv_newlyadded +en : Newly added +ru*: +cs*: +hu*: +nl : Net toegevoegd + :_tagv_save en : Save changes ru : Сохранить изменения diff --git a/data/script.js b/data/script.js index 0cadd300..4c42bffe 100644 --- a/data/script.js +++ b/data/script.js @@ -1257,6 +1257,8 @@ function tglLoad() { tglStripe(); var trs = byName(byId('tagtable'), 'tr'); for(var i=0; i<trs.length; i++) { + if(hasClass(trs[i], 'tagmod_cat')) + continue; var vote = byClass(trs[i], 'td', 'tc_myvote')[0]; vote.tgl_vote = getText(vote)*1; tglVoteBar(vote); @@ -1353,6 +1355,10 @@ function tglAdd() { if(byId('tgl_'+id)) return alert(mt('_tagv_double')); + if(!byId('tagmod_newtags')) + byId('tagtable').appendChild(tag('tr', {'class':'tagmod_cat', id:'tagmod_newtags'}, + tag('td', {colspan:7}, mt('_tagv_newlyadded')))); + var vote = tag('td', {'class':'tc_myvote', tgl_vote: 2}, ''); tglVoteBar(vote); var spoil = tag('td', {'class':'tc_myspoil', tgl_spoil: 0}, tglSpoilers[0]); @@ -1385,6 +1391,8 @@ function tglSerialize() { var r = []; var l = byName(byId('tagtable'), 'tr'); for(var i=0; i<l.length; i++) { + if(hasClass(l[i], 'tagmod_cat')) + continue; var vote = byClass(l[i], 'td', 'tc_myvote')[0].tgl_vote; if(vote != 0) r[r.length] = [ diff --git a/data/style.css b/data/style.css index f64596c0..f5445c2a 100644 --- a/data/style.css +++ b/data/style.css @@ -964,12 +964,14 @@ table.tgl tfoot td { padding-top: 20px!important; } table.tgl .tc_you { border-right: 1px solid $border$; border-left: 1px solid $border$; width: 150px; text-align: center } table.tgl .tc_others { border-left: 1px solid $border$; width: 150px; text-align: center } table.tgl .tc_tagname { min-width: 200px; border-right: 1px solid $border$ } +table.tgl tbody .tc_tagname { padding-left: 15px!important } table.tgl .tc_myvote { padding-left: 30px!important } table.tgl .tc_myover { padding: 0!important } table.tgl .tc_myspoil { border-right: 1px solid $border$; padding-right: 30px!important; text-align: right; padding-left: 10px!important; cursor: pointer } table.tgl .tc_allvote { padding-left: 30px!important; } table.tgl .tc_allvote i { font-style: normal; font-size: 8px } table.tgl .tc_allspoil { text-align: right; padding-right: 15px!important; } +table.tgl .tagmod_cat td { font-weight: bold } .taglvl { display: block; float: left; width: 8px; height: 12px; border: 1px solid $border$; font-size: 1px; color: $maintext$!important } .taglvl0 { width: 15px; border: none!important; font-size: 10px; text-align: center; } div.taglvl0 { font-size: 8px; width: 20px!important } diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index a4451f98..8ed4cec6 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -249,13 +249,13 @@ sub dbTagStats { }->{ $o{sort}||'name' }, $o{reverse} ? 'DESC' : 'ASC'; my($r, $np) = $self->dbPage(\%o, qq| - SELECT t.id, t.name, count(*) as cnt, $rating as rating, + SELECT t.id, t.name, t.cat, count(*) as cnt, $rating as rating, COALESCE(avg(CASE WHEN tv.ignore THEN NULL ELSE tv.spoiler END), 0) as spoiler, bool_or(tv.ignore) AS overruled FROM tags t JOIN tags_vn tv ON tv.tag = t.id WHERE tv.vid = ? - GROUP BY t.id, t.name + GROUP BY t.id, t.name, t.cat !s ORDER BY !s|, $o{vid}, defined $o{minrating} ? "HAVING $rating > $o{minrating}" : '', $order diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index c7d98060..974754c9 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -616,30 +616,7 @@ sub vntagmod { end; end; end 'tfoot'; tbody id => 'tagtable'; - for my $t (sort { $a->{name} cmp $b->{name} } @$tags) { - my $m = (grep $_->{tag} == $t->{id}, @$my)[0] || {}; - Tr id => "tgl_$t->{id}"; - td class => 'tc_tagname'; a href => "/g$t->{id}", $t->{name}; end; - td class => 'tc_myvote', $m->{vote}||0; - if($self->authCan('tagmod')) { - td class => 'tc_myover'; - input type => 'checkbox', name => 'overrule', value => $t->{id}, - $m->{vote} && !$m->{ignore} && $t->{overruled} ? (checked => 'checked') : () - if $t->{cnt} > 1; - end; - } - td class => 'tc_myspoil', defined $m->{spoiler} ? $m->{spoiler} : -1; - td class => 'tc_allvote'; - tagscore $t->{rating}; - i $t->{overruled} ? (class => 'grayedout') : (), " ($t->{cnt})"; - b class => 'standout', style => 'font-weight: bold', ' !' if $t->{overruled}; - end; - td class => 'tc_allspoil', sprintf '%.2f', $t->{spoiler}; - td class => 'tc_allwho'; - a href => "/g/links?v=$vid;t=$t->{id}", mt '_tagv_who'; - end; - end; - } + _tagmod_list($self, $vid, $tags, $my); end 'tbody'; end 'table'; } ], @@ -647,6 +624,44 @@ sub vntagmod { $self->htmlFooter; } +sub _tagmod_list { + my($self, $vid, $tags, $my) = @_; + + my %my = map +($_->{tag} => $_), @$my; + + for my $cat (@{$self->{tag_categories}}) { + my @tags = grep $_->{cat} eq $cat, @$tags; + next if !@tags; + Tr class => 'tagmod_cat'; + td colspan => 7, mt "_tagcat_$cat"; + end; + for my $t (@tags) { + my $m = $my{$t->{id}}; + Tr id => "tgl_$t->{id}"; + td class => 'tc_tagname'; a href => "/g$t->{id}", $t->{name}; end; + td class => 'tc_myvote', $m->{vote}||0; + if($self->authCan('tagmod')) { + td class => 'tc_myover'; + input type => 'checkbox', name => 'overrule', value => $t->{id}, + $m->{vote} && !$m->{ignore} && $t->{overruled} ? (checked => 'checked') : () + if $t->{cnt} > 1; + end; + } + td class => 'tc_myspoil', defined $m->{spoiler} ? $m->{spoiler} : -1; + td class => 'tc_allvote'; + tagscore $t->{rating}; + i $t->{overruled} ? (class => 'grayedout') : (), " ($t->{cnt})"; + b class => 'standout', style => 'font-weight: bold', ' !' if $t->{overruled}; + end; + td class => 'tc_allspoil', sprintf '%.2f', $t->{spoiler}; + td class => 'tc_allwho'; + a href => "/g/links?v=$vid;t=$t->{id}", mt '_tagv_who'; + end; + end; + } + } +} + sub tagindex { my $self = shift; |