diff --git a/Dockerfile b/Dockerfile index a98f147..63b38ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM caddy:builder-alpine AS builder -RUN xcaddy build --with github.com/simongregorebner/gitea-pages@v0.0.5 +RUN xcaddy build --with github.com/simongregorebner/gitea-pages@v0.0.6 FROM alpine diff --git a/Readme.md b/Readme.md index 80a3b44..7b47cac 100644 --- a/Readme.md +++ b/Readme.md @@ -89,7 +89,8 @@ log { | server | The URL of your Gitea server. | | token | Your access token for the Gitea API. This token is used to authenticate requests made to the Gitea server.| | pages_branch | The branch in your repository that contains the static files for your website or documentation. By default, this would be the branch "gitea-pages" | -| postfix_pages_repository | The (domain) postfix used for the pages repository. (This could be the domain where your site will be accessible, such as "gitea.io".) | +| pages_repository | The default repository of an organization | +| postfix_pages_repository | The (domain) postfix used for the pages repository. __This setting is only used if pages_repository is not set!__ (This could be the domain where your site will be accessible, such as "gitea.io".) | | url_scheme | The URL scheme to use for the pages. "simple" or "classic | diff --git a/giteapages.go b/giteapages.go index 79e98af..10406ec 100644 --- a/giteapages.go +++ b/giteapages.go @@ -34,6 +34,7 @@ type GiteaPagesModule struct { Server string `json:"server,omitempty"` Token string `json:"token,omitempty"` PagesBranch string `json:"pages_branch,omitempty"` + PagesRepository string `json:"pages_repository,omitempty"` PostfixPagesRepository string `json:"postfix_pages_repository,omitempty"` URLScheme string `json:"url_scheme,omitempty"` } @@ -65,6 +66,8 @@ func (module *GiteaPagesModule) UnmarshalCaddyfile(d *caddyfile.Dispenser) error d.Args(&module.Token) case "pages_branch": d.Args(&module.PagesBranch) + case "pages_repository": + d.Args(&module.PagesBranch) case "postfix_pages_repository": d.Args(&module.PostfixPagesRepository) case "url_scheme": @@ -76,8 +79,10 @@ func (module *GiteaPagesModule) UnmarshalCaddyfile(d *caddyfile.Dispenser) error if module.PagesBranch == "" { module.PagesBranch = "gitea-pages" } - if module.PostfixPagesRepository == "" { - module.PostfixPagesRepository = "gitea-pages" + if module.PagesRepository == "" { + if module.PostfixPagesRepository == "" { + module.PostfixPagesRepository = "gitea-pages" + } } if module.URLScheme == "" { @@ -131,9 +136,13 @@ func (module GiteaPagesModule) ServeHTTP(writer http.ResponseWriter, request *ht // Case http(s)://.[:] // (Try to) Use of the pages repository in the specified organization - // We use github.com conventions: .github.io - // repository = organization + "." + module.PostfixPagesRepository - repository = module.PostfixPagesRepository + // Determine name of the default repository for organization based on settings + if module.PagesRepository != "" { + repository = module.PagesRepository + } else { + // We use github.com conventions: .github.io + repository = organization + "." + module.PostfixPagesRepository + } path = "index.html" } else { @@ -153,9 +162,13 @@ func (module GiteaPagesModule) ServeHTTP(writer http.ResponseWriter, request *ht } } else { // (Try to) Use of the pages repository in the specified organization - // We use github.com conventions: .github.io - // repository = organization + "." + module.PostfixPagesRepository - repository = module.PostfixPagesRepository + // Determine name of the default repository for organization based on settings + if module.PagesRepository != "" { + repository = module.PagesRepository + } else { + // We use github.com conventions: .github.io + repository = organization + "." + module.PostfixPagesRepository + } path = strings.Join(parts[0:], "/") } }