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.
40 lines
1.1 KiB
40 lines
1.1 KiB
3 years ago
|
<?php
|
||
|
/**
|
||
|
* autodoc
|
||
|
*
|
||
|
* Permettre le calcul d'URL vers un Github 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 Github
|
||
|
**/
|
||
|
class Github extends DefaultViewer
|
||
|
{
|
||
|
/**
|
||
|
* {@inheritDoc}
|
||
|
**/
|
||
|
public function getUrl() {
|
||
|
// https://github.com/marcimat/bigup/tree/master/saisies
|
||
|
// https://github.com/marcimat/bigup/blob/master/saisies/bigup.html
|
||
|
$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(), '.');
|
||
|
}
|
||
|
}
|