summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-29 13:42:58 +0100
committerYorhel <git@yorhel.nl>2008-12-29 13:42:58 +0100
commit3c1b01ec2ba0328f74aa7269bae8015cf1faf531 (patch)
tree32be3bc4696399abf14e09f1f8f78f38f92509dc /lib/VNDB
parent1ef9db32e893669cc5da7b69b371ef051008b989 (diff)
parentf000aaf69e345bae4fc5581e5028463c85cfdafb (diff)
Merge branch 'beta'2.1
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Releases.pm3
-rw-r--r--lib/VNDB/DB/Users.pm2
-rw-r--r--lib/VNDB/Func.pm35
-rw-r--r--lib/VNDB/Handler/Discussions.pm2
-rw-r--r--lib/VNDB/Handler/ULists.pm3
-rw-r--r--lib/VNDB/Handler/Users.pm7
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
-rw-r--r--lib/VNDB/Util/FormHTML.pm3
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm4
9 files changed, 49 insertions, 16 deletions
diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm
index b2c78d5e..6af2f736 100644
--- a/lib/VNDB/DB/Releases.pm
+++ b/lib/VNDB/DB/Releases.pm
@@ -3,6 +3,7 @@ package VNDB::DB::Releases;
use strict;
use warnings;
+use POSIX 'strftime';
use Exporter 'import';
our @EXPORT = qw|dbReleaseGet dbReleaseAdd dbReleaseEdit|;
@@ -27,7 +28,7 @@ sub dbReleaseGet {
$o{vid} ? (
'rv.vid = ?' => $o{vid} ) : (),
defined $o{unreleased} ? (
- q|rr.released !s TO_CHAR('today'::timestamp, 'YYYYMMDD')::integer| => $o{unreleased} ? '>' : '<=' ) : (),
+ q|rr.released !s ?| => [ $o{unreleased} ? '>' : '<=', strftime('%Y%m%d', gmtime) ] ) : (),
);
my @join = (
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/Func.pm b/lib/VNDB/Func.pm
index 9abacad0..330dad7d 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -86,6 +86,7 @@ sub userstr {
# [url=..] [/url]
# [raw] .. [/raw]
# [spoiler] .. [/spoiler]
+# [quote] .. [/quote]
# v+, v+.+
# http://../
sub bb2html {
@@ -94,11 +95,10 @@ sub bb2html {
$raw =~ s/\r//g;
return '' if !$raw && $raw ne "0";
- my($result, $length, @open) = ('', 0, 'first');
+ my($result, $length, $rmnewline, @open) = ('', 0, 0, 'first');
my $e = sub {
local $_ = shift;
- tr/A-Za-z/N-ZA-Mn-za-m/ if !@_ && grep /spoiler/, @open;
s/&/&amp;/g;
s/>/&gt;/g;
s/</&lt;/g;
@@ -109,13 +109,34 @@ sub bb2html {
for (split /(\s|\n|\[[^\]]+\])/, $raw) {
next if !defined $_;
+ next if $_ eq '';
+
+ $rmnewline = s/\n//g if $rmnewline;
+ next if $_ eq '';
my $lit = $_;
if($open[$#open] ne 'raw') {
if ($_ eq '[raw]') { push @open, 'raw'; next }
- elsif ($_ eq '[spoiler]') { push @open, 'spoiler'; next }
- elsif ($_ eq '[/spoiler]') { pop @open if $open[$#open] eq 'spoiler'; next }
- elsif ($_ eq '[/url]') {
+ elsif ($_ eq '[spoiler]') { push @open, 'spoiler'; $result .= '<b class="spoiler">'; next }
+ elsif ($_ eq '[quote]') {
+ push @open, 'quote';
+ $result .= '<div class="quote">' if !$maxlength;
+ $rmnewline++;
+ next
+ } elsif ($_ eq '[/spoiler]') {
+ if($open[$#open] eq 'spoiler') {
+ $result .= '</b>';
+ pop @open;
+ }
+ next;
+ } elsif ($_ eq '[/quote]') {
+ if($open[$#open] eq 'quote') {
+ $result .= '</div>' if !$maxlength;
+ $rmnewline++;
+ pop @open;
+ }
+ next;
+ } elsif($_ eq '[/url]') {
if($open[$#open] eq 'url') {
$result .= '</a>';
pop @open;
@@ -126,7 +147,7 @@ sub bb2html {
push @open, 'url';
next;
} elsif(!grep(/url/, @open) &&
- s{(.*)(http|https)://(.+[0-9a-zA-Z=/])(.*)}
+ s{(.*)(http|https)://(.+[\d\w=/-])(.*)}
{$e->($1).qq|<a href="$2://|.$e->($3, 1).'" rel="nofollow">'.$e->('link').'</a>'.$e->($4)}e) {
$length += 4;
last if $maxlength && $length > $maxlength;
@@ -151,7 +172,7 @@ sub bb2html {
$result .= $e->($_);
}
- $result .= '</a>'
+ $result .= $_ eq 'url' ? '</a>' : $_ eq 'quote' ? '</div>' : '</b>'
while((local $_ = pop @open) ne 'first');
$result .= '...' if $maxlength && $length > $maxlength;
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm
index 286e3ee5..06693590 100644
--- a/lib/VNDB/Handler/Discussions.pm
+++ b/lib/VNDB/Handler/Discussions.pm
@@ -54,7 +54,7 @@ sub thread {
table;
for my $i (0..$#$p) {
local $_ = $p->[$i];
- my $class = $i % 2 == 0 ? 'odd ' : '';
+ my $class = $i % 2 ? 'odd ' : '';
$class .= 'deleted' if $_->{hidden};
Tr class => $class;
td class => 'tc1';
diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm
index 5353dbc9..f86cba83 100644
--- a/lib/VNDB/Handler/ULists.pm
+++ b/lib/VNDB/Handler/ULists.pm
@@ -70,7 +70,8 @@ sub rlist {
$f->{e} =~ /^([rv])(\d+)$/ && $1 eq 'r' ? (rstat => $2) : (vstat => $2)
) if $f->{e} ne 'del';
- $self->resRedirect('/r'.$id, 'temp');
+ (my $ref = $self->reqHeader('Referer')||"/r$id") =~ s/^\Q$self->{url}//;
+ $self->resRedirect($ref, 'temp');
}
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index daba59e6..f2bb0fa6 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 { $self->{skins}{$a} cmp $self->{skins}{$b} } 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/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 35a9ac8c..b53b60ee 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -397,9 +397,9 @@ sub _releases {
a href => "/r$rel->{id}", title => $rel->{original}||$rel->{title}, $rel->{title};
end;
td class => 'tc5';
- if($rel->{ulist}) {
- a href => "/r$rel->{id}";
- lit liststat $rel->{ulist};
+ if($self->authInfo->{id}) {
+ a href => "/r$rel->{id}", id => "rlsel_$rel->{id}";
+ lit $rel->{ulist} ? liststat $rel->{ulist} : '--';
end;
} else {
txt ' ';
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 80b8c4f3..ff23682d 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -216,6 +216,9 @@ sub htmlForm {
a href => "#$short", id => "jt_sel_$short", $subs[$_*2];
end;
}
+ li class => 'left';
+ a href => '#all', id => 'jt_sel_all', 'All items';
+ end;
end;
}
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index e5ced8f6..30a10ce3 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -12,13 +12,15 @@ our @EXPORT = qw|htmlHeader htmlFooter|;
sub htmlHeader { # %options->{ title, js, noindex, search }
my($self, %o) = @_;
+ my $skin = $self->authInfo->{skin} || $self->{skin_default};
+ $skin = $self->{skin_default} if !-d "$VNDB::ROOT/static/s/$skin";
# heading
html;
head;
title $o{title};
Link rel => 'shortcut icon', href => '/favicon.ico', type => 'image/x-icon';
- Link rel => 'stylesheet', href => $self->{url_static}.'/f/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;
}