diff --git a/modulekit.php b/modulekit.php
index 59b1d8e8..6b3cf35f 100644
--- a/modulekit.php
+++ b/modulekit.php
@@ -23,6 +23,7 @@ $include = array(
     'src/RepositoryDir.php',
     'src/RepositoryGit.php',
     'src/repositories.php',
+    'src/repositoriesGitea.php',
     'src/customCategory.php',
   ),
   'css' => array(
diff --git a/src/repositories.php b/src/repositories.php
index 2a56b83f..40f83dce 100644
--- a/src/repositories.php
+++ b/src/repositories.php
@@ -1,7 +1,6 @@
 <?php
 function getRepositories () {
   global $repositories;
-  global $repositoriesGitea;
   $result = array();
 
   if (isset($repositories)) {
@@ -15,33 +14,7 @@ function getRepositories () {
     );
   }
 
-  if (isset($repositoriesGitea)) {
-    $d1 = opendir($repositoriesGitea['path']);
-    while ($f1 = readdir($d1)) {
-      if (substr($f1, 0, 1) !== '.') {
-        $d2 = opendir("{$repositoriesGitea['path']}/{$f1}");
-        while ($f2 = readdir($d2)) {
-          if (substr($f2, 0, 1) !== '.') {
-            $f2id = substr($f2, 0, -4);
-
-            $r = array(
-              'path' => "{$repositoriesGitea['path']}/{$f1}/{$f2}",
-              'type' => 'git',
-            );
-
-            if (array_key_exists('url', $repositoriesGitea)) {
-	      $r['repositoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}";
-	      $r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.json";
-            }
-
-            $result["{$f1}/{$f2id}"] = $r;
-          }
-        }
-        closedir($d2);
-      }
-    }
-    closedir($d1);
-  }
+  call_hooks("get-repositories", $result);
 
   return $result;
 }
@@ -57,14 +30,3 @@ function getRepo ($repoId, $repoData) {
 
   return $repo;
 }
-
-register_hook('init', function () {
-  global $repositoriesGitea;
-
-  if (isset($repositoriesGitea) && array_key_exists('url', $repositoriesGitea)) {
-    $d = array('repositoriesGitea' => array(
-      'url' => $repositoriesGitea['url'],
-    ));
-    html_export_var($d);
-  }
-});
diff --git a/src/repositoriesGitea.php b/src/repositoriesGitea.php
new file mode 100644
index 00000000..81e94d4c
--- /dev/null
+++ b/src/repositoriesGitea.php
@@ -0,0 +1,43 @@
+<?php
+register_hook("get-repositories", function ($result) {
+  global $repositoriesGitea;
+
+  if (isset($repositoriesGitea)) {
+    $d1 = opendir($repositoriesGitea['path']);
+    while ($f1 = readdir($d1)) {
+      if (substr($f1, 0, 1) !== '.') {
+        $d2 = opendir("{$repositoriesGitea['path']}/{$f1}");
+        while ($f2 = readdir($d2)) {
+          if (substr($f2, 0, 1) !== '.') {
+            $f2id = substr($f2, 0, -4);
+
+            $r = array(
+              'path' => "{$repositoriesGitea['path']}/{$f1}/{$f2}",
+              'type' => 'git',
+            );
+
+            if (array_key_exists('url', $repositoriesGitea)) {
+	      $r['repositoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}";
+	      $r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.json";
+            }
+
+            $result["{$f1}/{$f2id}"] = $r;
+          }
+        }
+        closedir($d2);
+      }
+    }
+    closedir($d1);
+  }
+});
+
+register_hook('init', function () {
+  global $repositoriesGitea;
+
+  if (isset($repositoriesGitea) && array_key_exists('url', $repositoriesGitea)) {
+    $d = array('repositoriesGitea' => array(
+      'url' => $repositoriesGitea['url'],
+    ));
+    html_export_var($d);
+  }
+});