From 242789f6d2073264c9f0b2699e1869a7ef42e180 Mon Sep 17 00:00:00 2001 From: DioDuPiMa Date: Wed, 29 Mar 2023 19:54:43 +0100 Subject: [PATCH 1/4] [add] PoC implementation of gitlab shortcut --- layouts/shortcodes/gitlab.html | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 layouts/shortcodes/gitlab.html diff --git a/layouts/shortcodes/gitlab.html b/layouts/shortcodes/gitlab.html new file mode 100644 index 00000000..196727db --- /dev/null +++ b/layouts/shortcodes/gitlab.html @@ -0,0 +1,40 @@ +{{- $githubData := getJSON (print "https://gitlab.com/api/v4/projects/" (.Get "repo_id")) -}} +{{- $githubColors := .Site.Data.githubColors -}} +{{- with $githubData -}} + + +
+ +
+ + {{ partial "icon.html" "gitlab" }} + +
+ {{ .name_with_namespace | markdownify | emojify }} +
+
+ +

+ {{ .description | markdownify | emojify }} +

+ +
+ + {{ partial "icon.html" "star" }} + +
+ {{ .star_count }} +
+ + + {{ partial "icon.html" "fork" }} + +
+ {{ .forks_count }} +
+ +
+ +
+
+{{- end -}} From 3d9978c225bf15eeba98f4c97758869b22d03537 Mon Sep 17 00:00:00 2001 From: Diogo Macedo <43378713+DiogoM1@users.noreply.github.com> Date: Wed, 29 Mar 2023 22:32:46 +0100 Subject: [PATCH 2/4] [FIX] Replace github naming --- layouts/shortcodes/gitlab.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/layouts/shortcodes/gitlab.html b/layouts/shortcodes/gitlab.html index 196727db..4364ce86 100644 --- a/layouts/shortcodes/gitlab.html +++ b/layouts/shortcodes/gitlab.html @@ -1,6 +1,5 @@ -{{- $githubData := getJSON (print "https://gitlab.com/api/v4/projects/" (.Get "repo_id")) -}} -{{- $githubColors := .Site.Data.githubColors -}} -{{- with $githubData -}} +{{- $gitlabData := getJSON (print "https://gitlab.com/api/v4/projects/" (.Get "repo_id")) -}} +{{- with $gitlabData -}}
From c1aca647c7f1013b68d28308f01cb7d76931133c Mon Sep 17 00:00:00 2001 From: DioDuPiMa Date: Wed, 5 Apr 2023 00:47:46 +0100 Subject: [PATCH 3/4] [ADD] Base URL option for short code and an appropriate default for gitlab's public instance --- layouts/shortcodes/gitlab.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/gitlab.html b/layouts/shortcodes/gitlab.html index 4364ce86..ce210dac 100644 --- a/layouts/shortcodes/gitlab.html +++ b/layouts/shortcodes/gitlab.html @@ -1,5 +1,5 @@ -{{- $gitlabData := getJSON (print "https://gitlab.com/api/v4/projects/" (.Get "repo_id")) -}} -{{- with $gitlabData -}} +{{- $gitLabData := getJSON (print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID")) -}} +{{- with $gitLabData -}}
From d335c7dc714590117c1fcfd50dd31789bc22f2ef Mon Sep 17 00:00:00 2001 From: DioDuPiMa Date: Wed, 5 Apr 2023 01:02:03 +0100 Subject: [PATCH 4/4] [ADD] Gitlab shortcut documentation --- exampleSite/content/docs/shortcodes/index.md | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md index d005a16e..9199925a 100644 --- a/exampleSite/content/docs/shortcodes/index.md +++ b/exampleSite/content/docs/shortcodes/index.md @@ -296,7 +296,7 @@ In order to add images to the gallery, use `img` tags for each image and add `cl | Parameter | Description | -| --------- | ----------------------------------------------------- | +|-----------|-------------------------------------------------------| | `repo` | [String] github repo in the format of `username/repo` | @@ -310,6 +310,30 @@ In order to add images to the gallery, use `img` tags for each image and add `cl


+## GitLab Card + +`gitlab` allows you to quickly link a GitLab Project (GitLab's jargon for repo). +It displays realtime stats about it, such as the number of stars and forks it has. +Unlike `github` it can't display the main programming language of a project. +Finaly custom GitLab instace URL can be provided, as long as the `api/v4/projects/` endpoint is available, making this shortcode compatible with most self-hosted / entreprise deployments. + + +| Parameter | Description | +|-------------|------------------------------------------------------------------------| +| `projectID` | [String] gitlab numeric ProjectID | +| `baseURL` | [String] optional gitlab instace URL, default is `https://gitlab.com/` | + + +**Example 1:** + +```md +{{}} +``` + +{{< gitlab projectID="278964" >}} + +


+ ## Icon `icon` outputs an SVG icon and takes the icon name as its only parameter. The icon is scaled to match the current text size.