M core/routes.go => core/routes.go +12 -0
@@ 37,6 37,7 @@ type Service struct {
// RegisterRoutes ...
func (s *Service) RegisterRoutes() {
s.eg.GET("/", s.Homepage).Name = "index"
+ s.eg.GET("/inactive", s.InactiveDomain).Name = s.RouteName("inactive_domain")
s.eg.GET("/:slug", s.OrgLinksList).Name = s.RouteName("org_link_list")
s.eg.GET("/recent", s.OrgLinksList).Name = s.RouteName("recent_link_list")
s.eg.GET("/popular", s.PopularLinkList).Name = s.RouteName("popular_link_list")
@@ 90,6 91,17 @@ func (s *Service) RegisterRoutes() {
s.eg.GET("/tag-autocomplete", s.TagAutocomplete).Name = s.RouteName("tag_autocomplete")
}
+func (s *Service) InactiveDomain(c echo.Context) error {
+ gctx := c.(*server.Context)
+ lt := localizer.GetSessionLocalizer(c)
+ pd := localizer.NewPageData(lt.Translate("Inactive Domain"))
+ pd.Data["msg"] = lt.Translate("The domain is inactive")
+ pd.Data["please_upgrade"] = lt.Translate("Please upgrade your account to reactivate it")
+ slug := links.PullOrgSlug(c)
+ gMap := gobwebs.Map{"pd": pd, "slug": slug}
+ return gctx.Render(http.StatusOK, "inactive_domain.html", gMap)
+}
+
func (s *Service) Homepage(c echo.Context) error {
// If user custom domain, don't parse homepage. Just show the assigned
// org public list
M domain/middleware.go => domain/middleware.go +1 -6
@@ 4,14 4,12 @@ import (
"context"
"errors"
"fmt"
- "links/internal/localizer"
"links/models"
"net/http"
"net/url"
"strings"
"github.com/labstack/echo/v4"
- "netlandish.com/x/gobwebs/messages"
"netlandish.com/x/gobwebs/server"
)
@@ 44,11 42,8 @@ func badDomainRedirect(c echo.Context) error {
nextURL := &url.URL{
Scheme: gctx.Server.Config.Scheme,
Host: mainDomain,
+ Path: c.Echo().Reverse("core:inactive_domain"),
}
- lt := localizer.GetSessionLocalizer(c)
- // XXX This needs to change. See: https://todo.code.netlandish.com/~netlandish/links/48
- messages.Error(
- c, lt.Translate("The domain is currently inactive. Please subscribe to activate this domain"))
return c.Redirect(http.StatusMovedPermanently, nextURL.String())
}
A templates/inactive_domain.html => templates/inactive_domain.html +9 -0
@@ 0,0 1,9 @@
+{{template "base" .}}
+<section class="app-header">
+ <h1 class="app-header__title">{{.pd.Title}}</h1>
+</section>
+<section class="card shadow-card">
+ <p class="text-center">{{.pd.Data.msg}}</p>
+ <p class="text-center"><a href={{reverse "billing:create_subscription" .slug}}>{{.pd.Data.please_upgrade}}</a></p>
+</section>
+{{template "base_footer" .}}