summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-24 15:04:02 +0100
committerYorhel <git@yorhel.nl>2010-01-24 15:07:00 +0100
commitd7815efc3a99aecc61c5ac1d9833de0f448b697f (patch)
tree50e8082f67f360eff12c434723784d9069df4109 /lib
parentb04c46baec8aef93d21898ef7f52b9d6d2442ce3 (diff)
Automatically generate the skin credits on d7
Added a userid field in the skin config files, from which the credits are loaded. Now I don't have to constantly update d7 for every language when something changes in the skin files.
Diffstat (limited to 'lib')
-rw-r--r--lib/SkinFile.pm1
-rw-r--r--lib/VNDB/DB/Users.pm4
-rw-r--r--lib/VNDB/Handler/Misc.pm17
-rw-r--r--lib/VNDB/Handler/Users.pm2
4 files changed, 18 insertions, 6 deletions
diff --git a/lib/SkinFile.pm b/lib/SkinFile.pm
index b8d0c4fb..78608f89 100644
--- a/lib/SkinFile.pm
+++ b/lib/SkinFile.pm
@@ -26,6 +26,7 @@ sub open {
open my $F, '<:utf8', "$self->{root}/$dir/conf" or die $!;
flock $F, LOCK_SH or die $!;
seek $F, 0, SEEK_SET or die $!;
+ local $_;
while(<$F>) {
chomp;
s/\r//g;
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index f8fdfe3f..36f589ac 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -30,8 +30,10 @@ sub dbUserGet {
'ASCII(username) < 97 OR ASCII(username) > 122' => 1 ) : (),
$o{mail} ? (
'mail = ?' => $o{mail} ) : (),
- $o{uid} ? (
+ $o{uid} && !ref($o{uid}) ? (
'id = ?' => $o{uid} ) : (),
+ $o{uid} && ref($o{uid}) ? (
+ 'id IN(!l)' => [ $o{uid} ]) : (),
!$o{uid} && !$o{username} ? (
'id > 0' => 1 ) : (),
$o{ip} ? (
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 7d2bd78c..e2fdaa62 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -288,24 +288,33 @@ sub docpage {
$sec++;
$subsec = 0;
qq|<h3><a href="#$sec" name="$sec">$sec. $1</a></h3>\n|
- }eg;
+ }e;
s{^:SUBSUB:(.+)\r?\n$}{
$subsec++;
qq|<h4><a href="#$sec.$subsec" name="$sec.$subsec">$sec.$subsec. $1</a></h4>\n|
- }eg;
+ }e;
s{^:INC:(.+)\r?\n$}{
$f = sprintf('%s/data/docs/%s', $VNDB::ROOT, $1);
open($F, '<:utf8', $f.$l) or open($F, '<:utf8', $f) or die $!;
my $ii = join('', <$F>);
close $F;
$ii;
- }eg;
+ }e;
s{^:TOP5CONTRIB:$}{
my $l = $self->dbUserGet(results => 6, sort => 'changes', reverse => 1);
'<dl>'.join('', map $_->{id} == 1 ? () :
sprintf('<dt><a href="/u%d">%s</a></dt><dd>%d</dd>', $_->{id}, $_->{username}, $_->{c_changes}),
@$l).'</dl>';
- }eg;
+ }e;
+ s{^:SKINCONTRIB:$}{
+ my %users;
+ push @{$users{ $self->{skins}{$_}[1] }}, [ $_, $self->{skins}{$_}[0] ]
+ for sort { $self->{skins}{$a}[0] cmp $self->{skins}{$b}[0] } keys %{$self->{skins}};
+ my $u = $self->dbUserGet(uid => [ keys %users ]);
+ '<dl>'.join('', map sprintf('<dt><a href="/u%d">%s</a></dt><dd>%s</dd>',
+ $_->{id}, $_->{username}, join(', ', map sprintf('<a href="?skin=%s">%s</a>', $_->[0], $_->[1]), @{$users{$_->{id}}})
+ ), @$u).'</dl>';
+ }e;
}
$self->htmlHeader(title => $title);
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index 386fcda1..75ce411e 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -346,7 +346,7 @@ sub edit {
[ check => short => 'flags_list', name => mt '_usere_flist', "/u$uid/list", "/u$uid/wish" ],
[ check => short => 'flags_nsfw', name => mt '_usere_fnsfw' ],
[ select => short => 'skin', name => mt('_usere_skin'), width => 300, options => [
- map [ $_ eq $self->{skin_default} ? '' : $_, $self->{skins}{$_}.($self->debug?" [$_]":'') ], sort { $self->{skins}{$a} cmp $self->{skins}{$b} } keys %{$self->{skins}} ] ],
+ map [ $_ eq $self->{skin_default} ? '' : $_, $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' ],
]);
$self->htmlFooter;