示例#1
0
// NewContext create new Context with from,to and theme args
func NewContext(cli *cli.Context, from, to, theme string) *Context {
	c := &Context{
		cli:       cli,
		From:      from,
		To:        to,
		ThemeName: theme,
		time:      time.Now(),
	}
	c.Tree = model.NewTree(c.DstDir())
	c.Sync = sync.NewSyncer(c.DstDir())
	return c
}
示例#2
0
文件: doc.go 项目: go-xiaohei/pugo
func docServ(c *cli.Context) error {
	if !c.Bool("no-server") {
		builder.After(func(ctx *builder.Context) {
			if s == nil {
				s = server.New(ctx.DstDir())
				go s.Run(c.String("addr"))
			}
			if ctx.Source != nil && ctx.Source.Meta != nil {
				s.SetPrefix(ctx.Source.Meta.Path)
			}
		})
	}
	buildContext := newContext(c, false)
	buildContext.From = "doc/source"
	buildContext.To = "doc/dest"
	buildContext.ThemeName = "doc/theme"
	buildContext.Tree.Dest = buildContext.DstDir()
	buildContext.Sync = sync.NewSyncer(buildContext.DstDir())
	build(buildContext, !c.Bool("no-server"))
	return nil
}