func init() { // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language HeaderFilter, // Add some security based headers revel.InterceptorFilter, // Run interceptors around the action. revel.CompressFilter, // Compress the result. revel.ActionInvoker, // Invoke the action. } // register startup functions with OnAppStart // ( order dependent ) revel.OnAppStart(controllers.InitDB) revel.InterceptMethod((*controllers.GormController).Begin, revel.BEFORE) revel.InterceptMethod((*controllers.GormController).Commit, revel.AFTER) revel.InterceptMethod((*controllers.GormController).Rollback, revel.FINALLY) // revel.OnAppStart(FillCache) }
func init() { revel.OnAppStart(Initialize) revel.InterceptMethod((*DatabaseController).Begin, revel.BEFORE) //revel.InterceptMethod((*Profile).Index, revel.BEFORE) revel.InterceptMethod((*DatabaseController).Commit, revel.AFTER) revel.InterceptMethod((*DatabaseController).Rollback, revel.FINALLY) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.InterceptMethod((*XormController).Attach, revel.BEFORE) revel.InterceptMethod((*XormController).Commit, revel.AFTER) revel.InterceptMethod((*XormController).Detach, revel.FINALLY) revel.InterceptMethod((*XormSessionController).Attach, revel.BEFORE) revel.OnAppStart(Init) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod(Application.AddUser, revel.BEFORE) revel.InterceptMethod(Hotels.checkUser, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*XOrmController).Begin, revel.BEFORE) revel.InterceptMethod((*XOrmTnController).Begin, revel.BEFORE) revel.InterceptMethod((*XOrmTnController).Commit, revel.AFTER) revel.InterceptMethod((*XOrmTnController).Rollback, revel.PANIC) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod(Application.authorize, revel.BEFORE) revel.InterceptMethod(Application.setLoginUrl, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod(Application.SetAccount, revel.BEFORE) revel.InterceptMethod(Dashboard.checkAccount, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
// in your app initialization.. func init() { revel.TemplateFuncs["appendjs"] = func(renderArgs map[string]interface{}, key string, value interface{}) template.HTML { s := value.(string) js_code := template.JS(s) if renderArgs[key] == nil { renderArgs[key] = []interface{}{js_code} } else { renderArgs[key] = append(renderArgs[key].([]interface{}), js_code) } return template.HTML("") } // Filters is the default set of global filters. revel.Filters = []revel.Filter{ revel.PanicFilter, // Recover from panics and display an error page instead. revel.RouterFilter, // Use the routing table to select the right Action revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters. revel.ParamsFilter, // Parse parameters into Controller.Params. revel.SessionFilter, // Restore and write the session cookie. revel.FlashFilter, // Restore and write the flash cookie. csrf.CSRFFilter, // CSRF prevention. revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie. revel.I18nFilter, // Resolve the requested language HeaderFilter, // Add some security based headers revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } revel.OnAppStart(func() { appPath := revel.BasePath for _, AC := range compilers { path := filepath.Join(appPath, AC.Path) revel.INFO.Printf("Listening: %q\n", path) revel.MainWatcher.Listen(AC, path) } }) // DB related stuff // add interceptors revel.InterceptMethod((*ctrl.DbController).Begin, revel.BEFORE) revel.InterceptMethod(ctrl.App.RenderArgsFill, revel.BEFORE) revel.InterceptMethod(ctrl.User.CheckLoggedIn, revel.BEFORE) revel.InterceptMethod((*ctrl.DbController).Commit, revel.AFTER) revel.InterceptMethod((*ctrl.DbController).Rollback, revel.FINALLY) // revel.InterceptMethod((*ctrl.DbController).GetUserLogin, revel.BEFORE) revel.OnAppStart(func() { ctrl.InitDB() if revel.RunMode == "dev" { ctrl.SetupDevDB() } if revel.RunMode == "prod" { ctrl.SetupTables() } }) }
func init() { revel.OnAppStart(InitDB) // DBやテーブルの作成 revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) // transaction開始 revel.InterceptMethod((*GorpController).Commit, revel.AFTER) // 変更反映 revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) // 異常時処理 revel.InterceptMethod(App.AddUser, revel.BEFORE) // ログインユーザーの追加 revel.InterceptMethod(Events.checkUser, revel.BEFORE) // ログインの確認 }
func init() { revel.OnAppStart(GorpInit) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod((*User).getUserLogin, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) revel.TemplateFuncs["eq"] = func(a, b interface{}) bool { return a == b } }
func StartApp() { revel.INFO.Printf("Beginning Initialization Process...") // Load Database Connections revel.INFO.Printf("Connecting to Database...") session, err := mgo.Dial("mongodb://*****:*****@oceanic.mongohq.com:10000/list") if err != nil { panic(err) } collection = session.DB("list").C("classes") users = session.DB("list").C("users") rand.Seed(time.Now().UnixNano()) // Start Parsing Lou's List revel.INFO.Printf("Launching Parser...") jobs.Now(Parser{}) jobs.Every(1*time.Hour, Parser{}) // Regex to Recognize Classes revel.INFO.Printf("Compiling Regular Expressions...") classRegex = regexp.MustCompile(`([A-z]{1,4})\s?(\d{4})\s?(?::{((?:,?\s?\d{1,3})+)})?`) sectionRegex = regexp.MustCompile(`\d{1,3}`) /* revel.INFO.Printf("Adding Template Functions...") CreateTemplateFunctions()*/ // Interceptions revel.INFO.Printf("Starting Interceptors...") revel.InterceptMethod(App.Init, revel.BEFORE) revel.INFO.Printf("Initialization Complete") }
func init() { revel.OnAppStart(InitDB) revel.InterceptFunc(checkUser, revel.BEFORE, &Post{}) revel.InterceptFunc(checkUser, revel.BEFORE, &Profile{}) revel.InterceptFunc(checkUser, revel.BEFORE, &Asset{}) revel.InterceptFunc(adminOnly, revel.BEFORE, &Contributor{}) revel.InterceptFunc(adminOnly, revel.BEFORE, &SiteInfo{}) //revel.InterceptFunc(adminOnly, revel.BEFORE, &Category{}) revel.InterceptMethod((*GormController).Begin, revel.BEFORE) revel.InterceptMethod((*GormController).Commit, revel.AFTER) revel.InterceptMethod((*GormController).RollBack, revel.FINALLY) revel.TemplateFuncs["config"] = func(key string) string { return revel.Config.StringDefault(key, "") } }
func init() { revel.OnAppStart(Init) revel.InterceptMethod((*Application).checkUser, revel.BEFORE) revel.TemplateFuncs["eqis"] = func(i int64, s string) bool { return strconv.FormatInt(i, 10) == s } }
func init() { // Set up the database. revel.OnAppStart(InitDB) // Start running the probes. revel.OnAppStart(func() { jobs.Every(10*time.Second, ProbeJob{}) }) // Before a request, make sure the right API token is set. revel.InterceptMethod((*GorpController).CheckToken, revel.BEFORE) // Before a request, we want to start a transaction. revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) // revel.InterceptMethod(Application.AddUser, revel.BEFORE) // revel.InterceptMethod(Hotels.checkUser, revel.BEFORE) // When a request is done, we want to commit the transaction. revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.OnAppStart(InitDB) revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) revel.InterceptMethod(Account.AddAppName, revel.BEFORE) revel.InterceptMethod(Account.AddRenderMode, revel.BEFORE) revel.InterceptMethod(Account.AddUser, revel.BEFORE) revel.InterceptMethod((*GorpController).Commit, revel.AFTER) revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) }
func init() { revel.InterceptMethod((*MongoController).Open, revel.BEFORE) revel.InterceptMethod((*MongoController).Close, revel.AFTER) revel.InterceptMethod((*MongoController).Error, revel.PANIC) }
func init() { revel.InterceptMethod((*Nodes).Before, revel.BEFORE) }
func init() { // revel.OnAppStart(InitDb) revel.InterceptMethod((*AbstractController).Begin, revel.BEFORE) revel.InterceptMethod((*AbstractController).Commit, revel.AFTER) revel.InterceptMethod((*AbstractController).Rollback, revel.FINALLY) }
func init() { revel.InterceptMethod((*Users).Before, revel.BEFORE) // revel.InterceptMethod((*Users).After, revel.AFTER) }
func InitControllers() { revel.InterceptMethod(CheckCourseraMode, revel.BEFORE) revel.InterceptMethod(PublicApplication.AddUser, revel.BEFORE) revel.InterceptMethod(CheckWorker, revel.BEFORE) revel.InterceptFunc(CheckUser, revel.BEFORE, &SecuredApplication{}) if CourseraMode { revel.InterceptFunc(CheckUser, revel.BEFORE, &CourseraApplication{}) } revel.TemplateFuncs["rfc3339"] = func(t time.Time) string { return t.Format(time.RFC3339) } revel.TemplateFuncs["lower"] = func(s string) string { return strings.ToLower(s) } revel.TemplateFuncs["plus"] = func(x int, y int) int { return x + y } revel.TemplateFuncs["shorten"] = func(s string) string { if len(s) > 60 { bs := []byte(s) return string(bs[:60]) + "..." } else { return s } } revel.TemplateFuncs["percentageToInt"] = func(f float32) int { return int(f * 100) } revel.TemplateFuncs["splitComma"] = func(str string) []string { return strings.Split(str, ",") } revel.TemplateFuncs["positiveQ"] = func(i int) bool { return i > 0 } revel.TemplateFuncs["notEmpty"] = func(xs interface{}) bool { vxs := reflect.ValueOf(xs) return vxs.Len() > 0 } revel.TemplateFuncs["loggerClass"] = func(s string) (class string) { switch s { case "Fatal": case "Error": class = "danger" case "Warn": class = "warning" case "Info": case "Debug": class = "active" default: class = "" } return } revel.TemplateFuncs["milliSeconds"] = func(t int64) float64 { return float64(t) / 1000000.0 } MPFileDirectory = filepath.Join(revel.BasePath, "mp") createBigCodeDatabaseMutex = &sync.Mutex{} if CourseraMode { InitCourseraController() } if IsMaster { InitAdminController() } }
func init() { revel.InterceptMethod(App.Init, revel.BEFORE) }
func ControllerInit() { revel.InterceptMethod((*MongoController).Begin, revel.BEFORE) revel.InterceptMethod((*MongoController).End, revel.FINALLY) }
func init() { revmgo.ControllerInit() revel.InterceptMethod((*Application).Setup, revel.BEFORE) }
func init() { revel.InterceptMethod((*DbController).Begin, revel.BEFORE) }
func initIntercepter() { revel.InterceptMethod(authenticate, revel.BEFORE) }
func init() { revel.OnAppStart(Init) revel.InterceptMethod((*MongoController).Begin, revel.BEFORE) revel.InterceptMethod((*MongoController).End, revel.FINALLY) }
func init() { revel.InterceptMethod((*Settings).Before, revel.BEFORE) }
func init() { r.OnAppStart(InitDB) r.InterceptMethod((*DbController).Begin, r.BEFORE) r.InterceptMethod((*DbController).Commit, r.AFTER) r.InterceptMethod((*DbController).Rollback, r.FINALLY) }
func init() { revel.OnAppStart(InitDB) // DBやテーブルの作成 revel.InterceptMethod((*GorpController).Begin, revel.BEFORE) // transaction開始 revel.InterceptMethod((*GorpController).Commit, revel.AFTER) // 変更反映 revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) // 異常時処理 }