automatically configure git paths (dir + public clone url)
authorChristian Weiske <cweiske@cweiske.de>
Mon, 7 Jul 2014 06:50:08 +0000 (08:50 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 7 Jul 2014 06:50:08 +0000 (08:50 +0200)
data/config.default.php
src/phorkie/Tools.php
www/www-header.php

index 2e588fadc39fb8a93a68bfade175f5285d899e6d..5b56fc7e16d87de96bdd0c60102c4276c03cc30f 100644 (file)
@@ -2,15 +2,21 @@
 $pharFile = \Phar::running();
 if ($pharFile == '') {
     $phorkieDir = __DIR__ . '/../';
 $pharFile = \Phar::running();
 if ($pharFile == '') {
     $phorkieDir = __DIR__ . '/../';
+    $wwwDir = $phorkieDir . 'www/';
 } else {
     //remove phar:// from the path
     $phorkieDir = dirname(substr($pharFile, 7)) . '/';
 } else {
     //remove phar:// from the path
     $phorkieDir = dirname(substr($pharFile, 7)) . '/';
+    $wwwDir = $phorkieDir;
 }
 
 $GLOBALS['phorkie']['cfg'] = array(
     'debug'         => false,
 }
 
 $GLOBALS['phorkie']['cfg'] = array(
     'debug'         => false,
-    'gitdir'        => $phorkieDir . 'repos/git/',
-    'workdir'       => $phorkieDir . 'repos/work/',
+    'git'           => array(
+        'public'    => '%BASEURL%' . 'repos/git/',
+        'private'   => null,
+    ),
+    'gitdir'        => $wwwDir . 'repos/git/',
+    'workdir'       => $wwwDir . 'repos/work/',
     'tpl'           => __DIR__ . '/templates/',
     'baseurl'       => null,
     'avatars'       => true,
     'tpl'           => __DIR__ . '/templates/',
     'baseurl'       => null,
     'avatars'       => true,
index e97c5464f5ce789bd17230f8eeb3b5008800af97..2febb29a222907621137239122a2f83493254dfe 100644 (file)
@@ -48,6 +48,23 @@ class Tools
         return $prot . '://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phorkie']['cfg']['baseurl'] . $path;
     }
 
         return $prot . '://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phorkie']['cfg']['baseurl'] . $path;
     }
 
+    /**
+     * Get the full URL to a path, but remove the .phar file from
+     * the base URL if necessary
+     *
+     * @param string $path Path to the file
+     *
+     * @return string Full URL without .phar/
+     */
+    public static function fullUrlNoPhar($path = '')
+    {
+        $base = static::fullUrl();
+        if (substr($base, -6) == '.phar/') {
+            $base = dirname($base) . '/';
+        }
+        return $base . $path;
+    }
+
     /**
      * Removes malicious parts from a file name
      *
     /**
      * Removes malicious parts from a file name
      *
index 5381eed67a4f01e89b528ad7a47a8630d6031d9d..eaf19520bef3b840586ad7ac4c61116591bee118 100644 (file)
@@ -50,6 +50,12 @@ if (file_exists($cfgFilePath)) {
 
 if ($GLOBALS['phorkie']['cfg']['baseurl'] === null) {
     $GLOBALS['phorkie']['cfg']['baseurl'] = Tools::detectBaseUrl();
 
 if ($GLOBALS['phorkie']['cfg']['baseurl'] === null) {
     $GLOBALS['phorkie']['cfg']['baseurl'] = Tools::detectBaseUrl();
+    if (substr($GLOBALS['phorkie']['cfg']['git']['public'], 0, 9) == '%BASEURL%') {
+        //make autoconfig work
+        $GLOBALS['phorkie']['cfg']['git']['public'] = Tools::fullUrlNoPhar(
+            substr($GLOBALS['phorkie']['cfg']['git']['public'], 9)
+        );
+    }
 }
 
 // Set/Get git commit session variables
 }
 
 // Set/Get git commit session variables