add option author="none"

This commit is contained in:
2022-01-01 08:08:04 +01:00
parent 4b7b8d4a13
commit f6abb63a22
4 changed files with 15 additions and 10 deletions

View File

@ -3,7 +3,7 @@
/*
Plugin Name: Gitlab REST API Shortcodes
Plugin URI: http://tk-sls.de/ref/gitlab-list-commits
Description: Summary: Embed list of most recent commits to a Gitlab project from a Gitlab instance's public REST API. Example: Add [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 commits="all" since="3 month" max=5 releases="latest"] for a list of at most 5 commits to that project that were made since at most 3 months ago, followed by alink to the latest release of the project (if any). To disable the list of commits, set commits="none". To generate a list of all releases, set releases="all". To disable the list of releases, omit the "releases" attribute or set releases="none".
Description: Summary: Embed list of most recent commits to a Gitlab project from a Gitlab instance's public REST API. Example: Add [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 commits="all" since="3 month" max=5 releases="latest"] for a list of at most 5 commits to that project that were made since at most 3 months ago, followed by alink to the latest release of the project (if any). To disable the list of commits, set commits="none". To disable printing the author name of a commit, set author="none". To generate a list of all releases, set releases="all". To disable the list of releases, omit the "releases" attribute or set releases="none".
Author: Tilman Kranz
Version: 1.4
Author URI: https://tk-sls.de
@ -57,15 +57,19 @@ class LinuxfooGitlab {
static function format_commit($atts, $commit) {
preg_match('/^....-..-../', $commit->committed_date, $m);
$date = $m[0];
$title = htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE);
$result = $m[0].' ';
return
$date.' '.
__('by', 'linuxfoo-gitlab').' '.$commit->author_name.
if($atts['author']==null || $atts['author']!='none')
$result .=
__('by', 'linuxfoo-gitlab').' '.$commit->author_name;
$result .=
': '.
'<a href="'.$commit->web_url.'">'.$commit->short_id.'</a> '.$title;
'<a href="'.$commit->web_url.'">'.$commit->short_id.'</a> '.
htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE);
return $result;
}
static function format_commit_stats($atts, $commits_count, $branch) {