示例#1
0
文件: app.go 项目: rainycape/gondola
func New(opts Options) *App {
	data := &appData{
		Groups: opts.Groups,
	}
	a := reusableapp.New(reusableapp.Options{
		Name:          "Docs",
		AssetsData:    assetsData,
		TemplatesData: tmplData,
		Data:          data,
	})
	a.Prefix = "/doc/"
	reverseDoc := func(s string) string { return a.MustReverse(PackageHandlerName, s) }
	reverseSource := func(s string) string { return a.MustReverse(SourceHandlerName, s) }
	data.Environment = doc.NewEnvironment(reverseDoc, reverseSource)
	data.Environment.Set(envAppKey, a)
	a.AddTemplateVars(map[string]interface{}{
		"List":    ListHandlerName,
		"StdList": StdListHandlerName,
		"Package": PackageHandlerName,
		"Source":  SourceHandlerName,
	})
	a.Handle("^/$", ListHandler, app.NamedHandler(ListHandlerName))
	a.Handle("^/pkg/std/?", StdListHandler, app.NamedHandler(StdListHandlerName))
	a.Handle("^/pkg/(.+)", PackageHandler, app.NamedHandler(PackageHandlerName))
	a.Handle("^/src/(.+)", SourceHandler, app.NamedHandler(SourceHandlerName))
	return &App{App: *a}
}
示例#2
0
文件: app.go 项目: rainycape/gondola
func New() *App {
	a := reusableapp.New(reusableapp.Options{
		Name:          "Articles",
		Data:          &appData{},
		TemplatesData: tmplData,
	})
	a.AddTemplateVars(map[string]interface{}{
		"Article": ArticleHandlerName,
		"List":    ArticleListHandlerName,
	})
	a.Handle("^/(.+)/$", ArticleHandler, app.NamedHandler(ArticleHandlerName))
	a.Handle("^/$", ArticleListHandler, app.NamedHandler(ArticleListHandlerName))
	return &App{App: *a}
}