53 lines
1.7 KiB
CoffeeScript
53 lines
1.7 KiB
CoffeeScript
###
|
|
Crafting Guide - main.coffee
|
|
|
|
Copyright (c) 2014-2015 by Redwood Labs
|
|
All rights reserved.
|
|
###
|
|
|
|
require './underscore_mixins'
|
|
require './polyfill'
|
|
|
|
CraftingGuideRouter = require './crafting_guide_router'
|
|
FeedbackController = require './controllers/feedback_controller'
|
|
views = require './views'
|
|
{CraftingGuideClient} = require 'crafting-guide-common'
|
|
{Logger} = require 'crafting-guide-common'
|
|
|
|
########################################################################################################################
|
|
|
|
if typeof(global) is 'undefined'
|
|
window.global = window
|
|
global = window.global
|
|
|
|
global.logger = new Logger
|
|
|
|
switch window.location.hostname
|
|
when 'local.crafting-guide.com'
|
|
global.env = 'development'
|
|
logger.level = Logger.DEBUG
|
|
apiBaseUrl = 'http://localhost:8001'
|
|
when 'new.crafting-guide.com'
|
|
global.env = 'staging'
|
|
logger.level = Logger.VERBOSE
|
|
apiBaseUrl = 'https://crafting-guide-production.herokuapp.com'
|
|
when 'crafting-guide.com'
|
|
global.env = 'production'
|
|
logger.level = Logger.INFO
|
|
apiBaseUrl = 'https://crafting-guide-production.herokuapp.com'
|
|
else
|
|
throw new Error "cannot determine the environment of: #{window.location.hostname}"
|
|
|
|
global.router = new CraftingGuideRouter client:new CraftingGuideClient baseUrl:apiBaseUrl
|
|
global.util = require 'util'
|
|
global.views = views
|
|
global.markdown = global.markdown.markdown
|
|
|
|
global.feedbackController = new FeedbackController el:'.view__feedback'
|
|
feedbackController.render()
|
|
|
|
global.router.loadDefaultModPack()
|
|
|
|
logger.info -> "CraftingGuide is ready"
|
|
Backbone.history.start pushState:true
|