Ejemplo n.º 1
0
func form(ctx iface.Context, action_name string) *Form {
	nouns := scut.GetNouns(ctx.Options().Document())
	np := ctx.NonPortable()
	hl, err := highlev.New(ctx.Conducting().Hooks(), np.Resource(), nouns, np.Params())
	if err != nil {
		panic(err)
	}
	f := hl.URLE().Form(action_name)
	return &Form{
		f,
	}
}
Ejemplo n.º 2
0
func _url(ctx iface.Context, action_name string, i ...interface{}) string {
	if len(i)%2 == 1 {
		panic("Must be even.")
	}
	nouns := scut.GetNouns(ctx.Options().Document())
	np := ctx.NonPortable()
	hl, err := highlev.New(ctx.Conducting().Hooks(), np.Resource(), nouns, np.Params())
	if err != nil {
		panic(err)
	}
	f := hl.URLE()
	inp := convert.ListToMap(i...)
	return f.UrlString(action_name, inp)
}
Ejemplo n.º 3
0
func pager(ctx iface.Context, pagestr string, count, limit int) []paging.Pelem {
	if len(pagestr) == 0 {
		pagestr = "1"
	}
	if limit == 0 {
		return nil
	}
	p := ctx.NonPortable().Resource() + "?" + ctx.NonPortable().RawParams()
	page, err := strconv.Atoi(pagestr)
	if err != nil {
		return nil // Not blowing up here.
	}
	if page == 0 {
		return nil
	}
	page_count := count/limit + 1
	nav, _ := paging.P(page, page_count, 3, p)
	return nav
}
Ejemplo n.º 4
0
// Works from Get or GetSingle only.
func getSub(ctx iface.Context, noun string, params ...interface{}) []interface{} {
	nouns, ok := ctx.Options().Document().GetM("nouns")
	if !ok {
		panic("Can't find nouns.")
	}
	np := ctx.NonPortable()
	hl, err := highlev.New(ctx.Conducting().Hooks(), np.Resource(), nouns, np.Params())
	if err != nil {
		panic(err)
	}
	inp := convert.ListToMap(params...)
	subhl, err := hl.Sub(noun, inp)
	if err != nil {
		panic(err)
	}
	deflev_i, _ := ctx.Options().Document().Get("default_level")
	deflev, _ := numcon.Int(deflev_i)
	ret, err := subhl.Run(ctx.Db(), ctx.User(), deflev)
	if err != nil {
		panic(err)
	}
	return ret
}