예제 #1
0
파일: context.go 프로젝트: go-xiaohei/pugo
// 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
}