Example #1
0
func main() {
	debug.Nop()

	///////////////////////////////////////////////////////////////////////////
	// Load configuration

	defer config.Close() // Close all packages on exit

	config.Load("config.json",
		&EmailConfig{&email.Config},
		&mongo.Config,
		&user.Config,
		&view.Config,
		&media.Config,
		&mongomedia.Config,
	)

	///////////////////////////////////////////////////////////////////////////
	// Ensure that an admin user exists

	var admin models.User
	_, err := user.EnsureExists("admin", "*****@*****.**", "test", true, &admin)
	errs.PanicOnError(err)
	admin.Admin = true
	err = admin.Save()
	errs.PanicOnError(err)

	///////////////////////////////////////////////////////////////////////////
	// Config view

	view.Config.NamedAuthenticators["admin"] = views.Admin_Auth
	view.Config.Debug.Mode = true
	// view.Config.Debug.LogPaths = true
	// view.Config.Debug.LogRedirects = true
	// view.Config.DisableCachedViews = true
	// view.Config.GlobalAuth = view.NewBasicAuth("statuplive.in", "gostart", "gostart")

	///////////////////////////////////////////////////////////////////////////
	// Run server

	view.RunServer(views.Paths())
}
Example #2
0
// return error?
func (self *Collection) NewDocument(subDocSelectors ...string) interface{} {
	if len(subDocSelectors) > 0 {
		panic("Sub document selectors are not implemented")
	}
	docType := self.DocumentType
	for _, selector := range subDocSelectors {
		for _, field := range strings.Split(selector, ".") {
			var err error
			docType, err = self.subDocumentType(docType, field, subDocSelectors)
			errs.PanicOnError(err)
		}
	}
	doc := reflect.New(docType).Interface()
	self.InitDocument(doc)
	return doc
}