mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 11:10:57 +01:00
contextual readme management
This commit is contained in:
@@ -41,7 +41,7 @@ class TreeController implements ControllerProviderInterface
|
|||||||
'breadcrumbs' => $breadcrumbs,
|
'breadcrumbs' => $breadcrumbs,
|
||||||
'branches' => $repository->getBranches(),
|
'branches' => $repository->getBranches(),
|
||||||
'tags' => $repository->getTags(),
|
'tags' => $repository->getTags(),
|
||||||
'readme' => $app['util.repository']->getReadme($repository, $branch),
|
'readme' => $app['util.repository']->getReadme($repository, $branch, $tree ? "$tree" : ""),
|
||||||
));
|
));
|
||||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||||
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
|
->assert('commitishPath', $app['util.routing']->getCommitishPathRegex())
|
||||||
|
|||||||
@@ -161,18 +161,21 @@ class Repository
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReadme($repository, $branch = null)
|
public function getReadme($repository, $branch = null, $path = "")
|
||||||
{
|
{
|
||||||
$files = $repository->getTree($branch)->output();
|
|
||||||
if ($branch === null) {
|
if ($branch === null) {
|
||||||
$branch = $repository->getHead();
|
$branch = $repository->getHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($path != "") $path = "$path/";
|
||||||
|
|
||||||
|
$files = $repository->getTree($path != "" ? "$branch:$path" : $branch)->output();
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (preg_match('/^readme*/i', $file['name'])) {
|
if (preg_match('/^readme*/i', $file['name'])) {
|
||||||
return array(
|
return array(
|
||||||
'filename' => $file['name'],
|
'filename' => $file['name'],
|
||||||
'content' => $repository->getBlob("$branch:\"{$file['name']}\"")->output()
|
'content' => $repository->getBlob("$branch:\"$path{$file['name']}\"")->output()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user