Last active
September 15, 2015 12:00
-
-
Save francisbesset/5f5551a38c8c3037a80f to your computer and use it in GitHub Desktop.
Setup multi gitiki wiki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"gitiki/gitiki": ">=1.0-dev", | |
"gitiki/code-highlight": ">=1.0-dev" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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