From: Emil Williams Date: Wed, 20 Aug 2025 23:54:32 +0000 (+0000) Subject: Hopefully Things Are Better Now X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=d75ac24491b782974517cbff207bfbc17e46bd56;p=gorillanest.git Hopefully Things Are Better Now --- d75ac24491b782974517cbff207bfbc17e46bd56 diff --cc .gitignore index ee90409,225e596..7459f49 --- a/.gitignore +++ b/.gitignore @@@ -1,5 -1,7 +1,6 @@@ + nytprof/ *.sqlite3 + *.db + *.out +config.pl git/* --!git/public/.gitkeep --!git/private/.gitkeep diff --cc gorillanest.pl.cgi index 8f688aa,a807fc4..6d01d7c --- a/gorillanest.pl.cgi +++ b/gorillanest.pl.cgi @@@ -1,9 -1,20 +1,19 @@@ #!/usr/bin/env perl + # XXX -# why are we passing around root like a cheap whore? ++# why are we passing around root like a cheap whore? because root is where things are (f(x) -> y) + # looking into it, i think we should have a global config object using -# https://metacpan.org/pod/Readonly ++# https://metacpan.org/pod/Readonly fuck read only, constants are for faggots + # -# i modified the routing heavily, this is how people do it; ++# i modified the routing heavily, this is how people do it; very scary + # pretty clean -# you must also realize that not all routes are necessarily templates, ++# you must also realize that not all routes are necessarily templates, then they are routed by nginx. + # it could be a redirect for example, so the original solution would -# complicate beyond comprehension ++# complicate beyond comprehension ACK. + use strict; use warnings; - use CGI; - use Switch::Back; use Template; use URI::Escape; use Cwd; @@@ -17,7 -28,14 +27,14 @@@ sub info warn join(' ', @_); } --our $template = Template->new({INCLUDE_PATH => 'template'}); + + sub serve_template { ++ my $template = Template->new({INCLUDE_PATH => 'template'}); + my ($template_name, $data) = @_; + + $template->process($template_name, $data) + or info("Template: " . $template->error()); + } # significant dirs only sub GN::directories { @@@ -55,32 -77,24 +76,25 @@@ sub GN::user { # /$username } sub GN::repository { # /$username/$repository - my ($root, $dataref) = @_; - my %data = %$dataref; - $data{found} = 0; - return \%data; - } + my ($root, $username, $repository) = @_; - sub serve_template { - my ($file, @rest) = @_; - my %vars = @rest ? @rest : (); - - $template->process($file, \%vars) - or info("Template: " . $template->error()); + die 'not implemented'; } - my %routes = ( - '/' => sub { serve_template("index.tt", @_) }, - '/~([a-zA-Z0-9_.]+)' => sub { serve_template("index_user.tt", @_) }, - '/~([a-zA-Z0-9_.]+)/([a-zA-Z0-9_.]+)' => sub { serve_template("repository.tt", @_) }, - ); - -my $public = 'repos/'; -my $dbfile = 'gorillanest.sqlite3'; +my $root = GIT_ROOT; +my $dbfile = DB_FILE; ++ my %data = ( found => 0, ); + my %routes = ( - '/' => sub { GN::index($public); }, - '/~([\w.]+)' => sub { GN::user($public, @_) }, - '/~([\w.]+)/([\w.]+)' => sub { GN::repository($public, @_) }, ++ '/' => sub { GN::index($root); }, ++ '/~([\w.]+)' => sub { GN::user($root, @_) }, ++ '/~([\w.]+)/([\w.]+)' => sub { GN::repository($root, @_) }, + ); + my %route_regex_cache = map { $_ => qr{^$_$} } keys %routes; + sub master { my $cgi = CGI->new; my %header = ( @@@ -97,9 -112,7 +112,9 @@@ } } - serve_template("404.tt"); # XXX missing code + serve_template("404.tt", {}); # XXX missing code } -master() if !caller; 1; +master() if !caller; + +1; diff --cc gorillanest.pl.fcgi index 2692877,d44df66..a9d77c0 --- a/gorillanest.pl.fcgi +++ b/gorillanest.pl.fcgi @@@ -6,14 -6,11 +6,13 @@@ use warnings use Syntax::Keyword::Try; use FCGI; +use lib '.'; - # BEGIN { require 'config.pl'; } BEGIN { require 'gorillanest.pl.cgi'; } -our $request = FCGI::Request(); - try { + open STDERR, '>', LOG_FILE or die LOG_FILE . ": $!"; + my $sock = FCGI::OpenSocket(SOCKET_FILE, 100); + my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock); while($request->Accept() >= 0) { master(); }