This repository was archived by the owner on Apr 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
88 lines (68 loc) · 2.45 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Gitonomy\ChangeLog\Filter\FilterFactory;
use Gitonomy\Documentation\Documentation;
$app = new Gitonomy\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/../views',
'twig.options' => array(
'cache' => __DIR__.'/../cache/twig'
)
));
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->get('/', function() use($app) {
return $app['twig']->render('pages/homepage.html.twig');
})
->bind('homepage');
$app->get('/demo', function() use($app) {
return $app['twig']->render('pages/demo.html.twig');
})
->bind('demo');
$app->get('/download', function() use($app) {
$changeLog = $app['gitonomy.changelog'];
$currentVersion = $changeLog->getLastStableVersion();
return $app['twig']->render('pages/download.html.twig', array(
'changeLog' => $changeLog,
));
})
->bind('download');
$app->get('/features', function() use($app) {
return $app['twig']->render('pages/features.html.twig');
})
->bind('features');
$app->get('/doc/{project}/{version}/{path}', function ($project, $version, $path) use ($app) {
if (!in_array($project, array('gitlib', 'gitonomy'))) {
throw new \RuntimeException('Project not found');
}
if ($path == '') {
$path = 'index';
} elseif (preg_match('#/$#', $path)) {
$path = substr($path, 0, -1);
}
$document = $app[$project.'.documentation']->get($version, $path);
return $app['twig']->render('pages/documentation.html.twig', array(
'document' => $document,
'project' => $project,
'version' => $version,
'path' => $path
));
})
->assert('path', '.*')
->bind('documentation')
;
$app->get('/version.json', function () use ($app) {
$changeLog = $app['gitonomy.changelog'];
$currentVersion = $changeLog->getLastStableVersion();
return json_encode(array(
'version' => $currentVersion->getVersion(),
'date' => $currentVersion->getDate(),
));
});
$app->get('/changelog.json', function (Request $request) use ($app) {
$changelog = FilterFactory::createFromRequest($request)->filter($app['gitonomy.changelog']);
return json_encode($changelog->toArray());
});
$app->run();