diff --git a/controllers/treeController.php b/controllers/treeController.php
index 07fb903..03fe6a5 100644
--- a/controllers/treeController.php
+++ b/controllers/treeController.php
@@ -16,6 +16,7 @@ $app->get('{repo}/', function($repo) use($app) {
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
+ 'readme' => $app['utils']->getReadme($repo),
));
})->assert('repo', '[\w-._]+');
@@ -35,6 +36,7 @@ $app->get('{repo}/tree/{branch}/', function($repo, $branch) use($app) {
'breadcrumbs' => $breadcrumbs,
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
+ 'readme' => $app['utils']->getReadme($repo, $branch),
));
})->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+');
diff --git a/lib/Application/Utils.php b/lib/Application/Utils.php
index 78767a6..76ee742 100644
--- a/lib/Application/Utils.php
+++ b/lib/Application/Utils.php
@@ -245,4 +245,19 @@ class Utils
'total' => $totalCommits,
);
}
+
+ public function getReadme($repo, $branch = 'master')
+ {
+ $repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo);
+ $files = $repository->getTree('master')->output();
+
+ foreach ($files as $fileInfo)
+ if (preg_match('/^readme(\.md|\.markdown|)$/i', $fileInfo['name'])) {
+ $readmeFile = $fileInfo['name'];
+ break;
+ }
+
+ if ($readmeFile) return array('filename' => $readmeFile, 'content' => $repository->getBlob("$branch:'$readmeFile'")->output());
+ return array();
+ }
}
\ No newline at end of file
diff --git a/views/layout.twig b/views/layout.twig
index 84d6938..57535d0 100644
--- a/views/layout.twig
+++ b/views/layout.twig
@@ -14,6 +14,7 @@
+