]> git.xolatile.top Git - gorillanest.git/commitdiff
Hopefully Things Are Better Now
authorEmil Williams <emilemilemil@cock.li>
Wed, 20 Aug 2025 23:54:32 +0000 (23:54 +0000)
committerEmil Williams <emilemilemil@cock.li>
Wed, 20 Aug 2025 23:54:32 +0000 (23:54 +0000)
1  2 
.gitignore
gorillanest.pl.cgi
gorillanest.pl.fcgi

diff --cc .gitignore
index ee9040973d8910a07b36cb27266783929f8d7bf0,225e5968c74025c6bf790e4ea1961e4b7584b771..7459f4967ddad48c8e68a1b077a8fdff2a77740a
@@@ -1,5 -1,7 +1,6 @@@
+ nytprof/
  *.sqlite3
+ *.db
+ *.out
 +config.pl
  git/*
--!git/public/.gitkeep
--!git/private/.gitkeep
index 8f688aaf2fd5ea67f529fb3a22d4f9e1926af969,a807fc49e2c5664d6abeb1f3ecd0dcd268ef1229..6d01d7c16fe94455012fa6634b67eca22ebd6b88
@@@ -1,9 -1,20 +1,19 @@@
  #!/usr/bin/env perl
  
 -# why are we passing around root like a cheap whore?
+ # XXX
 -# https://metacpan.org/pod/Readonly
++# 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
 -# i modified the routing heavily, this is how people do it;
++# https://metacpan.org/pod/Readonly                                             fuck read only, constants are for faggots
+ #
 -# you must also realize that not all routes are necessarily templates,
++# i modified the routing heavily, this is how people do it;                     very scary
+ # pretty clean
 -# complicate beyond comprehension
++# 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                                               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,
  );
  
 -    '/'                   => sub { GN::index($public); },
 -    '/~([\w.]+)'          => sub { GN::user($public, @_) },
 -    '/~([\w.]+)/([\w.]+)' => sub { GN::repository($public, @_) },
+ my %routes = (
++    '/'                   => 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 = (
                }
        }
  
-       serve_template("404.tt"); # XXX missing code
+       serve_template("404.tt", {}); # XXX missing code
  }
  
 -master() if !caller; 1;
 +master() if !caller;
 +
 +1;
index 2692877baeb8b41d2804239002a7e8492b6e434b,d44df66d779b3204f5e2a8da568d8715bf530d79..a9d77c0f2fa68140c93e8f1a46ee68d61ff2fce3
@@@ -6,14 -6,11 +6,13 @@@ use warnings
  use Syntax::Keyword::Try;
  use FCGI;
  
- # BEGIN { require 'config.pl'; }
 +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();
      }