Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setup multi gitiki wiki
{
"require": {
"gitiki/gitiki": ">=1.0-dev",
"gitiki/code-highlight": ">=1.0-dev"
}
}
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$titles = [
'elasticsearch' => 'Elasticsearch',
'methodes-developpement' => 'Méthodes de développement',
];
require_once __DIR__.'/vendor/autoload.php';
if (!preg_match('#^'.preg_quote($_SERVER['SCRIPT_NAME'], '#').'/([^/]+)#', $_SERVER['REQUEST_URI'], $match)) {
$response = new Response();
$wikis = [];
foreach (glob('*', GLOB_ONLYDIR) as $wiki) {
if ('vendor' === $wiki) {
continue;
}
$wikis[] = '<a href="'.$_SERVER['SCRIPT_NAME'].'/'.$wiki.'">'.(isset($titles[$wiki]) ? $titles[$wiki] : $wiki).'</a>';
}
Response::create(sprintf('<html><head></head><body>%s</body></html>', implode($wikis, '<br>')))
->prepare(Request::createFromGlobals())
->send()
;
return;
}
// Manual url rewriting
$_SERVER["SCRIPT_FILENAME"] .= '/'.$match[1];
$_SERVER["SCRIPT_NAME"] .= '/'.$match[1];
$app = new Gitiki\Gitiki();
$app['locale'] = 'en';
$app['wiki_dir'] = __DIR__.'/'.$match[1];
$app['wiki_title'] = isset($titles[$match[1]]) ? $titles[$match[1]] : $match[1];
$app->register(new Gitiki\CodeHighlight\CodeHighlightServiceProvider());
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment