From db47e11b580efa1938de892e6c08ba47ba2c6cc4 Mon Sep 17 00:00:00 2001 From: yorhel Date: Tue, 8 Jul 2008 07:27:56 +0000 Subject: Wrote an integrated messageboard, and fixed a few (very) small things along the way git-svn-id: svn://vndb.org/vndb@54 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b --- data/tpl/defs.pl | 70 +++++++++++++++++++++++++++++++++++++---------- data/tpl/faq | 75 --------------------------------------------------- data/tpl/hist | 2 +- data/tpl/home | 11 ++++---- data/tpl/main | 8 +++++- data/tpl/myvotes | 1 + data/tpl/pedit | 5 ++-- data/tpl/ppage | 3 +-- data/tpl/redit | 5 ++-- data/tpl/rpage | 3 +-- data/tpl/tedit | 24 +++++++++++++++++ data/tpl/tindex | 54 +++++++++++++++++++++++++++++++++++++ data/tpl/ttag | 57 +++++++++++++++++++++++++++++++++++++++ data/tpl/tthread | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/tpl/useredit | 1 + data/tpl/userpage | 1 + data/tpl/vnedit | 5 ++-- data/tpl/vnlist | 1 + data/tpl/vnpage | 18 ++++++------- 19 files changed, 306 insertions(+), 119 deletions(-) delete mode 100644 data/tpl/faq create mode 100644 data/tpl/tedit create mode 100644 data/tpl/tindex create mode 100644 data/tpl/ttag create mode 100644 data/tpl/tthread (limited to 'data') diff --git a/data/tpl/defs.pl b/data/tpl/defs.pl index fcc1c443..46269347 100644 --- a/data/tpl/defs.pl +++ b/data/tpl/defs.pl @@ -59,6 +59,17 @@ sub wraplong { # text, margin s/([^\s\r\n]{$m})([^\s\r\n])/$1 $2/g; return $_; } +sub age { + my $a = time-$_[0]; + return sprintf '%d %s', + $a > 60*60*24*365*2 ? ( $a/60/60/24/365, 'years ago' ) : + $a > 60*60*24*(365/12)*2 ? ( $a/60/60/24/(365/12), 'months ago' ) : + $a > 60*60*24*7*2 ? ( $a/60/60/24/7, 'weeks ago' ) : + $a > 60*60*24*2 ? ( $a/60/60/24, 'days ago' ) : + $a > 60*60*2 ? ( $a/60/60, 'hours ago' ) : + $a > 60*2 ? ( $a/60, 'min ago' ) : + ( $a, 'sec ago' ) ; +} sub wordsplit { # split a string into an array of words, but make sure to not split HTML tags @@ -134,6 +145,7 @@ sub summary { # cmd, len, def my $res = ''; my $len = 0; my $as = 0; + my $raw = 0; (my $txt = $_[0]) =~ s/\r?\n/\n /g; for (split / /, $txt) { next if !defined $_ || $_ eq ''; @@ -141,19 +153,31 @@ sub summary { # cmd, len, def s/\&/&/g; s/>/>/g; s/]+)\]//i) { - $l -= length($1)+6; - $as++; + if(!$raw && s/^\[raw\]//) { + $l -= 5; + $raw++; } - if(!$as && s/(http|https):\/\/(.+[0-9a-zA-Z=\/])/link<\/a>/) { - $l = 4; - } elsif(!$as) { - s/^(.*[^\w]|)([dvpr][0-9]+)\.([0-9]+)([^\w].*|)$/$1$2.$3<\/a>$4/ || - s/^(.*[^\w]|)([duvpr][0-9]+)([^\w].*|)$/$1$2<\/a>$3/; + if(!$raw) { + $l -= 9 while(s/\[spoiler\]//i); + $l -= 10 while(s/\[\/spoiler\]/<\/b>/i); + while(s/\[url=((https?:\/\/|\/)[^\]>]+)\]//i) { + $l -= length($1)+6; + $as++; + } + if(!$as && s/(http|https):\/\/(.+[0-9a-zA-Z=\/])/link<\/a>/) { + $l = 4; + } elsif(!$as) { + s/^(.*[^\w]|)([tdvpr][0-9]+)\.([0-9]+)([^\w].*|)$/$1$2.$3<\/a>$4/ || + s/^(.*[^\w]|)([tduvpr][0-9]+)([^\w].*|)$/$1$2<\/a>$3/; + } + while(s/\[\/url\]/<\/a>/i) { + $l -= 6; + $as--; + } } - while(s/\[\/url\]/<\/a>/i) { + if(s/\[\/raw\]//) { $l -= 6; - $as--; + $raw=0; } $len += $l + 1; last if $_[1] && $len > $_[1]; @@ -168,21 +192,29 @@ sub summary { # cmd, len, def } -sub ttabs { # [vrp], obj, sel +sub ttabs { # [vrpu], obj, sel my($t, $o, $s) = @_; $s||=''; my @act = ( !$s?'%s':'%1$s', $$o{locked} ? 'locked for editing' : (), - $p{Authlock} ? + $p{Authlock} && $t ne 'u' ? sprintf('%s', $$o{locked} ? 'unlock' : 'lock') : (), - $p{Authdel} ? ( + $p{Authdel} && $t ne 'u' ? ( sprintf('%s', $t eq 'v' ? ' id="vhide"' : '', $$o{hidden} ? 'unhide' : 'hide') ) : (), - (!$$o{locked} && !$$o{hidden}) || ($p{Authedit} && $p{Authlock}) ? + ($t eq 'u' && $p{Authuseredit}) || ($t ne 'u' && (!$$o{locked} && !$$o{hidden}) || ($p{Authedit} && $p{Authlock})) ? ($s eq 'edit' ? 'edit' : 'edit') : (), + $t eq 'u' ? ( + $o->{flags} & $VNDB::UFLAGS->{votes} ? ( $s eq 'vote' ? 'votes' : 'votes', ) : (), + $o->{flags} & $VNDB::UFLAGS->{list} ? ( $s eq 'list' ? 'list' : 'list', ) : (), + ) : (), + + $t ne 'r' ? ( + $s eq 'disc' ? 'discussions' : 'discussions', ) : (), + $p{Authhist} ? ($s eq 'hist' ? 'history' : 'history') : (), ); @@ -228,6 +260,14 @@ my %pagetitles = ( home => 'Visual Novel Database', pbrowse => 'Browse producers', userlist => 'Browse users', + tindex => 'Discussion board index', + ttag => sub { + return ($p{ttag}{obj} ? 'Related discussions for ' : '').$p{ttag}{title} }, + tthread => sub { + return $p{tthread}{t}{title} }, + tedit => sub { + return $p{tedit}{p} ? 'Edit post' : + $p{tedit}{t} ? 'Reply to thread' : 'Start a new thread' }, myvotes => sub { return $p{myvotes}{user}{username} eq $p{AuthUsername} ? 'My votes' : ('Votes by '.$p{myvotes}{user}{username}); }, userpage => sub { @@ -288,6 +328,7 @@ my %formerr_names = ( vn => 'Visual novel relations', l_vnn => 'Visual-novels.net link', comm => 'Edit summary', + msg => 'Message', ); my @formerr_msgs = ( sub { return sprintf 'Field "%s" is required.', @_ }, @@ -312,6 +353,7 @@ my %formerr_exeptions = ( nomail => 'No user found with that email address', nojpeg => 'Image is not in JPEG or PNG format!', toolarge => 'Image is too large (in filesize), try to compress it a little', + wrongtag => 'Wrong tag selected!', ); sub formerr { my @err = ref $_[0] eq 'ARRAY' ? @{$_[0]} : (); diff --git a/data/tpl/faq b/data/tpl/faq deleted file mode 100644 index 1c64056e..00000000 --- a/data/tpl/faq +++ /dev/null @@ -1,75 +0,0 @@ -

[[: $p{PageTitle} ]]

-
-

What is a Visual Novel?

-

- A visual novel can be seen as a combination of a novel and a computer game: - they're computer games with a large text based storyline and only little - interaction of the player. A typical visual novel consists of text over - an anime-style background image and is accompanied by background music. - Throughout the game, the player usually has to answer a few questions which will - have an effect on the story, thus playing a visual novel a second time while - giving other answers may result in an entirely different plot.
-
- For more information see - the Wikipedia article on visual novels or the description on - Visual-Novels.net. - To get a general idea of the genre, try one of the free short visual novels from - al|together 2006. -


-

- - -

How about Eroge, H-Games and Dating Sims?

-

- An eroge or H-game is basically any Japanese game that features sexual - content. Many visual novels are eroge and many eroge are visual novels, - but this is not a rule. The definition of dating sim is a bit more vague, - but it's usually the same as a visual novel, except that a dating sim - generally uses a gameplay based on statistics.
-
- There are no strict bounds to the definition of "visual novel", most - eroge and dating sims include elements of visual novels, but may - - strictly speaking - not be visual novels themselves. As VNDB aims to - be comprehensive, we simply accept any game that contains elements of a - visual novel and is produced by a Japanese or Japan-related company or - doujin cicle. -


-

- - -

Why a Visual Novel Database?

-

- The internet is large, very large, but the number of English resources - related to visual novels is only very limited. VNDB attempts to collect - and present as much information as possible that would otherwise be very - hard to find for the English speaking audience. This way fans can easily - keep track of new releases and localizations of their favorite games, - while not having to browse numerous of indistinct Japanese websites. -


-

- - -

How can I help VNDB?

-

- There are many ways to contribute to VNDB. First of all you can freely - edit all information found on this website, so if you find any errors - just click the "edit" link on the top right of the page. You can also - add new information (visual novels, producers, releases) to the database, - though please search the database before you do in order to prevent - duplicate pages.
-
- To discuss about new features or to help the development of the website - itself, feel free to browse the forums - or join us on IRC at #vndb @ irc.synirc.net. - If you aren't used to IRC or are just to lazy to install a client, you can - still join the chat using the Webchat. - Just choose a nickname, specify #vndb as channel and hit Login! -


-

- - -

Where can I download the Visual Novels?

-

- Not here. We do not provide downloads nor links to resources that encourage - the illegal spreading of visual novels. -

diff --git a/data/tpl/hist b/data/tpl/hist index 05780bb6..77acb6c2 100644 --- a/data/tpl/hist +++ b/data/tpl/hist @@ -1,4 +1,4 @@ -[[= $d{type} && $d{type} ne 'u' ? ttabs($d{type}, $d{obj}, 'hist') : '' ]]- +[[= $d{type} ? ttabs($d{type}, $d{obj}, 'hist') : '' ]]-

[[: $p{PageTitle} ]]

[[ if($d{type} eq 'u' && $#{$d{hist}} < 0) { ]]

diff --git a/data/tpl/home b/data/tpl/home index ed0bca63..5ea730ce 100644 --- a/data/tpl/home +++ b/data/tpl/home @@ -10,16 +10,15 @@ and they can vote on all visual novels.

Feel free to browse around, register an account - or to discuss about the database at our forums. + or to participate in the discussions about visual novels or VNDB on our discussion board.

-

VNDB 1.18!

+

[[: $d{an}{title} ]]- +

by [[: $d{anpost}{username} ]], -[[= age $d{anpost}{date} ]]

- Shortly after 1.17, I now present 1.18! This update includes a major change in how you refer - to specific revisions of an entry, adds the ability to select release dates back to 1980, NES - and MSX to the list of platforms, and a few warnings. + [[= summary $d{anpost}{msg}, 200 ]]
- Read more... - news archive. + Read more... - news archive.

-[[ if(!$p{AuthLoggedin}) { ]]- @@ -103,6 +108,7 @@
  • My votes
  • My visual novel list
  • My recent changes
  • +
  • My messages
  • [[ if($p{Authedit}) { ]]-
  •  
  • Add visual novel
  • diff --git a/data/tpl/myvotes b/data/tpl/myvotes index 9379e98e..231eaf25 100644 --- a/data/tpl/myvotes +++ b/data/tpl/myvotes @@ -1,3 +1,4 @@ +[[= ttabs('u', $d{user}, 'vote') ]]

    [[: $p{PageTitle} ]]

    [[ if($#{$d{votes}} < 0) { ]]-

    diff --git a/data/tpl/pedit b/data/tpl/pedit index 363f9619..56c06b92 100644 --- a/data/tpl/pedit +++ b/data/tpl/pedit @@ -6,9 +6,8 @@ [[ } else { ]] - It is currently not possible to delete producers from the database, please - use the forums to request - a deletion. Also refer to the forums for more serious edits or discussions about changes. + Please check the discussion board before making + any changes! [[ } if($d{id} && $d{prod}{cid} != $d{prod}{latest}) { ]] diff --git a/data/tpl/ppage b/data/tpl/ppage index e829682a..f45366fa 100644 --- a/data/tpl/ppage +++ b/data/tpl/ppage @@ -4,8 +4,7 @@ [[ if($d{prod}{hidden}) { ]]- This item has been deleted from the database. File a request on the - forums - to undelete this page. + discussion board to undelete this page. [[ } ]] [[ if(!$d{prod}{hidden} || $p{Authdel}) { ]]- diff --git a/data/tpl/redit b/data/tpl/redit index 73744517..32d618e3 100644 --- a/data/tpl/redit +++ b/data/tpl/redit @@ -3,9 +3,8 @@ [[ if($d{id}) { ]] - It is currently not possible to delete releases from the database, please - use the forums to request - a deletion. Also refer to the forums for more serious edits or discussions about changes. + Please check the discussion board before making + any changes! [[ } if($d{id} && $d{rel}{cid} != $d{rel}{latest}) { ]] diff --git a/data/tpl/rpage b/data/tpl/rpage index 11432f80..54267204 100644 --- a/data/tpl/rpage +++ b/data/tpl/rpage @@ -4,8 +4,7 @@ [[ if($d{rel}{hidden}) { ]]- This item has been deleted from the database. File a request on the - forums - to undelete this page. + discussion board to undelete this page. [[ } ]] [[ if(!$d{rel}{hidden} || $p{Authdel}) { ]]- diff --git a/data/tpl/tedit b/data/tpl/tedit new file mode 100644 index 00000000..cfcd5a95 --- /dev/null +++ b/data/tpl/tedit @@ -0,0 +1,24 @@ +

    [[: $p{PageTitle} ]]

    + + +-[[= cform( [ + { type => 'error' }, + { type => 'startform', action => $d{p} ? '/t'.$d{t}{id}.'.'.$d{p}{num}.'/edit' : $d{t} ? '/t'.$d{t}{id}.'/reply' : '/t/'.$d{tag}.'/new' }, + { type => 'static', name => 'Username', text => ''.($d{p}?$d{p}{username}:$p{AuthUsername}).'' }, + $d{t} && !($d{p} && $d{p}{num} == 1) ? ( + { type => 'static', name => 'Topic', text => ''.$d{t}{title}.'.' } + ) : ( + { type => 'input', short => 'title', name => 'Thread title' }, + { type => 'input', short => 'tags', name => 'Tags' }, + $p{Authboardmod} ? ( + { type => 'check', short => 'lock', name => 'Locked' }, + ) : (), + ), + $p{Authboardmod} ? ( + { type => 'check', short => 'hide', name => 'Hidden' }, + ) : (), + { type => 'textarea', short => 'msg', name => 'Message', rows => 10, cols => 60 }, + { type => 'submit', text => 'Submit' }, + { type => 'endform' }, +], $d{form}) ]]- + diff --git a/data/tpl/tindex b/data/tpl/tindex new file mode 100644 index 00000000..ae5625b3 --- /dev/null +++ b/data/tpl/tindex @@ -0,0 +1,54 @@ +

    [[: $p{PageTitle} ]]

    + +[[ + my %desc = ( + an => 'Yorhel\'s place to make useless announcements...', + db => 'General discussions about VNDB.org. This is the place to be for feature requests and bug reports.', + v => 'Discussions about the visual novels in the database', + p => '...Producers', + r => '...Releases', + u => 'Messages to or discussions about other users on this site.' + ); +]] + + +[[ for my $tag (qw|an db v p u|) { ]]- + +
    +

    [[: $VNDB::DTAGS->{$tag} ]]

    + +[[ if(@{$d{$tag}}) { ]]- + + +[[ for (@{$d{$tag}}) { ]]- + + + + + + +[[ } ]] +
    + [[: $_->{title} ]] + [[ if($_->{locked}) { ]]- [locked][[ } ]] + [[= $_->{count}-1 ]][[= $_->{username} ]][[= $_->{lusername} ]] @ + + [[= age $_->{ldate} ]]
    +more... +[[ } else { ]]- +

    No threads yet. + -[[ if($tag eq 'db') { ]] + Start a new thread. + [[ } ]] +

    +[[ } ]] +
    + +[[ } ]] diff --git a/data/tpl/ttag b/data/tpl/ttag new file mode 100644 index 00000000..3495d319 --- /dev/null +++ b/data/tpl/ttag @@ -0,0 +1,57 @@ +[[= $d{obj} ? ttabs($d{type}, $d{obj}, 'disc') : '' ]]- +

    [[: $p{PageTitle} ]]

    +

    + Discussion board + > [[: $VNDB::DTAGS->{$d{type}} ]] + [[ if($d{obj}) { ]]- + > [[= $d{tag} ]]:[[: $d{title} ]][[ } ]]- +

    + +[[ if(@{$d{t}}) { ]]- + +[[ if(!$d{obj} && $d{tag} !~ /(an|db)/) { + my @tags = grep $$_[0] eq $d{type}, map @{$_->{tags}}, @{$d{t}}; my %tags; my $i=0; ]]- +
    +
    Recent tags
    +
    + [[ for (@tags) { next if $tags{$$_[1]}++; last if $i++ == 5; ]]- + [[= $$_[0].$$_[1] ]]:[[: $$_[2] ]]
    [[ } ]] +
    +
    +[[ } else { ]] +
    +[[ } ]] + + +[[= pagebut('/t/'.$d{tag}) ]] + + + + + + + +[[ for (@{$d{t}}) { ]]- + + + + + + +[[ } ]] +
    Topic#StarterLast post
    [[: $_->{title} ]][[= $_->{count}-1 ]][[= $_->{username} ]][[= $_->{lusername} ]] @ + + [[= age $_->{ldate} ]]
    +[[= pagebut('/t/'.$d{tag}) ]] + +[[ } else { ]] +


    + No related threads found. +

    +[[ } ]]- + +-[[ if($p{Authboard} && $d{tag} =~ /^(?:db|[vpru][0-9]+)$/) { ]]- +
    +create a new thread +[[ } ]] + diff --git a/data/tpl/tthread b/data/tpl/tthread new file mode 100644 index 00000000..915474f7 --- /dev/null +++ b/data/tpl/tthread @@ -0,0 +1,81 @@ +

    [[: $p{PageTitle} ]]

    +[[ if($d{t}{hidden}) { ]] +This thread has been deleted! +[[ } ]] + +
    +
    Posted in
    +
    + [[ for (sort { $$a[0].$$a[1] cmp $$b[0].$$b[1] } @{$d{t}{tags}}) { ]]- + [[: $VNDB::DTAGS->{$$_[0]} ]] + [[ if($$_[1]) { ]]- + > [[= $$_[0].$$_[1] ]]:[[: $$_[2] ]][[ } ]]- +
    + [[ } ]] +
    +
    + +
    + +[[ + my $pages=''; + my $lp = ceil($d{t}{count}/$d{ppp}); + if($d{t}{count} > $d{ppp}) { + my @pages = ( + $d{page} == 1 ? '<<' : '<<', + $lp > 2 ? (map + $d{page} == $_ ? $_ : ''.$_.'', + 2..($lp-1) ) : (), + $d{page} == $lp ? '>>' : '>>' + ); + $pages = '

    '.join('  ', map sprintf($_,$d{t}{id}), @pages).'

    '; + } +]] + +[[= $pages ]] + + [[ for (@{$d{p}}) { ]]- + + + + + [[ } ]]- +
    + #[[= $_->{num} ]] + [[ if(!$_->{hidden}) { ]]- + by [[: $_->{username} ]]
    + [[= formatdate('%Y-%m-%d %R', $_->{date}) ]] + [[ } ]] +
    + [[ if($p{AuthId} == $_->{uid} && !$_->{hidden} || $p{Authboardmod}) { ]]- +

    < edit >

    + [[ } ]] + [[ if(!$_->{hidden}) { ]]- + [[= summary $_->{msg} ]] + [[ if($_->{edited}) { ]]
    + last modified -[[= formatdate('%Y-%m-%d %R', $_->{edited}) ]] + [[ } ]] + [[ } else { ]] + + [[ } ]] +
    +[[= $pages ]] + +
    +[[ if($lp == $d{page}) { ]] + [[ if($d{t}{locked}) { ]]- +

    + This thread has been locked, you can't reply anymore. +

    + [[ } elsif(!$p{AuthLoggedin}) { ]]- +

    + You need to be logged in to reply to this thread. +

    + [[ } elsif($p{Authboard} && $lp == $d{page}) { ]]- +
    +

    Quick reply

    + + +
    + [[ } ]] +[[ } ]] diff --git a/data/tpl/useredit b/data/tpl/useredit index f470ce0a..16bc8c44 100644 --- a/data/tpl/useredit +++ b/data/tpl/useredit @@ -1,3 +1,4 @@ +[[= ttabs('u', $d{u}, 'edit') ]]

    [[: $p{PageTitle} ]]

    -[[ if($d{done}) { ]] diff --git a/data/tpl/userpage b/data/tpl/userpage index 9b14efc9..ef5fc55c 100644 --- a/data/tpl/userpage +++ b/data/tpl/userpage @@ -1,3 +1,4 @@ +[[= ttabs('u', $d{user}) ]] [[ ($d{pv}, $d{pl}) = ($d{user}{flags} & $VNDB::UFLAGS->{votes}, $d{user}{flags} & $VNDB::UFLAGS->{list}); ]] diff --git a/data/tpl/vnedit b/data/tpl/vnedit index c6cbd3ae..6412ad8f 100644 --- a/data/tpl/vnedit +++ b/data/tpl/vnedit @@ -6,9 +6,8 @@ in order to prevent duplicate entries. [[ } else { ]] - It is currently not possible to delete visual novels from the database, please - use the forums to request - a deletion. Also refer to the forums for more serious edits or discussions about changes. + Please check the discussion board before making + any changes! [[ } if($d{id} && $d{vn}{cid} != $d{vn}{latest}) { ]] diff --git a/data/tpl/vnlist b/data/tpl/vnlist index 64db1c05..0fb20509 100644 --- a/data/tpl/vnlist +++ b/data/tpl/vnlist @@ -1,3 +1,4 @@ +[[= ttabs('u', $d{user}, 'list') ]]

    [[: $p{PageTitle} ]]

    [[ my $url = sprintf '/u%d/list', $d{user}{id}; diff --git a/data/tpl/vnpage b/data/tpl/vnpage index 22fa98fc..551731a5 100644 --- a/data/tpl/vnpage +++ b/data/tpl/vnpage @@ -2,23 +2,23 @@

    [[: $d{vn}{title} ]]

    --[[ if($p{AuthLoggedin}) { ]] -

    < user options - - [[= $d{vote}{vid} ? 'your vote: '.$d{vote}{vote} : 'vote' ]] -- [[= !$d{list}{vid} ? 'add to vn list' : 'status: '.lc $VNDB::LSTAT->[$d{list}{status}] ]] ->

    -[[ } ]]- - [[ if($d{vn}{hidden}) { ]]- This item has been deleted from the database. File a request on the - forums - to undelete this page. + discussion board to undelete this page. [[ } ]] [[ if(!$d{vn}{hidden} || $p{Authdel}) { ]]- +-[[ if($p{AuthLoggedin}) { ]] +

    < user options - + [[= $d{vote}{vid} ? 'your vote: '.$d{vote}{vote} : 'vote' ]] +- [[= !$d{list}{vid} ? 'add to vn list' : 'status: '.lc $VNDB::LSTAT->[$d{list}{status}] ]] +>

    +[[ } ]]- + + [[ if($d{change}) { ]] [[= cdiff($d{prev}, $d{vn}, -- cgit v1.2.3