base.go (1708B)
1 // GoToSocial 2 // Copyright (C) GoToSocial Authors admin@gotosocial.org 3 // SPDX-License-Identifier: AGPL-3.0-or-later 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package web 19 20 import ( 21 "net/http" 22 "strings" 23 24 "github.com/gin-gonic/gin" 25 apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" 26 "github.com/superseriousbusiness/gotosocial/internal/config" 27 "github.com/superseriousbusiness/gotosocial/internal/gtserror" 28 ) 29 30 func (m *Module) baseHandler(c *gin.Context) { 31 // if a landingPageUser is set in the config, redirect to that user's profile 32 if landingPageUser := config.GetLandingPageUser(); landingPageUser != "" { 33 c.Redirect(http.StatusFound, "/@"+strings.ToLower(landingPageUser)) 34 return 35 } 36 37 instance, err := m.processor.InstanceGetV1(c.Request.Context()) 38 if err != nil { 39 apiutil.WebErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) 40 return 41 } 42 43 c.HTML(http.StatusOK, "index.tmpl", gin.H{ 44 "instance": instance, 45 "ogMeta": ogBase(instance), 46 "stylesheets": []string{ 47 distPathPrefix + "/index.css", 48 }, 49 }) 50 }