Redirect old blog URLs to new

This commit is contained in:
Ben Visness 2021-09-20 10:17:53 -05:00
parent 73e6af72e0
commit 070ea5cc20
4 changed files with 7 additions and 1 deletions

0
local/download_database.sh Normal file → Executable file
View File

0
local/resetdb.sh Normal file → Executable file
View File

View File

@ -439,7 +439,7 @@ var RegexWikiArticle = regexp.MustCompile(`^/wiki/(?P<threadid>\d+)(-([^/]+))?$`
* Blog * Blog
*/ */
var RegexBlogsRedirect = regexp.MustCompile(`^/blogs`) var RegexBlogsRedirect = regexp.MustCompile(`^/blogs(?P<remainder>.*)`)
var RegexBlog = regexp.MustCompile(`^/blog(/(?P<page>\d+))?$`) var RegexBlog = regexp.MustCompile(`^/blog(/(?P<page>\d+))?$`)

View File

@ -224,6 +224,12 @@ func NewWebsiteRoutes(longRequestContext context.Context, conn *pgxpool.Pool, pe
mainRoutes.POST(hmnurl.RegexBlogPostEdit, authMiddleware(csrfMiddleware(BlogPostEditSubmit))) mainRoutes.POST(hmnurl.RegexBlogPostEdit, authMiddleware(csrfMiddleware(BlogPostEditSubmit)))
mainRoutes.GET(hmnurl.RegexBlogPostDelete, authMiddleware(BlogPostDelete)) mainRoutes.GET(hmnurl.RegexBlogPostDelete, authMiddleware(BlogPostDelete))
mainRoutes.POST(hmnurl.RegexBlogPostDelete, authMiddleware(csrfMiddleware(BlogPostDeleteSubmit))) mainRoutes.POST(hmnurl.RegexBlogPostDelete, authMiddleware(csrfMiddleware(BlogPostDeleteSubmit)))
mainRoutes.GET(hmnurl.RegexBlogsRedirect, func(c *RequestContext) ResponseData {
return c.Redirect(hmnurl.ProjectUrl(
fmt.Sprintf("blog%s", c.PathParams["remainder"]), nil,
c.CurrentProject.Slug,
), http.StatusMovedPermanently)
})
mainRoutes.GET(hmnurl.RegexPodcast, PodcastIndex) mainRoutes.GET(hmnurl.RegexPodcast, PodcastIndex)
mainRoutes.GET(hmnurl.RegexPodcastEdit, PodcastEdit) mainRoutes.GET(hmnurl.RegexPodcastEdit, PodcastEdit)