Restore the library since we're not actually rolling out education yet
This commit is contained in:
parent
19d79a2a77
commit
168b210c5b
|
@ -700,6 +700,13 @@ func (c *UrlContext) BuildBlogPostReply(threadId int, postId int) string {
|
|||
|
||||
var RegexLibraryAny = regexp.MustCompile(`^/library`)
|
||||
|
||||
var RegexLibrary = regexp.MustCompile(`^/library$`)
|
||||
|
||||
func BuildLibrary() string {
|
||||
defer CatchPanic()
|
||||
return Url("/library", nil)
|
||||
}
|
||||
|
||||
/*
|
||||
* Episode Guide
|
||||
*/
|
||||
|
|
|
@ -84,7 +84,10 @@
|
|||
<div class="root-item">
|
||||
<a>Resources <div class="dib svgicon ml1">{{ svg "chevron-down-thick" }}</div></a>
|
||||
<div class="submenu b--theme-dark">
|
||||
<a href="{{ .Header.LibraryUrl }}">Library</a>
|
||||
{{ if and .User .User.IsEduTester }}
|
||||
<a href="{{ .Header.EducationUrl }}">Education</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -52,6 +52,7 @@ type Header struct {
|
|||
FishbowlUrl string
|
||||
ForumsUrl string
|
||||
ConferencesUrl string
|
||||
LibraryUrl string
|
||||
EducationUrl string
|
||||
|
||||
Project *ProjectHeader
|
||||
|
|
|
@ -75,6 +75,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
|
|||
FishbowlUrl: hmnurl.BuildFishbowlIndex(),
|
||||
ForumsUrl: hmnurl.HMNProjectContext.BuildForum(nil, 1),
|
||||
ConferencesUrl: hmnurl.BuildConferences(),
|
||||
LibraryUrl: hmnurl.BuildLibrary(),
|
||||
EducationUrl: hmnurl.BuildEducationIndex(),
|
||||
},
|
||||
Footer: templates.Footer{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package website
|
||||
|
||||
func LibraryNotPortedYet(c *RequestContext) ResponseData {
|
||||
baseData := getBaseData(c, "Library", nil)
|
||||
|
||||
var res ResponseData
|
||||
res.MustWriteTemplate("library_not_ported_yet.html", baseData, c.Perf)
|
||||
return res
|
||||
}
|
|
@ -75,6 +75,16 @@ func adminsOnly(h Handler) Handler {
|
|||
}
|
||||
}
|
||||
|
||||
func educationBetaTestersOnly(h Handler) Handler {
|
||||
return func(c *RequestContext) ResponseData {
|
||||
if c.CurrentUser == nil || !c.CurrentUser.CanSeeUnpublishedEducationContent() {
|
||||
return FourOhFour(c)
|
||||
}
|
||||
|
||||
return h(c)
|
||||
}
|
||||
}
|
||||
|
||||
func educationAuthorsOnly(h Handler) Handler {
|
||||
return func(c *RequestContext) ResponseData {
|
||||
if c.CurrentUser == nil || !c.CurrentUser.CanAuthorEducation() {
|
||||
|
|
|
@ -117,21 +117,25 @@ func NewWebsiteRoutes(conn *pgxpool.Pool) http.Handler {
|
|||
hmnOnly.GET(hmnurl.RegexFishbowlIndex, FishbowlIndex)
|
||||
hmnOnly.GET(hmnurl.RegexFishbowl, Fishbowl)
|
||||
|
||||
hmnOnly.GET(hmnurl.RegexEducationIndex, EducationIndex)
|
||||
hmnOnly.GET(hmnurl.RegexEducationGlossary, EducationGlossary)
|
||||
hmnOnly.GET(hmnurl.RegexEducationArticleNew, educationAuthorsOnly(EducationArticleNew))
|
||||
hmnOnly.POST(hmnurl.RegexEducationArticleNew, educationAuthorsOnly(EducationArticleNewSubmit))
|
||||
hmnOnly.GET(hmnurl.RegexEducationArticle, EducationArticle) // Article stuff must be last so `/glossary` and others do not match as an article slug
|
||||
hmnOnly.GET(hmnurl.RegexEducationArticleEdit, educationAuthorsOnly(EducationArticleEdit))
|
||||
hmnOnly.POST(hmnurl.RegexEducationArticleEdit, educationAuthorsOnly(EducationArticleEditSubmit))
|
||||
hmnOnly.GET(hmnurl.RegexEducationArticleDelete, educationAuthorsOnly(EducationArticleDelete))
|
||||
hmnOnly.POST(hmnurl.RegexEducationArticleDelete, educationAuthorsOnly(csrfMiddleware(EducationArticleDeleteSubmit)))
|
||||
educationPrerelease := hmnOnly.WithMiddleware(educationBetaTestersOnly)
|
||||
{
|
||||
educationPrerelease.GET(hmnurl.RegexEducationIndex, EducationIndex)
|
||||
educationPrerelease.GET(hmnurl.RegexEducationGlossary, EducationGlossary)
|
||||
educationPrerelease.GET(hmnurl.RegexEducationArticleNew, educationAuthorsOnly(EducationArticleNew))
|
||||
educationPrerelease.POST(hmnurl.RegexEducationArticleNew, educationAuthorsOnly(EducationArticleNewSubmit))
|
||||
educationPrerelease.GET(hmnurl.RegexEducationArticle, EducationArticle) // Article stuff must be last so `/glossary` and others do not match as an article slug
|
||||
educationPrerelease.GET(hmnurl.RegexEducationArticleEdit, educationAuthorsOnly(EducationArticleEdit))
|
||||
educationPrerelease.POST(hmnurl.RegexEducationArticleEdit, educationAuthorsOnly(EducationArticleEditSubmit))
|
||||
educationPrerelease.GET(hmnurl.RegexEducationArticleDelete, educationAuthorsOnly(EducationArticleDelete))
|
||||
educationPrerelease.POST(hmnurl.RegexEducationArticleDelete, educationAuthorsOnly(csrfMiddleware(EducationArticleDeleteSubmit)))
|
||||
}
|
||||
|
||||
hmnOnly.POST(hmnurl.RegexAPICheckUsername, csrfMiddleware(APICheckUsername))
|
||||
|
||||
hmnOnly.GET(hmnurl.RegexLibraryAny, func(c *RequestContext) ResponseData {
|
||||
return c.Redirect(hmnurl.BuildEducationIndex(), http.StatusFound)
|
||||
})
|
||||
hmnOnly.GET(hmnurl.RegexLibraryAny, LibraryNotPortedYet)
|
||||
// hmnOnly.GET(hmnurl.RegexLibraryAny, func(c *RequestContext) ResponseData {
|
||||
// return c.Redirect(hmnurl.BuildEducationIndex(), http.StatusFound)
|
||||
// })
|
||||
|
||||
// Project routes can appear either at the root (e.g. hero.handmade.network/edit)
|
||||
// or on a personal project path (e.g. handmade.network/p/123/hero/edit). So, we
|
||||
|
|
Loading…
Reference in New Issue