]> git.sesse.net Git - ccbs/blobdiff - html/ccbs.pm
Shape text using Pango and HarfBuzz; gives us nice ligatures and exotic scripts.
[ccbs] / html / ccbs.pm
index 3fdf3a5fc85b84c2c521954fb030ef30658f72cb..1807e0953de82cfdbb066373c8c4af7ed4ba58a4 100755 (executable)
@@ -1,6 +1,7 @@
 package ccbs;
 use Template;
 use CGI;
+use CGI::Cookie;
 use DBI;
 use HTML::Entities;
 use Time::HiRes;
@@ -13,8 +14,16 @@ require '../intl/Sesse::GettextizeTemplates.pm';
 require '../config.pm';
 -r '../config.local.pm' and require '../config.local.pm';
 
-POSIX::setlocale( &POSIX::LC_CTYPE , $ccbs::config::lang );
-POSIX::setlocale( &POSIX::LC_MESSAGES , $ccbs::config::lang );
+# Check for language settings
+my %cookies = fetch CGI::Cookie;
+my $lang = defined($cookies{'language'}) ? $cookies{'language'}->value : undef;
+if (defined($lang) && ($lang eq 'nb_NO' || $lang eq 'nn_NO' || $lang eq 'en_US')) {
+       POSIX::setlocale( &POSIX::LC_CTYPE , $lang . ".UTF-8" );
+       POSIX::setlocale( &POSIX::LC_MESSAGES , $lang . ".UTF-8" );
+} else {
+       POSIX::setlocale( &POSIX::LC_CTYPE , $ccbs::config::lang );
+       POSIX::setlocale( &POSIX::LC_MESSAGES , $ccbs::config::lang );
+}
 Locale::gettext::bindtextdomain("ccbs", "po");
 Locale::gettext::textdomain("ccbs");
 
@@ -36,12 +45,12 @@ sub print_see_other {
        my $location = shift;
 
        print CGI::header(-status=>'303 See other',
-                         -location=>'http://ccbs.sesse.net/' . $location,
+                         -location=>$ccbs::config::webroot . $location,
                          -type=>'text/html; charset=utf-8');
 }
 
 sub db_connect {
-       my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=www.positivegaming.com", "ccbs", "GeT|>>B_")
+       my $dbh = DBI->connect("dbi:Pg:dbname=$ccbs::config::dbname;host=$ccbs::config::dbhost", $ccbs::config::dbuser, $ccbs::config::dbpass)
                or die "Couldn't connect to database";
        $dbh->{RaiseError} = 1;
        return $dbh;
@@ -79,7 +88,7 @@ sub process_template {
        my ($page, $title, $vars) = @_;
        $vars->{'page'} = $page;
        $vars->{'title'} = $title;
-       $vars->{'public'} = $config::ccbs::noadmin;
+       $vars->{'public'} = $ccbs::config::noadmin;
        $vars->{'timetogenerate'} = sprintf "%.3f", Time::HiRes::tv_interval($start_time);
        
        my $config = {
@@ -92,7 +101,7 @@ sub process_template {
        my $template = Template->new($config);
 
        my $output = '';
-       $template->process('main.tmpl', $vars, \$output)
+       $template->process($ccbs::config::main_template, $vars, \$output)
                or die $template->error();
 
        print $output;