Esempio n. 1
0
// HandleCreateShow serves the create form via GET for stories
func HandleCreateShow(context router.Context) error {

	// Authorise
	err := authorise.Path(context)
	if err != nil {
		return router.NotAuthorizedError(err)
	}

	// Render the template
	view := view.New(context)
	story := stories.New()
	view.AddKey("story", story)
	view.AddKey("meta_title", "Go Hacker News Submit")
	view.AddKey("authenticity_token", authorise.CreateAuthenticityToken(context))
	return view.Render()
}
Esempio n. 2
0
// HandleCreateShow serves the create form via GET for stories
func HandleCreateShow(context router.Context) error {

	// Authorise
	err := authorise.Path(context)
	if err != nil {
		// When not allowed to post stories, redirect to register screen
		router.Redirect(context, "/users/create")
	}

	// Render the template
	view := view.New(context)
	story := stories.New()
	view.AddKey("story", story)
	view.AddKey("meta_title", "Go Hacker News Submit")

	return view.Render()
}