Example #1
0
// All front hooks must have the signature of func(*context.Uni, *bool) error
// All views are going to use this hook.
func execFrontViews(uni *context.Uni) {
	var err error
	i := func(hijacked bool, er error) bool {
		if er != nil {
			err = er
			return true
		}
		return hijacked
	}
	uni.Ev.Iterate("Front", i)
	if err == nil {
		display.D(uni)
	} else {
		display.DErr(uni, err)
	}
}
Example #2
0
func runSite(uni *context.Uni) {
	err := buildUser(uni)
	if err != nil {
		display.DErr(uni, err)
		return
	}
	switch uni.Paths[1] {
	// Back hooks are put behind "/b/" to avoid eating up the namespace.
	case "b":
		execAction(uni)
	// Admin is a VIP module, to allow bootstrapping a site even if the option document is empty.
	case "admin":
		execAdmin(uni)
	case "run-commands":
		execCommands(uni)
	case "terminal":
		terminal(uni)
	default:
		execFrontViews(uni)
	}
}
Example #3
0
func execAdmin(uni *context.Uni) {
	l := len(uni.Paths)
	var err error
	if l > 2 && uni.Paths[2] == "b" {
		var action_name string
		if l > 3 {
			action_name = uni.Paths[3]
			uni.Dat["_action"] = action_name
			err = admin.AB(uni, action_name)
		} else {
			err = fmt.Errorf(no_admin_action)
		}
		actionResponse(uni, err, action_name)
	} else {
		err = admin.AD(uni)
		if err == nil {
			display.D(uni)
		} else {
			display.DErr(uni, err)
		}
	}
}