summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-12 17:12:57 +0100
committerYorhel <git@yorhel.nl>2008-12-12 17:12:57 +0100
commita416eb118824fd4aea5e5acf06e81a8c36f7f0c8 (patch)
tree1ac10f3c27a0fde3c18991991e03612c3502fb3d /lib/VNDB
parente2efaa47382a54efae24cba9de5919231509ab83 (diff)
Homepage
No idea why, but it looks like a mess :-(
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Misc.pm4
-rw-r--r--lib/VNDB/DB/VN.pm16
-rw-r--r--lib/VNDB/Handler/Misc.pm117
3 files changed, 135 insertions, 2 deletions
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm
index 828d5281..530f7d5b 100644
--- a/lib/VNDB/DB/Misc.pm
+++ b/lib/VNDB/DB/Misc.pm
@@ -77,7 +77,8 @@ sub dbItemInsert {
}
-# Options: type, iid, uid, auto, hidden, edit, page, results
+# Options: type, iid, uid, auto, hidden, edit, page, results, what
+# what: item user
sub dbRevisionGet {
my($self, %o) = @_;
$o{results} ||= 10;
@@ -85,6 +86,7 @@ sub dbRevisionGet {
$o{auto} ||= 0; # 0:show, -1:only, 1:hide
$o{hidden} ||= 0;
$o{edit} ||= 0; # 0:both, -1:new, 1:edits
+ $o{what} ||= '';
my %where = (
$o{type} ? (
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index f12bf513..e062f6e1 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
use VNDB::Func 'gtintype';
-our @EXPORT = qw|dbVNGet dbVNAdd dbVNEdit dbVNImageId dbVNCache dbScreenshotAdd dbScreenshotGet|;
+our @EXPORT = qw|dbVNGet dbVNAdd dbVNEdit dbVNImageId dbVNCache dbScreenshotAdd dbScreenshotGet dbScreenshotRandom|;
# Options: id, rev, char, search, cati, cate, lang, platform, results, page, order, what
@@ -264,5 +264,19 @@ sub dbScreenshotGet {
}
+# Fetch random VN + screenshots
+sub dbScreenshotRandom {
+ return shift->dbAll(q|
+ SELECT vs.scr, vr.vid, vr.title
+ FROM vn_screenshots vs
+ JOIN vn v ON v.latest = vs.vid
+ JOIN vn_rev vr ON vr.id = v.latest
+ WHERE vs.nsfw = FALSE
+ ORDER BY RANDOM()
+ LIMIT 5|
+ );
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 46a05822..f2e4cdcb 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -35,8 +35,125 @@ sub homepage {
div class => 'mainbox';
h1 $self->{site_title};
+ p class => 'description';
+ lit qq|
+ VNDB.org strives to be a comprehensive database for information about visual novels and
+ eroge.<br />
+ This website is built as a wiki, meaning that anyone can freely add and contribute information
+ to the database, allowing us to create the largest, most accurate and most up-to-date visual novel
+ database on the web.<br />
+ Registered users are also able to keep track of a personal list of games they want to play or have finished
+ and they can vote on all visual novels.<br />
+ <br />
+ Feel free to <a href="/v/all">browse around</a>, <a href="/u/register">register an account</a>
+ or to participate in the discussions about visual novels or VNDB on our <a href="/t">discussion board</a>.
+ |;
+ end;
+
+ my $scr = $self->dbScreenshotRandom;
+ p class => 'center';
+ br;
+ for (@$scr) {
+ a href => "/v$_->{vid}", title => $_->{title};
+ img src => sprintf("%s/st/%02d/%d.jpg", $self->{url_static}, $_->{scr}%100, $_->{scr}), alt => $_->{title};
+ end;
+ }
+ end;
+ end;
+
+ # Recent changes
+ div class => 'mainbox threelayout';
+ h1 'Recent changes';
+ my $changes = $self->dbRevisionGet(what => 'item user', results => 10);
+ ul;
+ for (@$changes) {
+ my $t = (qw|v r p|)[$_->{type}];
+ li;
+ b "$t:";
+ a href => "/$t$_->{iid}.$_->{rev}", title => $_->{ioriginal}||$_->{ititle}, shorten $_->{ititle}, 30;
+ txt ' by ';
+ a href => "/u$_->{requester}", $_->{username};
+ end;
+ }
+ end;
+ end;
+
+ # Announcements
+ div class => 'mainbox threelayout';
+ my $an = $self->dbThreadGet(type => 'an', order => 't.id DESC', results => 2);
+ a class => 'right', href => '/t/an', 'News archive';
+ h1 'Announcements';
+ for (@$an) {
+ my $post = $self->dbPostGet(tid => $_->{id}, num => 1)->[0];
+ h2;
+ a href => "/t$_->{id}", $_->{title};
+ end;
+ p;
+ lit bb2html $post->{msg}, 150;
+ end;
+ }
+ end;
+
+ # Recent posts
+ div class => 'mainbox threelayout last';
+ h1 'Recent posts';
+ my $posts = $self->dbThreadGet(what => 'lastpost', results => 10, order => 'tpl.date DESC');
+ ul;
+ for (@$posts) {
+ li;
+ txt date($_->{ldate}).' ';
+ a href => "/t$_->{id}.$_->{count}", title => $_->{title}, shorten $_->{title}, 20;
+ txt ' by ';
+ a href => "/u$_->{luid}", $_->{lusername};
+ end;
+ }
+ end;
+ end;
+
+ # Random visual novels
+ div class => 'mainbox threelayout';
+ h1 'Random visual novels';
+ my $random = $self->dbVNGet(results => 10, order => 'RANDOM()');
+ ul;
+ for (@$random) {
+ li;
+ a href => "/v$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
+ end;
+ }
+ end;
+ end;
+
+ # Upcoming releases
+ div class => 'mainbox threelayout';
+ h1 'Upcoming releases';
+ my $upcoming = $self->dbReleaseGet(results => 10, unreleased => 1);
+ ul;
+ for (@$upcoming) {
+ li;
+ lit datestr $_->{released};
+ txt ' ';
+ a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
+ end;
+ }
+ end;
+ end;
+
+ # Just released
+ div class => 'mainbox threelayout last';
+ h1 'Just released';
+ my $justrel = $self->dbReleaseGet(results => 10, order => 'rr.released DESC', unreleased => 0);
+ ul;
+ for (@$justrel) {
+ li;
+ lit datestr $_->{released};
+ txt ' ';
+ a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
+ end;
+ }
+ end;
end;
+ clearfloat;
$self->htmlFooter;
}