diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| l--------- | config.pl | 1 | ||||
| -rw-r--r-- | config.pl.example | 1 | ||||
| -rwxr-xr-x | gorillanest.pl.cgi | 30 | ||||
| -rwxr-xr-x | gorillanest.pl.fcgi | 6 | ||||
| l--------- | repos | 1 |
6 files changed, 22 insertions, 20 deletions
@@ -2,6 +2,5 @@ nytprof/ *.sqlite3 *.db *.out +config.pl git/* -!git/public/.gitkeep -!git/private/.gitkeep diff --git a/config.pl b/config.pl deleted file mode 120000 index 1813fbf..0000000 --- a/config.pl +++ /dev/null @@ -1 +0,0 @@ -config.pl.example
\ No newline at end of file diff --git a/config.pl.example b/config.pl.example index fd39608..c6becdf 100644 --- a/config.pl.example +++ b/config.pl.example @@ -1,4 +1,5 @@ # always assume anything to do with files is from project root +use constant LOG_FILE => '/tmp/gorillanest.log'; use constant GIT_ROOT => 'git'; # directory containing all browsable $users/$repositories use constant DB_FILE => 'gorillanest.sqlite3'; # sqlite3 database file location use constant TEMPLATE_ROOT => 'template'; # template directory diff --git a/gorillanest.pl.cgi b/gorillanest.pl.cgi index a807fc4..6d01d7c 100755 --- a/gorillanest.pl.cgi +++ b/gorillanest.pl.cgi @@ -1,19 +1,18 @@ #!/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 Template; use URI::Escape; @@ -28,9 +27,9 @@ 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) @@ -40,7 +39,7 @@ sub serve_template { # significant dirs only sub GN::directories { my $root = $_[0]; - opendir my $dir, $root or die "Cannot open directory '$root': $!"; + opendir my $dir, $root or die "$root: $!"; my @directories; my %drop = ( '.' => 0, @@ -82,16 +81,17 @@ sub GN::repository { # /$username/$repository die 'not implemented'; } -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; @@ -115,4 +115,6 @@ sub master { serve_template("404.tt", {}); # XXX missing code } -master() if !caller; 1; +master() if !caller; + +1; diff --git a/gorillanest.pl.fcgi b/gorillanest.pl.fcgi index d44df66..a9d77c0 100755 --- a/gorillanest.pl.fcgi +++ b/gorillanest.pl.fcgi @@ -6,11 +6,13 @@ use warnings; use Syntax::Keyword::Try; use FCGI; +use lib '.'; 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(); } @@ -1 +0,0 @@ -dummy_repos
\ No newline at end of file |
