Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fb5d9a8f52 | ||
f6abb63a22 | |||
4b7b8d4a13 | |||
95fa3719db | |||
6efb5ccf18 | |||
7c7685bee7 |
@ -44,6 +44,7 @@ The following optional attributes modify the behavior of the list of commits:
|
|||||||
* `max=NUM`: Optional; `NUM`: Positive integer; list not more than `NUM` commits (example: `5`).
|
* `max=NUM`: Optional; `NUM`: Positive integer; list not more than `NUM` commits (example: `5`).
|
||||||
* `ref_name=STRING`: Optional: list only commit from branch or reference name `STRING` (examples: `main`, `v1.1`).
|
* `ref_name=STRING`: Optional: list only commit from branch or reference name `STRING` (examples: `main`, `v1.1`).
|
||||||
* `default_branch`: Optional; if set, list only commits from the project's default branch.
|
* `default_branch`: Optional; if set, list only commits from the project's default branch.
|
||||||
|
* `author="none"`: Optional; do not print names of authors in the commit list.
|
||||||
|
|
||||||
## Author and License
|
## Author and License
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ msgid "http://tk-sls.de/ref/gitlab-list-commits"
|
|||||||
msgstr "http://tk-sls.de/ref/gitlab-list-commits"
|
msgstr "http://tk-sls.de/ref/gitlab-list-commits"
|
||||||
|
|
||||||
#. Description of the plugin
|
#. Description of the plugin
|
||||||
msgid "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\"."
|
msgid "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\"."
|
||||||
msgstr "Zusammenfassung: Bette Liste der neuesten Commits eines Gitlab-Projektes ein, die mit Gitlabs REST API abgerufen wird. Beispiel: Füge folgenden Shortcode zu einem Artikel hinzu, um die letzten 5 Commits anzuzeigen, die nicht älter als 3 Monate sind: [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 since=\"3 month\" max=5]. Um die Liste der Commits zu deaktivieren: commits=\"none\". Um eine Liste von Releases hinzuzufügen: releases=\"all\". Um nur die neueste Release anzuzeigen: releases=\"latest\"."
|
msgstr "Zusammenfassung: Bette Liste der neuesten Commits eines Gitlab-Projektes ein, die mit Gitlabs REST API abgerufen wird. Beispiel: Füge folgenden Shortcode zu einem Artikel hinzu, um die letzten 5 Commits anzuzeigen, die nicht älter als 3 Monate sind: [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 since=\"3 month\" max=5]. Um die Liste der Commits zu deaktivieren: commits=\"none\". Um die Ausgabe der Autor-Namens pro Commit zu deaktivieren: author=\"none\". Um eine Liste von Releases hinzuzufügen: releases=\"all\". Um nur die neueste Release anzuzeigen: releases=\"latest\"."
|
||||||
|
|
||||||
#. Author of the plugin
|
#. Author of the plugin
|
||||||
msgid "Tilman Kranz"
|
msgid "Tilman Kranz"
|
||||||
|
@ -23,7 +23,7 @@ msgid "http://tk-sls.de/ref/gitlab-list-commits"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. Description of the plugin
|
#. Description of the plugin
|
||||||
msgid "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\"."
|
msgid "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\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. Author of the plugin
|
#. Author of the plugin
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
Plugin Name: Gitlab REST API Shortcodes
|
Plugin Name: Gitlab REST API Shortcodes
|
||||||
Plugin URI: http://tk-sls.de/ref/gitlab-list-commits
|
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
|
Author: Tilman Kranz
|
||||||
Version: 1.4
|
Version: 1.4
|
||||||
Author URI: https://tk-sls.de
|
Author URI: https://tk-sls.de
|
||||||
@ -28,6 +28,14 @@ class LinuxfooGitlab {
|
|||||||
'</span>';
|
'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function project_header($atts, $project) {
|
||||||
|
return
|
||||||
|
'<span class="project_header">'.
|
||||||
|
__('Gitlab project', 'linuxfoo-gitlab').' '.
|
||||||
|
'<a href="'.$project->web_url.'">'.$project->name.'</a>'.
|
||||||
|
'</span>';
|
||||||
|
}
|
||||||
|
|
||||||
static function format_since($since) {
|
static function format_since($since) {
|
||||||
preg_match('/^([0-9]+)\s+(.*)$/', $since, $m);
|
preg_match('/^([0-9]+)\s+(.*)$/', $since, $m);
|
||||||
$num = $m[1];
|
$num = $m[1];
|
||||||
@ -48,42 +56,34 @@ class LinuxfooGitlab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function format_commit($atts, $commit) {
|
static function format_commit($atts, $commit) {
|
||||||
$out = '';
|
|
||||||
|
|
||||||
preg_match('/^....-..-../', $commit->committed_date, $m);
|
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].' ';
|
||||||
|
|
||||||
$out .=
|
if($atts['author']==null || $atts['author']!='none')
|
||||||
$date.' '.
|
$result .=
|
||||||
__('by', 'linuxfoo-gitlab').' '.$commit->author_name.
|
__('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 $out;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function format_commit_stats($atts, $commits_count, $branch) {
|
static function format_commit_stats($atts, $commits_count, $branch) {
|
||||||
$out = '';
|
return
|
||||||
|
(
|
||||||
if($commits_count==0) {
|
($commits_count==0)
|
||||||
$out .=
|
? __('No commits', 'linuxfoo-gitlab')
|
||||||
__('No commits', 'linuxfoo-gitlab').
|
|
||||||
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
|
|
||||||
(is_null($atts['since']) ? '' : ' '.('since '.$atts['since'].' ago')).'.';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$out .=
|
|
||||||
/* translators: %d: maximum number of commits displayed */
|
/* translators: %d: maximum number of commits displayed */
|
||||||
sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count).
|
: sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count)
|
||||||
|
).
|
||||||
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
|
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
|
||||||
(is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':';
|
(is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function commits_list($atts, $project_url) {
|
static function commits_list($atts, $project_url) {
|
||||||
$since = null;
|
$since = null;
|
||||||
|
|
||||||
@ -144,13 +144,13 @@ class LinuxfooGitlab {
|
|||||||
'</span>';
|
'</span>';
|
||||||
|
|
||||||
if($commits_count>0) {
|
if($commits_count>0) {
|
||||||
$out .= '<ul class="commits">';
|
$out .= '<span class="commits" role="list">';
|
||||||
|
|
||||||
foreach($commits as $commit) {
|
foreach($commits as $commit) {
|
||||||
$out .= '<li>'.self::format_commit($atts, $commit).'</li>';
|
$out .= '<span class="commit">'.self::format_commit($atts, $commit).'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= '</ul>';
|
$out .= '</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,32 +183,32 @@ class LinuxfooGitlab {
|
|||||||
else {
|
else {
|
||||||
if(count($releases)==0) {
|
if(count($releases)==0) {
|
||||||
$out .=
|
$out .=
|
||||||
'<p class="releases">'.
|
'<span class="releases">'.
|
||||||
__('This project has currently no releases.', 'linuxfoo-gitlab').
|
__('This project has currently no releases.', 'linuxfoo-gitlab').
|
||||||
'</p>';
|
'</span>';
|
||||||
}
|
}
|
||||||
elseif($atts['releases']=='latest') {
|
elseif($atts['releases']=='latest') {
|
||||||
$out .=
|
$out .=
|
||||||
'<p class="releases">'.
|
'<span class="releases">'.
|
||||||
__('Latest release', 'linuxfoo-gitlab').': '.
|
__('Latest release', 'linuxfoo-gitlab').': '.
|
||||||
'<a href="'.$releases[0]->_links->self.'">'.$releases[0]->name.'</a>'.
|
'<a href="'.$releases[0]->_links->self.'">'.$releases[0]->name.'</a>'.
|
||||||
'</p>';
|
'</span>';
|
||||||
}
|
}
|
||||||
elseif($atts['releases']=='all') {
|
elseif($atts['releases']=='all') {
|
||||||
$out .=
|
$out .=
|
||||||
'<p class="releases">'.
|
'<span class="releases">'.
|
||||||
__('Releases', 'linuxfoo-gitlab').': '.
|
__('Releases', 'linuxfoo-gitlab').': '.
|
||||||
'</p>'.
|
'</span>'.
|
||||||
'<ul class="releases">';
|
'<span class="releases" role="list">';
|
||||||
|
|
||||||
foreach($releases as $release) {
|
foreach($releases as $release) {
|
||||||
$out .=
|
$out .=
|
||||||
'<li>'.
|
'<span class="release">'.
|
||||||
'<a href="'.$release->_links->self.'">'.$release->name.'</a>'.
|
'<a href="'.$release->_links->self.'">'.$release->name.'</a>'.
|
||||||
'</li>';
|
'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= '</ul>';
|
$out .= '</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ class LinuxfooGitlab {
|
|||||||
static function show_project($atts, $content, $tag) {
|
static function show_project($atts, $content, $tag) {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
$out = '<div class="linuxfoo_gitlab">';
|
$out = '<span class="linuxfoo_gitlab">';
|
||||||
|
|
||||||
if(
|
if(
|
||||||
is_null($atts['url']) ||
|
is_null($atts['url']) ||
|
||||||
@ -255,19 +255,14 @@ class LinuxfooGitlab {
|
|||||||
$out .= self::error('Project information not readable.');
|
$out .= self::error('Project information not readable.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$out .=
|
$out .= self::project_header($atts, $project);
|
||||||
'<span class="project_header">'.
|
|
||||||
__('Gitlab project', 'linuxfoo-gitlab').' '.
|
|
||||||
'<a href="'.$project->web_url.'">'.$project->name.'</a>'.
|
|
||||||
'</span>';
|
|
||||||
|
|
||||||
$out .= self::commits_list($atts, $project_url);
|
$out .= self::commits_list($atts, $project_url);
|
||||||
$out .= self::releases_list($atts, $project_url);
|
$out .= self::releases_list($atts, $project_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= '</div>';
|
$out .= '</span>';
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
10
styles.css
10
styles.css
@ -1,13 +1,17 @@
|
|||||||
.linuxfoo_gitlab {
|
.linuxfoo_gitlab {
|
||||||
|
display: block;
|
||||||
border: 1px dashed #8a8a8a;
|
border: 1px dashed #8a8a8a;
|
||||||
border-radius: .5em;
|
border-radius: .5em;
|
||||||
padding: .25em .5em;
|
padding: .25em .5em;
|
||||||
}
|
}
|
||||||
.linuxfoo_gitlab .commits {
|
.linuxfoo_gitlab .commits, .linuxfoo_gitlab .releases {
|
||||||
|
display: block;
|
||||||
margin: .25em 0 .25em 0;
|
margin: .25em 0 .25em 0;
|
||||||
}
|
}
|
||||||
.linuxfoo_gitlab .releases {
|
.linuxfoo_gitlab .commit, .linuxfoo_gitlab .release {
|
||||||
margin: .25em 0 .25em 0;
|
display: list-item;
|
||||||
|
list-style-type: square;
|
||||||
|
margin: 0 0 0 1em;
|
||||||
}
|
}
|
||||||
.linuxfoo_gitlab .project_header {
|
.linuxfoo_gitlab .project_header {
|
||||||
display: block;
|
display: block;
|
||||||
|
Loading…
Reference in New Issue
Block a user