diff --git a/lib/CProject.php b/lib/CProject.php index 4d5ec9c..4e05a46 100644 --- a/lib/CProject.php +++ b/lib/CProject.php @@ -25,6 +25,7 @@ class CProject { public $homeimage = null; protected $go_get_target = ''; + protected $git_repo = ''; public function __construct($dirname, $projname) { $this->dir = BASEDIR.'data/'.$dirname.'/'; @@ -98,21 +99,29 @@ class CProject { // Filters for longdesc - $prefix_html = ''; - $this->longdesc = preg_replace_callback('~\nWritten in ([^\\n]+)~ms', function($matches) use (&$prefix_html) { - $prefix_html .= ( + $this->prefix_html = ''; + $this->longdesc = preg_replace_callback('~\nWritten in ([^\\n]+)~ms', function($matches) { + $this->prefix_html .= ( (SHIELDS_PREFIX ? mkshield('build', 'success', 'brightgreen').' ' : ''). mkshield('written in', rtrim($matches[1], '.'), 'blue') ); return ''; }, $this->longdesc); + // Find 'git-repository' tags + $this->longdesc = preg_replace_callback('~\[git\](.+)\[/git\]~', function($matches) { + $this->git_repo = $matches[1]; + if (strlen($this->prefix_html) > 0) { + $this->prefix_html .= ' '; + } + $this->prefix_html .= ''.mkshield('vcs', 'git', 'yellowgreen', ['logo' => 'git']).''; + return ''; + }, $this->longdesc); + while(strpos($this->longdesc, "\n\n\n") !== false) { $this->longdesc = str_replace("\n\n\n", "\n\n", $this->longdesc); } $this->longdesc = rtrim($this->longdesc, "\n")."\n"; - - $this->prefix_html = $prefix_html; continue; } diff --git a/lib/util.php b/lib/util.php index 2964a02..7d354f7 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1,14 +1,17 @@ 0) { + $filename .= '?' . http_build_query($params); + } - $cache_path = SHIELDS_CACHE_DIR.$filename; + $cache_path = SHIELDS_CACHE_DIR.urlencode($filename); if (file_exists($cache_path)) { return file_get_contents($cache_path);