diff --git a/.gitignore b/.gitignore index a23b892..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -lang/*.mo diff --git a/lang/linuxfoo-gitlab-de_DE.mo b/lang/linuxfoo-gitlab-de_DE.mo new file mode 100644 index 0000000..0f91cfe Binary files /dev/null and b/lang/linuxfoo-gitlab-de_DE.mo differ diff --git a/lang/linuxfoo-gitlab-de_DE.po b/lang/linuxfoo-gitlab-de_DE.po index 200b3a2..9d39fe0 100644 --- a/lang/linuxfoo-gitlab-de_DE.po +++ b/lang/linuxfoo-gitlab-de_DE.po @@ -22,8 +22,8 @@ msgid "http://tk-sls.de/ref/gitlab-list-commits" msgstr "http://tk-sls.de/ref/gitlab-list-commits" #. 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 since=\"3 month\" max=5] for a list of at most 5 commits to that project that were made since at most 3 months ago." -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]" +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\"." +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\"." #. Author of the plugin msgid "Tilman Kranz" diff --git a/linuxfoo-gitlab.php b/linuxfoo-gitlab.php index db9beee..85b603c 100644 --- a/linuxfoo-gitlab.php +++ b/linuxfoo-gitlab.php @@ -47,6 +47,43 @@ class LinuxfooGitlab { return sprintf(__('since %d %s ago', 'linuxfoo-gitlab'), $num, $unit); } + static function format_commit($atts, $commit) { + $out = ''; + + preg_match('/^....-..-../', $commit->committed_date, $m); + $date = $m[0]; + + $title = htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE); + + $out .= + $date.' '. + __('by', 'linuxfoo-gitlab').' '.$commit->author_name. + ': '. + ''.$commit->short_id.' '.$title; + + return $out; + } + + static function format_commit_stats($atts, $commits_count, $branch) { + $out = ''; + + if($commits_count==0) { + $out .= + __('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 */ + sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count). + (is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"'). + (is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':'; + } + + return $out; + } + static function commits_list($atts, $project_url) { $since = null; @@ -99,37 +136,18 @@ class LinuxfooGitlab { else { $commits_count = count($commits); $commits_count = is_null($atts['max']) ? $commits_count : min($commits_count, $atts['max']); - $commits = array_slice($commits, 0, $commits_count); - if($commits_count==0) { - $out .= - ''. - __('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 */ - sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count). - (is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"'). - (is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':'. - ''. - '