diff --git a/doc/data/users.toml b/doc/data/users.toml index 9f246c4..b54d8d6 100644 --- a/doc/data/users.toml +++ b/doc/data/users.toml @@ -167,6 +167,12 @@ org_dir = "content-org" site = "https://numbersandshapes.net/blog/" +[kengrimes] + author = "Ken Grimes" + source = "https://www.kengrimes.com/gitweb/?p=kengrimes.com/content.git" + branch = "master" + site = "https://www.kengrimes.com/" + # [] # author = "" # source = "" diff --git a/doc/layouts/_default/examples.html b/doc/layouts/_default/examples.html index 53c7104..b8544ff 100644 --- a/doc/layouts/_default/examples.html +++ b/doc/layouts/_default/examples.html @@ -26,11 +26,13 @@ {{ range $key, $val := . }} {{ $branch := $val.branch | default "master" }} {{ $.Scratch.Set "__repo_updated_time" "" }} - {{ if (findRE "github\\.com" $val.source) }} + {{ $github_source := findRE "github\\.com" $val.source }} + {{ $gitlab_source := findRE "gitlab\\.com" $val.source }} + {{ if $github_source }} {{ $repo := replaceRE "^.*github\\.com/([^/]+/[^/]+).*" "${1}" $val.source }} {{ $repo_json := getJSON (printf "https://api.github.com/repos/%s/branches/%s" $repo $branch) }} {{ $.Scratch.Set "__repo_updated_time" (index (index (index (index $repo_json "commit") "commit") "committer") "date") }} - {{ else if (findRE "gitlab\\.com" $val.source) }} + {{ else if $gitlab_source }} {{ $repo := replaceRE "^.*gitlab\\.com/([^/]+/[^/]+).*" "${1}" $val.source }} {{ $repo_json := getJSON (printf "https://gitlab.com/api/v4/projects/%s/repository/branches/%s" ($repo | replaceRE "/" "%2F") $branch) }} {{ $.Scratch.Set "__repo_updated_time" (index (index $repo_json "commit") "committed_date") }} @@ -39,8 +41,16 @@ {{ $org_dir := $val.org_dir | default "" | replaceRE "/$" "" }} {{ if (findRE "\\.org$" $val.source) }} {{ $.Scratch.Set "__org_src" $val.source }} - {{ else }} + {{ else if (or $github_source $gitlab_source) }} {{ $.Scratch.Set "__org_src" (printf "%s/tree/%s/%s" ($val.source | replaceRE "/$" "") $branch $org_dir) }} + {{ else }} + + {{ $folder_switch := (cond (eq "" $org_dir) "" (printf ";f=%s" $org_dir)) }} + {{ $.Scratch.Set "__org_src" (printf "%s;a=tree%s;hb=refs/heads/%s" ($val.source | replaceRE "/$" "") $folder_switch $branch) }} {{ end }} {{ $val.author }}