diff options
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/Config.pm | 86 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/Auth.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/LayoutHTML.pm | 9 |
4 files changed, 94 insertions, 5 deletions
diff --git a/lib/VNDB/Config.pm b/lib/VNDB/Config.pm new file mode 100644 index 00000000..9c9a3a63 --- /dev/null +++ b/lib/VNDB/Config.pm @@ -0,0 +1,86 @@ +package VNDB::Config; + +use strict; +use warnings; +use Exporter 'import'; +our @EXPORT = ('config'); + +my $ROOT = $INC{'VNDB/Config.pm'} =~ s{/lib/VNDB/Config\.pm$}{}r; + +# Default config options +my $config = { + url => 'http://localhost:3000', + + tuwf => { + db_login => [ 'dbi:Pg:dbname=vndb', 'vndb_site', undef ], + cookie_prefix => 'vndb_', + }, + + skin_default => 'angel', + placeholder_img => 'http://s.vndb.org/s/angel/bg.jpg', # Used in the og:image meta tag + scrypt_args => [ 65536, 8, 1 ], # N, r, p + scrypt_salt => 'another-random-string', + form_salt => 'a-private-string-here', + source_url => 'http://git.blicky.net/vndb.git/?h=master', + admin_email => 'contact@vndb.org', + login_throttle => [ 24*3600/10, 24*3600 ], # interval between attempts, max burst (10 a day) + default_tags_cat => 'cont,tech', # Default visible tag categories + board_edit_time => 7*24*3600, # Time after which posts become immutable + poll_options => 20, # max number of options in discussion board polls + + engines => [ grep $_, split /\s*\n\s*/, q{ + BGI/Ethornell + CatSystem2 + codeX RScript + EntisGLS + Ikura GDL + KiriKiri + Majiro + NScripter + QLIE + RPG Maker + RealLive + Ren'Py + Shiina Rio + Unity + YU-RIS + }], + + dlsite_url => 'https://www.dlsite.com/%s/work/=/product_id/%%s.html', + denpa_url => 'https://denpasoft.com/products/%s', + jlist_url => 'https://www.jlist.com/%s', + jbox_url => 'https://www.jbox.com/%s', + mg_r18_url => 'https://www.mangagamer.com/r18/detail.php?product_code=%d', + mg_main_url => 'https://www.mangagamer.com/detail.php?product_code=%d', + + Multi => { + Core => {}, + Feed => {}, + Maintenance => {}, + RG => {}, + }, +}; + + +my $config_file = do $ROOT.'/data/conf.pl'; +my $config_merged; + +sub config { + $config_merged ||= do { + my $c = $config; + $c->{$_} = $config_file->{$_} for grep !/^(Multi|tuwf)$/, keys %$config_file; + $c->{Multi}{$_} = $config_file->{Multi}{$_} for keys %{ $config_file->{Multi} || {} }; + $c->{tuwf}{$_} = $config_file->{tuwf}{$_} for keys %{ $config_file->{tuwf} || {} }; + + $c->{url_static} ||= $c->{url}; + $c->{version} ||= `git -C "$ROOT" describe` =~ /^(.+)$/ && $1; + $c->{root} = $ROOT; + $c->{Multi}{Core}{log_level} ||= 'debug'; + $c->{Multi}{Core}{log_dir} ||= $ROOT.'/data/log'; + $c + }; + $config_merged +} + +1; + diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index d1cba2a4..81a8993d 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -42,7 +42,7 @@ sub homepage { 'og:description' => $desc, }; - $self->htmlHeader(title => $title, feeds => [ keys %{$self->{atom_feeds}} ], metadata => $metadata); + $self->htmlHeader(title => $title, feeds => 1, metadata => $metadata); div class => 'mainbox'; h1 $title; diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm index 0093bf2d..c335041a 100644 --- a/lib/VNDB/Util/Auth.pm +++ b/lib/VNDB/Util/Auth.pm @@ -156,7 +156,7 @@ sub authInfo { # returns whether the currently loggedin or anonymous user can perform -# a certain action. Argument is the action name as defined in global.pl +# a certain action. sub authCan { my($self, $act) = @_; return $self->{_auth} ? $self->{_auth}{perm} & $self->{permissions}{$act} : 0; diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm index 5cb266f4..c04fa7dd 100644 --- a/lib/VNDB/Util/LayoutHTML.pm +++ b/lib/VNDB/Util/LayoutHTML.pm @@ -14,7 +14,7 @@ our @EXPORT = qw|htmlHeader htmlFooter|; sub htmlHeader { # %options->{ title, noindex, search, feeds, svg, metadata } my($self, %o) = @_; my $skin = $self->reqGet('skin') || $self->authPref('skin') || $self->{skin_default}; - $skin = $self->{skin_default} if !$self->{skins}{$skin} || !-d "$VNDB::ROOT/static/s/$skin"; + $skin = $self->{skin_default} if !$self->{skins}{$skin} || !-d "$self->{root}/static/s/$skin"; # heading lit '<!DOCTYPE HTML>'; @@ -28,8 +28,11 @@ sub htmlHeader { # %options->{ title, noindex, search, feeds, svg, metadata } (my $css = $self->authPref('customcss')) =~ s/\n/ /g; style type => 'text/css', $css; } - Link rel => 'alternate', type => 'application/atom+xml', href => "/feeds/$_.atom", title => $self->{atom_feeds}{$_}[1] - for ($o{feeds} ? @{$o{feeds}} : ()); + if($o{feeds}) { + Link rel => 'alternate', type => 'application/atom+xml', href => "/feeds/announcements.atom", title => 'Site Announcements'; + Link rel => 'alternate', type => 'application/atom+xml', href => "/feeds/changes.atom", title => 'Recent Changes'; + Link rel => 'alternate', type => 'application/atom+xml', href => "/feeds/posts.atom", title => 'Recent Posts'; + } if(exists $o{metadata}) { # Required fields as per http://op.me/#metadata: og:title, og:type, og:image, og:url |