diff --git a/README.md b/README.md index 6edc4b5..6614b18 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,33 @@ Add the following shortcode for a list of at most 5 commits to that project that Add the following shortcode for a list of at most 3 commits followed by a link to the latest release: ``` -[gitlab-show-project url="https://tk-sls.de/gitlab" project_id=42 max=3 release="latest"] +[gitlab-show-project url="https://tk-sls.de/gitlab" project_id=42 max=3 releases="latest"] +``` + +Add the following shortcode to just link to the Gitlab project, without a list of commits or releases: + +``` +[gitlab-show-project url="https://tk-sls.de/gitlab" project_id=42 commit="none" releases="none"] ``` ### Attributes -* `url="STRING"`: Mandatory (example: `https://tk-sls.de/gitlab`). -* `project_id=NUM`: Mandatory; `NUM`: Positive Integer, valid project ID in Gitlab specified by `url` (example: `42`). +The following attributes are mandatory: + +* `url="STRING"`: Base URL of Gitlab instance (example: `https://tk-sls.de/gitlab`). +* `project_id=NUM`: ; `NUM`: Positive Integer, valid project ID in Gitlab specified by `url` (example: `42`). + +The following optional attributes enable or disable additional project information: + +* `commits="STRING"`: Optional; if set, `STRING` can be either `all` (show a list of recent commits, the default) or `none` (do not show a list of recent commits). +* `releases=STRING`: Optional; if set, `STRING` can be either `all` (show a list of all releases of this project, if any) or `latest` (show a link to the latest release of this project, if any) or `none` (do not show releases of this project, the default). + +The following optional attributes modify the behavior of the list of commits: + * `since="NUM UNIT"`: Optional; `NUM`: Positive integer; `UNIT`: `days`, `months`, `years`; exclude commits older than specified time interval (example: `3 months`). * `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`). * `default_branch`: Optional; if set, list only commits from the project's default branch. -* `release=STRING`: Optional; if set, `STRING` can be either `all` (show a list of all releases of this project) or `latest` (show a link to the latest release of this project, if any). ## Author and License diff --git a/lang/linuxfoo-gitlab-de_DE.po b/lang/linuxfoo-gitlab-de_DE.po index 524b928..200b3a2 100644 --- a/lang/linuxfoo-gitlab-de_DE.po +++ b/lang/linuxfoo-gitlab-de_DE.po @@ -50,6 +50,10 @@ msgstr "Jahren" msgid "since %d %s ago" msgstr "seit %d %s" +#: linuxfoo-gitlab.php:57 +msgid "Invalid value for parameter \"commits\"." +msgstr "Unzulässiger Wert für Parameter \"commits\"." + #: linuxfoo-gitlab.php:59 msgid "Required parameter missing." msgstr "Notwendiger Parameter fehlt" diff --git a/lang/linuxfoo-gitlab.pot b/lang/linuxfoo-gitlab.pot index 13f8001..810ea64 100644 --- a/lang/linuxfoo-gitlab.pot +++ b/lang/linuxfoo-gitlab.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2021-11-27T16:45:29+01:00\n" +"POT-Creation-Date: 2021-11-27T19:40:19+01:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.5.0\n" "X-Domain: linuxfoo-gitlab\n" @@ -23,7 +23,7 @@ msgid "http://tk-sls.de/ref/gitlab-list-commits" msgstr "" #. 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." +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 "" #. Author of the plugin @@ -34,90 +34,94 @@ msgstr "" msgid "https://tk-sls.de" msgstr "" -#: linuxfoo-gitlab.php:39 +#: linuxfoo-gitlab.php:37 msgid "days" msgstr "" -#: linuxfoo-gitlab.php:42 +#: linuxfoo-gitlab.php:40 msgid "months" msgstr "" -#: linuxfoo-gitlab.php:45 +#: linuxfoo-gitlab.php:43 msgid "years" msgstr "" #. translators: %d: count, %s unit of time interval -#: linuxfoo-gitlab.php:49 +#: linuxfoo-gitlab.php:47 msgid "since %d %s ago" msgstr "" -#: linuxfoo-gitlab.php:63 -msgid "Required parameter missing." +#: linuxfoo-gitlab.php:57 +msgid "Invalid value for parameter \"commits\"." msgstr "" -#: linuxfoo-gitlab.php:66 -#: linuxfoo-gitlab.php:72 -msgid "Invalid value for parameter \"project_id\"." -msgstr "" - -#: linuxfoo-gitlab.php:69 -msgid "Invalid value for parameter \"url\"." -msgstr "" - -#: linuxfoo-gitlab.php:79 -msgid "Project URL not reachable." -msgstr "" - -#: linuxfoo-gitlab.php:90 -msgid "Gitlab project" -msgstr "" - -#: linuxfoo-gitlab.php:97 +#: linuxfoo-gitlab.php:61 msgid "Invalid value for parameter \"since\"." msgstr "" -#: linuxfoo-gitlab.php:119 +#: linuxfoo-gitlab.php:91 msgid "Commits URL not reachable." msgstr "" -#: linuxfoo-gitlab.php:125 +#: linuxfoo-gitlab.php:97 msgid "Commits information not readable." msgstr "" -#: linuxfoo-gitlab.php:136 +#: linuxfoo-gitlab.php:108 msgid "No commits" msgstr "" -#: linuxfoo-gitlab.php:137 -#: linuxfoo-gitlab.php:151 +#: linuxfoo-gitlab.php:109 +#: linuxfoo-gitlab.php:118 msgid "in branch" msgstr "" #. translators: %d: maximum number of commits displayed -#: linuxfoo-gitlab.php:150 +#: linuxfoo-gitlab.php:117 msgid "Last %d commits" msgstr "" -#: linuxfoo-gitlab.php:172 +#: linuxfoo-gitlab.php:150 msgid "Invalid value for parameter \"releases\"." msgstr "" -#: linuxfoo-gitlab.php:179 +#: linuxfoo-gitlab.php:157 msgid "Releases URL not reachable." msgstr "" -#: linuxfoo-gitlab.php:185 +#: linuxfoo-gitlab.php:163 msgid "Releases information not readable." msgstr "" -#: linuxfoo-gitlab.php:189 +#: linuxfoo-gitlab.php:169 msgid "This project has currently no releases." msgstr "" -#: linuxfoo-gitlab.php:194 +#: linuxfoo-gitlab.php:175 msgid "Latest release" msgstr "" -#: linuxfoo-gitlab.php:201 +#: linuxfoo-gitlab.php:182 msgid "Releases" msgstr "" + +#: linuxfoo-gitlab.php:215 +msgid "Required parameter missing." +msgstr "" + +#: linuxfoo-gitlab.php:218 +#: linuxfoo-gitlab.php:224 +msgid "Invalid value for parameter \"project_id\"." +msgstr "" + +#: linuxfoo-gitlab.php:221 +msgid "Invalid value for parameter \"url\"." +msgstr "" + +#: linuxfoo-gitlab.php:231 +msgid "Project URL not reachable." +msgstr "" + +#: linuxfoo-gitlab.php:242 +msgid "Gitlab project" +msgstr "" diff --git a/linuxfoo-gitlab.php b/linuxfoo-gitlab.php index 0e6f1b9..db9beee 100644 --- a/linuxfoo-gitlab.php +++ b/linuxfoo-gitlab.php @@ -3,9 +3,9 @@ /* 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 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. +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". Author: Tilman Kranz -Version: 1.2 +Version: 1.4 Author URI: https://tk-sls.de */ @@ -18,16 +18,14 @@ class LinuxfooGitlab { } static function css() { - wp_enqueue_style('linuxfoo_gitlab_css', plugins_url('styles.css', __FILE__ ), '', '1.2' ); + wp_enqueue_style('linuxfoo_gitlab_css', plugins_url('styles.css', __FILE__ ), '', '1.4' ); } static function error ( $msg ) { return - '
'.__('This project has currently no releases.', 'linuxfoo-gitlab').'
'; - } - elseif($atts['releases']=='latest') { - $out .= - ''. - __('Latest release', 'linuxfoo-gitlab').': '. - ''.$releases[0]->name.''. - '
'; - } - elseif($atts['releases']=='all') { - $out .= - ''. - __('Releases', 'linuxfoo-gitlab').': '. - '
'. - ''. + __('This project has currently no releases.', 'linuxfoo-gitlab'). + '
'; + } + elseif($atts['releases']=='latest') { + $out .= + ''. + __('Latest release', 'linuxfoo-gitlab').': '. + ''.$releases[0]->name.''. + '
'; + } + elseif($atts['releases']=='all') { + $out .= + ''. + __('Releases', 'linuxfoo-gitlab').': '. + '
'. + '