aboutsummaryrefslogtreecommitdiff
path: root/gorillanest.pl.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'gorillanest.pl.cgi')
-rwxr-xr-xgorillanest.pl.cgi30
1 files changed, 16 insertions, 14 deletions
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;