Minor cleanup
This commit is contained in:
parent
a4671c5fb5
commit
5d5e84d7de
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue