Ejemplo n.º 1
0
// DocsHome renders the home.md document for the given language.
//
//		Method           GET
//
//		Route            /docs
//
//		Restrictions     None
//
// 		Template         base/docs_index.html
//
func DocsHome(ctx *echo.Context) error {
	data := utils.GetData(ctx).(utils.Data)
	lang := data.Get(settings.LangDataKey).(string)
	home := settings.DocsPath + "/" + lang + "/" + settings.DocsIndexPage
	d, err := static.Asset(home)
	if err != nil {
		utils.SetData(ctx, "Message", tmpl.NotFoundMessage)
		return ctx.Render(http.StatusNotFound, tmpl.ErrNotFoundTpl, utils.GetData(ctx))
	}
	data.Set("doc", string(d))
	data.Set(docIndex, getDocIndex(lang))
	data.Set("PageTitle", settings.DocsIndexPage)
	return ctx.Render(http.StatusOK, tmpl.BaseDocsHomeTpl, data)
}
Ejemplo n.º 2
0
// Docs renders individual zedlist document.
//
//		Method           GET
//
//		Route            /docs/:name
//
//		Restrictions     None
//
// 		Template         base/docs.html
func Docs(ctx *echo.Context) error {
	data := utils.GetData(ctx).(utils.Data)
	lang := data.Get(settings.LangDataKey).(string)
	fname := ctx.Param("name")
	if filepath.Ext(fname) != ".md" {
		fname = fname + ".md"
	}
	fPath := settings.DocsPath + "/" + lang + "/" + fname
	d, err := static.Asset(fPath)
	if err != nil {
		utils.SetData(ctx, "Message", tmpl.NotFoundMessage)
		return ctx.Render(http.StatusNotFound, tmpl.ErrNotFoundTpl, utils.GetData(ctx))
	}
	data.Set("doc", string(d))
	data.Set("PageTitle", fname)
	data.Set(docIndex, getDocIndex(lang))
	return ctx.Render(http.StatusOK, tmpl.BaseDocTpl, data)
}