Skip to content

Commit

Permalink
Add basic support for Gitea Swagger v1
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Sep 4, 2018
1 parent 28ad81c commit 2179e50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/data/users.toml
Expand Up @@ -318,9 +318,10 @@

[flowsta]
author = "Adolfo Antón Bravo"
source = "https://git.fsfe.org/adolflow/infotics.es/src/branch/master/articulos-infotics.org"
source = "https://git.fsfe.org/adolflow/infotics.es"
branch = "master"
site = "https://infotics.es"
org_src_desc = "Org file"
hosting = "gitea"

# []
# author = ""
Expand Down
11 changes: 11 additions & 0 deletions doc/layouts/_default/examples.html
Expand Up @@ -38,6 +38,7 @@ <h1>{{ .Title }}</h1>
{{ $github_source := findRE "github\\.com" $val.source }}
{{ $gitlab_source := findRE "gitlab\\.com" $val.source }}
{{ $codingnet_source := findRE "coding\\.net" $val.source }}
{{ $gitea_source := (and $val.hosting (eq "gitea" $val.hosting)) }} <!-- Gitea Swagger v1 -->
{{ if $github_source }}
{{ $repo := replaceRE "^.*github\\.com/([^/]+/[^/]+).*" "${1}" $val.source }}
<!-- https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -->
Expand All @@ -52,12 +53,22 @@ <h1>{{ .Title }}</h1>
{{ $repo_json := getJSON (printf "https://gitlab.com/api/v4/projects/%s/repository/commits?path=%s&?ref_name=%s" $repo ($org_dir | replaceRE "/" "%2F") $branch) }}
{{/* partial "debugprint.html" $repo_json */}}
{{ $repo_updated_time = (index (index $repo_json 0) "committed_date") }}
{{ else if $gitea_source }}
{{ $repo := replaceRE "^.*//[^/]+/([^/]+/[^/]+).*" "${1}" $val.source }}
{{ $api_url := printf "%s/api/v1" (replaceRE "^(.*//[^/]+)/.+" "${1}" $val.source) }}
<!-- https://try.gitea.io/api/swagger#/repository/repoGet -->
<!-- https://git.fsfe.org/api/v1/repos/adolflow/infotics.es -->
{{ $repo_json := getJSON (printf "%s/repos/%s" $api_url $repo) }}
{{/* partial "debugprint.html" $repo_json */}}
{{ $repo_updated_time = index $repo_json "updated_at" }}
{{ end }}
{{ $org_dir_link := "" }}
{{ if (findRE "\\.org$" $val.source) }} <!-- If the "source" is direct link to an Org file -->
{{ $org_dir_link = $val.source }}
{{ else if (or $github_source $gitlab_source $codingnet_source) }}
{{ $org_dir_link = (printf "%s/tree/%s/%s" ($val.source | replaceRE "/$" "") $branch $org_dir) }}
{{ else if $gitea_source }}
{{ $org_dir_link = (printf "%s/src/branch/%s/%s" ($val.source | replaceRE "/$" "") $branch $org_dir) }}
{{ else }}
<!-- Example: https://www.kengrimes.com/gitweb/?p=kengrimes.com/content.git;a=tree;f=content;hb=refs/heads/master
$val.source = https://www.kengrimes.com/gitweb/?p=kengrimes.com/content.git
Expand Down

0 comments on commit 2179e50

Please sign in to comment.