You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.1 KiB

<?php
/**
* autodoc
*
* Permettre le calcul d'URL vers un Gitlab d'une source issues d'un Vcs
*/
namespace autodoc\Plugin\Core\Compiler\Pass\VcsViewer;
/**
* Calcul d'URL pour visualiser des fichiers sources en ligne sur un Gitlab
**/
class Gitlab extends DefaultViewer
{
/**
* {@inheritDoc}
**/
public function getUrl() {
// https://gitlab.com/magraine/depublication/-/tree/master/prive
// https://gitlab.com/magraine/depublication/-/blob/master/depublication_fonctions.php
$vcs = $this->getVcs();
$url = $this->getUrlViewerRoot();
$url = rtrim($url . '/' . $vcs->getProjectPath(), '/');
if ($this->isDirFilename()) {
$url .= '/-/tree/';
} else {
$url .= '/-/blob/';
}
$url = rtrim($url . $vcs->getBranch(), '/');
$url = rtrim($url . '/' . $vcs->getInnerPath(), '/');
if ($this->getFilename()) $url .= '/' . $this->getFilename();
if ($this->getLine()) $url .= '#L' . $this->getLine();
return $url;
}
protected function isDirFilename() {
return false === strpos($this->getFilename(), '.');
}
}