// Setup db - at present query pkg manages this... func setupDatabase(server *server.Server) { defer server.Timef("#info Finished opening in %s database %s for user %s", time.Now(), server.Config("db"), server.Config("db_user")) config := server.Configuration() options := map[string]string{ "adapter": config["db_adapter"], "user": config["db_user"], "password": config["db_pass"], "db": config["db"], } // If host and port supplied in config, apply them if len(config["db_host"]) > 0 { options["host"] = config["db_host"] } if len(config["db_port"]) > 0 { options["port"] = config["db_port"] } if len(config["db_params"]) > 0 { options["params"] = config["db_params"] } // Ask query to open the database err := query.OpenDatabase(options) if err != nil { server.Fatalf("Error reading database %s", err) } }
// Compile or copy in our assets from src into the public assets folder, for use by the app func setupAssets(server *server.Server) { defer server.Timef("#info Finished loading assets in %s", time.Now()) // Compilation of assets is done on deploy // We just load them here assetsCompiled := server.ConfigBool("assets_compiled") appAssets = assets.New(assetsCompiled) // Load asset details from json file on each run err := appAssets.Load() if err != nil { // Compile assets for the first time server.Logf("#info Compiling assets") err := appAssets.Compile("src", "public") if err != nil { server.Fatalf("#error compiling assets %s", err) } } // Set up helpers which are aware of fingerprinted assets // These behave differently depending on the compile flag above // when compile is set to no, they use precompiled assets // otherwise they serve all files in a group separately view.Helpers["style"] = appAssets.StyleLink view.Helpers["script"] = appAssets.ScriptLink }
func setupView(server *server.Server) { defer server.Timef("#info Finished loading templates in %s", time.Now()) view.Production = server.Production() err := view.LoadTemplates() if err != nil { server.Fatalf("Error reading templates %s", err) } }
func setupView(server *server.Server) { defer server.Timef("#info Finished loading templates in %s", time.Now()) // A very limited translation - would prefer to use editable.js // instead and offer proper editing TODO: move to editable.js instead view.Helpers["markup"] = markup view.Helpers["timeago"] = timeago view.Production = server.Production() err := view.LoadTemplates() if err != nil { server.Fatalf("Error reading templates %s", err) } }
// Setup db - at present query pkg manages this... func setupDatabase(server *server.Server) { defer server.Timef("#info Finished opening in %s database %s for user %s", time.Now(), server.Config("db"), server.Config("db_user")) config := server.Configuration() options := map[string]string{ "adapter": config["db_adapter"], "user": config["db_user"], "password": config["db_pass"], "db": config["db"], } // Ask query to open the database err := query.OpenDatabase(options) if err != nil { server.Fatalf("Error reading database %s", err) } }