support go subpackages
This commit is contained in:
parent
8a43a8181e
commit
fb20358834
@ -46,6 +46,9 @@ function main($args) {
|
||||
if (array_key_exists('redirect', $config)) {
|
||||
buildredirects( $config['redirect'] );
|
||||
}
|
||||
if (array_key_exists('golang-subpackages', $config)) {
|
||||
buildgosubpackages( $config['golang-subpackages'] );
|
||||
}
|
||||
} else {
|
||||
buildprojects($pos, array_decimate(listprojects(), $total, $pos));
|
||||
}
|
||||
|
@ -194,3 +194,19 @@ function buildredirects($redirects) {
|
||||
file_put_contents(BASEDIR.'wwwroot/'.$oldname.'/index.html', $page);
|
||||
}
|
||||
}
|
||||
|
||||
function buildgosubpackages($packages) {
|
||||
foreach($packages as $path => $goGetStr) {
|
||||
|
||||
$page = (
|
||||
'<meta name="go-import" content="'.hesc($goGetStr).'">'.
|
||||
"\n".
|
||||
redirecthtml(BASEURL)
|
||||
);
|
||||
|
||||
// new directory format only
|
||||
mkdir_all(BASEDIR.'wwwroot/'.$path);
|
||||
file_put_contents(BASEDIR.'wwwroot/'.$path.'/index.html', $page);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,11 @@ function hesc($sz) {
|
||||
return @htmlentities($sz, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
function mkdir_all($path) {
|
||||
$epath = escapeshellarg($path);
|
||||
`mkdir -p ${epath}`;
|
||||
}
|
||||
|
||||
function text2html($sz) {
|
||||
|
||||
$identity = function($sz) {
|
||||
|
Reference in New Issue
Block a user