]> git.xolatile.top Git - gorillanest.git/commitdiff
2 Wizards In Detroit Getting McDonalds, Difficulty: Impossible
authorEmil Williams <emilemilemil@cock.li>
Sun, 17 Aug 2025 13:11:57 +0000 (13:11 +0000)
committerEmil Williams <emilemilemil@cock.li>
Sun, 17 Aug 2025 13:11:57 +0000 (13:11 +0000)
gorillanest
template/404.tt [new file with mode: 0644]
template/foot.tt [new file with mode: 0644]
template/head.tt [new file with mode: 0644]
template/index.tt [new file with mode: 0644]
template/index_user.tt [new file with mode: 0644]
template/repository.tt [new file with mode: 0644]

index baa196e5bf5c1e7cc82324e9258de3b141967103..6a917c1f3de9e7c7cda1cfca35705de4f6c56fea 100755 (executable)
@@ -47,12 +47,12 @@ sub GN::user { # /$username/
     return \@directories;
 }
 
-sub GN::repository { # /$username/(.*?(\.git)?)
+sub GN::repository { # /$username/$repository
     my ($root, $dataref) = @_;
     my %data = %$dataref;
-    print "* repository: $data{repository}\n";
     my @directories = @{GN::directories(join('/', $root, $data{name}, $data{repository}))};
-    print "@directories\n";
+    return \@directories;
+    # obviously should be doing more
 }
 
 sub GN::cache { # cache{'/some/path'}
@@ -84,6 +84,7 @@ try {
     # $db->disconnect;
     #
     my $head = 0;
+    my $a_template;
     while($request->Accept() >= 0) {
         my $cgi = CGI->new;
         my %header = (
@@ -96,27 +97,23 @@ try {
             $head = 1;
         } elsif ($method eq 'GET') {
             ($data{name}, $data{repository}) = $uri =~ m{/(.*?)/(?:(.*))?};
-            info("name:", $data{name} || '', "repo:", $data{repository} || '');
-            if ($head) { $head = 0; continue; }
+            # info("name:", $data{name} || '', "repo:", $data{repository} || '');
             if ($uri eq '/') {
-                print $cgi->header(%header);
-                print "* Index\n";
-                my @directories = @{GN::index($gitroot, \%data)};
-                print "@directories\n";
-            } elsif ($data{repository}) { # this will generally fail
-                print $cgi->header(%header);
-                print "* Repository\n";
-                my @directories = @{GN::repositories($gitroot, \%data)};
-                print "@directories\n";
-            } elsif ($data{name}) { # this acts like a default case
-                print $cgi->header(%header);
-                print "* User: $data{name}\n";
-                my @directories = @{GN::user($gitroot, \%data)};
-                print "@directories\n";
+                $data{directories} = GN::index($gitroot, \%data);
+                $a_template = "index.tt";
+            } elsif ($data{repository}) {
+                $data{directories} = GN::repositories($gitroot, \%data);
+                $a_template = "repository.tt";
+            } elsif ($data{name}) {
+                $data{directories} = GN::user($gitroot, \%data);
+                $a_template = "index_user.tt";
             } else {
                 $header{-status} = '404 Not Found';
-                print $cgi->header(%header);
+                $a_template = "404.tt";
             }
+            print $cgi->header(%header);
+            if ($head) { $head = 0; continue; }
+            $template->process($a_template, \%data) or info("Template: " . $template->error());
         } else {
             $header{-status} = '405 Method Not Allowed';
             print $cgi->header(%header);
diff --git a/template/404.tt b/template/404.tt
new file mode 100644 (file)
index 0000000..9d93d48
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+[% INCLUDE head.tt %]
+<body>
+<h1>404</h1>
+</body>
+[% INCLUDE foot.tt %]
+</html>
diff --git a/template/foot.tt b/template/foot.tt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/template/head.tt b/template/head.tt
new file mode 100644 (file)
index 0000000..1a9d3d9
--- /dev/null
@@ -0,0 +1,2 @@
+<head>
+</head>
diff --git a/template/index.tt b/template/index.tt
new file mode 100644 (file)
index 0000000..bf0c501
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+[% INCLUDE head.tt %]
+<body>
+<h1>index</h1>
+[% FOR i IN directories %]
+[% i %]
+[% END %]
+</body>
+[% INCLUDE foot.tt %]
+</html>
diff --git a/template/index_user.tt b/template/index_user.tt
new file mode 100644 (file)
index 0000000..2cbfbed
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+[% INCLUDE head.tt %]
+<body>
+<h1>index_user</h1>
+</body>
+[% INCLUDE foot.tt %]
+</html>
diff --git a/template/repository.tt b/template/repository.tt
new file mode 100644 (file)
index 0000000..004413d
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+[% INCLUDE head.tt %]
+<body>
+<h1>repository</h1>
+</body>
+[% INCLUDE foot.tt %]
+</html>