static function pathToWork($slug, $strptime = null)
{
$cachename = self::cachenameFromURI($slug, $strptime);
$basedir = gb::$site_dir . '/content/posts/';
$glob_skip = '/(\\.comments|\\/)$/';
# first, try if the post resides under the cachename, but in the workspace:
$path = $basedir . $cachename;
if (is_file($path)) {
return $path;
}
# try any file with the cachename as prefix
if ($path = gb::glob($path . '*', $glob_skip)) {
return $path;
}
# next, try a wider glob search
# todo: optimise: find minimum time resolution by examining $posts_cn_pattern
# for now we will assume the default resolution/granularity of 1 month.
$path = $basedir . gmstrftime('{%Y,%y,%G,%g}{?,/}%m', gb_mkutctime($strptime)) . '{*,*/*,*/*/*,*/*/*/*}' . $strptime['unparsed'] . '*';
if ($path = gb::glob($path, $glob_skip)) {
return $path;
}
# we're out of luck :(
return null;
}