Skip to content

Instantly share code, notes, and snippets.

@francisbesset
Last active September 15, 2015 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francisbesset/5f5551a38c8c3037a80f to your computer and use it in GitHub Desktop.
Save francisbesset/5f5551a38c8c3037a80f to your computer and use it in GitHub Desktop.
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