diff --git a/src/templates/templates.go b/src/templates/templates.go index 450dba27..bd167a40 100644 --- a/src/templates/templates.go +++ b/src/templates/templates.go @@ -214,6 +214,7 @@ var HMNTemplateFuncs = template.FuncMap{ }, } +// TODO(asaf): Delete these? type ErrInvalidHexColor struct { color string } @@ -221,17 +222,3 @@ type ErrInvalidHexColor struct { func (e ErrInvalidHexColor) Error() string { return fmt.Sprintf("invalid hex color: %s", e.color) } - -func getProjectSubdomain(proj interface{}) string { - subdomain := "" - switch p := proj.(type) { - case Project: - subdomain = p.Subdomain - case int: - // TODO: Look up project from the database - default: - panic(fmt.Errorf("projecturl requires either a templates.Project or a project ID, got %+v", proj)) - } - - return subdomain -} diff --git a/src/website/feed.go b/src/website/feed.go index 7fc8825a..30e765a3 100644 --- a/src/website/feed.go +++ b/src/website/feed.go @@ -94,7 +94,7 @@ func Feed(c *RequestContext) ResponseData { baseData.BodyClasses = append(baseData.BodyClasses, "feed") var res ResponseData - res.WriteTemplate("feed.html", FeedData{ + err = res.WriteTemplate("feed.html", FeedData{ BaseData: baseData, AtomFeedUrl: hmnurl.BuildAtomFeed(), @@ -102,6 +102,9 @@ func Feed(c *RequestContext) ResponseData { Posts: posts, Pagination: pagination, }, c.Perf) + if err != nil { + panic(err) + } return res } @@ -253,7 +256,10 @@ func AtomFeed(c *RequestContext) ResponseData { } var res ResponseData - res.WriteTemplate("atom.xml", feedData, c.Perf) + err := res.WriteTemplate("atom.xml", feedData, c.Perf) + if err != nil { + panic(err) + } return res } diff --git a/src/website/projects.go b/src/website/projects.go index 8656d9ff..8b430df6 100644 --- a/src/website/projects.go +++ b/src/website/projects.go @@ -182,7 +182,7 @@ func ProjectIndex(c *RequestContext) ResponseData { baseData := getBaseData(c) baseData.Title = "Project List" var res ResponseData - res.WriteTemplate("project_index.html", ProjectTemplateData{ + err = res.WriteTemplate("project_index.html", ProjectTemplateData{ BaseData: baseData, Pagination: pagination, @@ -199,5 +199,8 @@ func ProjectIndex(c *RequestContext) ResponseData { RegisterUrl: hmnurl.BuildRegister(), LoginUrl: hmnurl.BuildLoginPage(c.FullUrl()), }, c.Perf) + if err != nil { + panic(err) + } return res } diff --git a/src/website/routes.go b/src/website/routes.go index a5030ab0..6c2744ad 100644 --- a/src/website/routes.go +++ b/src/website/routes.go @@ -147,7 +147,7 @@ func getBaseData(c *RequestContext) templates.BaseData { LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()), LogoutActionUrl: hmnurl.BuildLogoutAction(), RegisterUrl: hmnurl.BuildHomepage(), // TODO(asaf) - HMNHomepageUrl: hmnurl.BuildHomepage(), // TODO(asaf) + HMNHomepageUrl: hmnurl.BuildHomepage(), ProjectHomepageUrl: hmnurl.BuildProjectHomepage(c.CurrentProject.Slug), ProjectIndexUrl: hmnurl.BuildProjectIndex(1), BlogUrl: hmnurl.BuildBlog(c.CurrentProject.Slug, 1), @@ -250,7 +250,10 @@ func FourOhFour(c *RequestContext) ResponseData { BaseData: getBaseData(c), Wanted: c.FullUrl(), } - res.WriteTemplate("404.html", templateData, c.Perf) + err := res.WriteTemplate("404.html", templateData, c.Perf) + if err != nil { + panic(err) + } } else { res.Write([]byte("Not Found")) } diff --git a/src/website/staticpages.go b/src/website/staticpages.go index 09410a64..156e6bf2 100644 --- a/src/website/staticpages.go +++ b/src/website/staticpages.go @@ -4,42 +4,63 @@ import () func Manifesto(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("manifesto.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("manifesto.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func About(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("about.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("about.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func CodeOfConduct(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("code_of_conduct.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("code_of_conduct.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func CommunicationGuidelines(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("communication_guidelines.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("communication_guidelines.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func ContactPage(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("contact.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("contact.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func MonthlyUpdatePolicy(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("monthly_update_policy.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("monthly_update_policy.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res } func ProjectSubmissionGuidelines(c *RequestContext) ResponseData { var res ResponseData - res.WriteTemplate("project_submission_guidelines.html", getBaseData(c), c.Perf) + err := res.WriteTemplate("project_submission_guidelines.html", getBaseData(c), c.Perf) + if err != nil { + panic(err) + } return res }