support linking to custom go repositories
This commit is contained in:
parent
fb20358834
commit
ff70556d8e
@ -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 .= '<a href="'.hesc($this->git_repo).'">'.mkshield('vcs', 'git', 'yellowgreen', ['logo' => 'git']).'</a>';
|
||||
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;
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
<?php
|
||||
|
||||
function mkshield($left_str, $right_str, $color_str) {
|
||||
function mkshield($left_str, $right_str, $color_str, $params=[]) {
|
||||
$filename = sprintf(
|
||||
"%s-%s-%s.svg",
|
||||
rawurlencode(str_replace('-', '--', $left_str)),
|
||||
rawurlencode(str_replace('-', '--', $right_str)),
|
||||
rawurlencode($color_str)
|
||||
);
|
||||
if (count($params) > 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);
|
||||
|
Reference in New Issue
Block a user