diff --git a/app/com/gitpitch/git/vendors/Gitea.java b/app/com/gitpitch/git/vendors/Gitea.java index 79a1554..501bd2b 100644 --- a/app/com/gitpitch/git/vendors/Gitea.java +++ b/app/com/gitpitch/git/vendors/Gitea.java @@ -78,5 +78,5 @@ public class Gitea extends GRSService { public static final String TYPE = "gitea"; private static final String GITEA_REPO_API = "repos/"; - private static final String GITEA_RAW = "/raw/"; + private static final String GITEA_RAW = "/raw/branch/"; } diff --git a/app/com/gitpitch/utils/GitRepoRenderer.java b/app/com/gitpitch/utils/GitRepoRenderer.java index 89cbe8c..b039495 100644 --- a/app/com/gitpitch/utils/GitRepoRenderer.java +++ b/app/com/gitpitch/utils/GitRepoRenderer.java @@ -334,25 +334,54 @@ public class GitRepoRenderer { * Return https://{grs}/{user}/{repo}/tree/{branch} */ public String branchHub(PitchParams pp) { - if(GRS_BITBUCKET.equals(pp.grs)) - return "#"; - else - return _repoHub + GIT_TREE + pp.branch; + + String branchHub = "#"; + + switch(pp.grs) { + case GRS_GITHUB: + case GRS_GITLAB: + case GRS_GITBUCKET: + branchHub = _repoHub + GIT_TREE + pp.branch; + break; + case GRS_BITBUCKET: + branchHub = _repoHub + GIT_SRC + pp.branch; + break; + case GRS_GITEA: + branchHub = _repoHub + GIT_SRC_BRANCH + pp.branch; + break; + case GRS_GOGS: + branchHub = _repoHub + GIT_SRC + pp.branch; + break; + } + return branchHub; } /* * Return https://{grs}/{user}/{repo}/blob/{branch}/{pitchme} */ public String pitchHub(PitchParams pp) { - if(GRS_BITBUCKET.equals(pp.grs)) { - return "#"; - } else { - if(pp.pitchme != null) - return _repoHub + GIT_BLOB + pp.branch + "/" + pp.pitchme + DEFAULT_PITCHME; - else - return _repoHub + GIT_BLOB + pp.branch + DEFAULT_PITCHME; - } + String pitchPath = + (pp.pitchme != null) ? (pp.branch + SLASH + pp.pitchme) : pp.branch; + String pitchHub = "#"; + + switch(pp.grs) { + case GRS_GITHUB: + case GRS_GITLAB: + case GRS_GITBUCKET: + pitchHub = _repoHub + GIT_BLOB + pitchPath + DEFAULT_PITCHME; + break; + case GRS_BITBUCKET: + pitchHub = _repoHub + GIT_SRC + pitchPath + DEFAULT_PITCHME; + break; + case GRS_GITEA: + pitchHub = _repoHub + GIT_SRC_BRANCH + pitchPath + DEFAULT_PITCHME; + break; + case GRS_GOGS: + pitchHub = _repoHub + GIT_SRC + pitchPath + DEFAULT_PITCHME; + break; + } + return pitchHub; } /* @@ -615,6 +644,8 @@ public class GitRepoRenderer { private static final String GIT_MASTER = "master"; private static final String GIT_TREE = "/tree/"; private static final String GIT_BLOB = "/blob/"; + private static final String GIT_SRC = "/src/"; + private static final String GIT_SRC_BRANCH = "/src/branch/"; private static final String CSS = ".css"; private static final String MARKDOWN = "/pitchme/markdown/"; private static final String SLASH = "/"; @@ -651,7 +682,12 @@ public class GitRepoRenderer { private static final String GIT_DEFAULT_ICON = ""; + private static final String GRS_GITHUB = "github"; + private static final String GRS_GITLAB = "gitlab"; private static final String GRS_BITBUCKET = "bitbucket"; + private static final String GRS_GITBUCKET = "gitbucket"; + private static final String GRS_GITEA = "gitea"; + private static final String GRS_GOGS = "gogs"; private static final String AS_DESCR = "Markdown Presentation powered by GitPitch."; diff --git a/conf/application.conf b/conf/application.conf index b3d0328..97ec565 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -465,7 +465,6 @@ gitpitch { type = "gitea" site = "https://localhost:3000/" apibase = "http://localhost:3000/api/v1/" - apibase = "https://try.gitea.io/api/v1/" // apitoken = "token your-gitea-app-token-here" apitokenheader = "Authorization" rawbase = "http://localhost:3000/" @@ -480,7 +479,6 @@ gitpitch { apitoken = "token your-gitea-app-token-here" apitokenheader = "Authorization" rawbase = "http://localhost:3000/" - rawbase = "https://try.gogs.io/" branchdelim = "~" default = "false" }