Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom redirect for landing page #19324

Merged
merged 5 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,13 @@ RUN_MODE = ; prod
;; PPROF_DATA_PATH, use an absolute path when you start gitea as service
;PPROF_DATA_PATH = data/tmp/pprof
;;
;; Landing page, can be "home", "explore", "organizations" or "login"
;; Landing page, can be "home", "explore", "organizations", "login", or "custom"
;; The "login" choice is not a security measure but just a UI flow change, use REQUIRE_SIGNIN_VIEW to force users to log in.
;LANDING_PAGE = home
techknowlogick marked this conversation as resolved.
Show resolved Hide resolved
;;
;; URL for landing page redirect if `LANDING_PAGE` is set to `custom`
;LANDING_PAGE_CUSTOM =
;;
;; Enables git-lfs support. true or false, default is false.
;LFS_START_SERVER = false
;;
Expand Down
3 changes: 2 additions & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ The following configuration set `Content-Type: application/vnd.android.package-a
- `ENABLE_GZIP`: **false**: Enable gzip compression for runtime-generated content, static resources excluded.
- `ENABLE_PPROF`: **false**: Application profiling (memory and cpu). For "web" command it listens on localhost:6060. For "serv" command it dumps to disk at `PPROF_DATA_PATH` as `(cpuprofile|memprofile)_<username>_<temporary id>`
- `PPROF_DATA_PATH`: **data/tmp/pprof**: `PPROF_DATA_PATH`, use an absolute path when you start Gitea as service
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login\].
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login, custom\].
- `LANDING_PAGE_CUSTOM`: ****: If `LANDING_PAGE` is set to `custom`, this is the URL for the custom landing page redirect.

- `LFS_START_SERVER`: **false**: Enables Git LFS support.
- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)/lfs**: Default LFS content path. (if it is on local storage.) **DEPRECATED** use settings in `[lfs]`.
Expand Down
9 changes: 7 additions & 2 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var (
StaticCacheTime time.Duration
EnableGzip bool
LandingPageURL LandingPage
LandingPageCustom string
UnixSocketPermission uint32
EnablePprof bool
PprofDataPath string
Expand Down Expand Up @@ -776,15 +777,19 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
}

LandingPageURL = LandingPageHome
switch sec.Key("LANDING_PAGE").MustString("home") {
case "explore":
LandingPageURL = LandingPageExplore
case "organizations":
LandingPageURL = LandingPageOrganizations
case "login":
LandingPageURL = LandingPageLogin
default:
LandingPageURL = LandingPageHome
case "custom":
customUrl := LandingPage(sec.Key("LANDING_PAGE_CUSTOM").MustString(""))
if customUrl != "" {
LandingPageURL = customUrl
techknowlogick marked this conversation as resolved.
Show resolved Hide resolved
}
}

if len(SSH.Domain) == 0 {
Expand Down