Add clone/push url support
Add clone/push url support

--- a/config/gitphp.conf.php.example
+++ b/config/gitphp.conf.php.example
@@ -207,6 +207,29 @@
 $gitphp_conf['cachelifetime'] = 3600;
 
 /*
+ * cloneurl
+ * Sets the base clone url to display for a project.
+ * This is the publicly-accessible url of the projectroot
+ * that gets prepended to the project path to create the clone
+ * url.  It can be any format, for example:
+ *
+ * http://server.com/
+ * ssh://server.com/git/
+ * git://server.com/gitprojects/
+ * (don't forget trailing slash)
+ * 
+ * If left blank/commented, no clone url will display.
+ */
+//$gitphp_conf['cloneurl'] = "http://localhost/git/";
+
+/*
+ * pushurl
+ * Sets the base push url to display for a project.
+ * Works the same as cloneurl.
+ */
+//$gitphp_conf['pushurl'] = "ssh://localhost/git/";
+
+/*
  * git_projects
  * Two-dimensional array list of projects
  * First array index is the name of the category the projects

--- a/include/display.git_summary.php
+++ b/include/display.git_summary.php
@@ -18,7 +18,7 @@
 
 function git_summary($projectroot,$project)
 {
-	global $tpl;
+	global $tpl,$gitphp_conf;
 
 	$cachekey = sha1($project);
 
@@ -33,6 +33,10 @@
 		$tpl->assign("description",$descr);
 		$tpl->assign("owner",$owner);
 		$tpl->assign("lastchange",$commitdate['rfc2822']);
+		if (isset($gitphp_conf['cloneurl']))
+			$tpl->assign('cloneurl', $gitphp_conf['cloneurl'] . $project);
+		if (isset($gitphp_conf['pushurl']))
+			$tpl->assign('pushurl', $gitphp_conf['pushurl'] . $project);
 		$revlist = git_read_revlist($projectroot . $project, $head, 17);
 		foreach ($revlist as $i => $rev) {
 			$revdata = array();

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -19,6 +19,12 @@
    <tr><td>description</td><td>{$description}</td></tr>
    <tr><td>owner</td><td>{$owner}</td></tr>
    <tr><td>last change</td><td>{$lastchange}</td></tr>
+   {if $cloneurl}
+     <tr><td>clone url</td><td>{$cloneurl}</td></tr>
+   {/if}
+   {if $pushurl}
+     <tr><td>push url</td><td>{$pushurl}</td></tr>
+   {/if}
  </table>
  <div>
    <a class="title" href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a>

comments