Move Logger and *withPrefix javascript into a common location
This commit is contained in:
@@ -146,10 +146,10 @@ MANAGERS = ADMINS
|
||||
# Static content
|
||||
STATIC_URL = '/static/'
|
||||
ADMIN_MEDIA_PREFIX = '/static/admin/'
|
||||
STATIC_ROOT = ENV_ROOT / "staticfiles"
|
||||
STATIC_ROOT = ENV_ROOT / "staticfiles"
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
('js/vendor', COMMON_ROOT / "static" / "js" / "vendor"),
|
||||
COMMON_ROOT / "static",
|
||||
PROJECT_ROOT / "static",
|
||||
|
||||
# This is how you would use the textbook images locally
|
||||
@@ -219,7 +219,15 @@ for idx, filetype, fragment in sorted(fragments):
|
||||
|
||||
PIPELINE_JS = {
|
||||
'main': {
|
||||
'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')],
|
||||
'source_filenames': [
|
||||
pth.replace(COMMON_ROOT / 'static/', '')
|
||||
for pth
|
||||
in glob2.glob(COMMON_ROOT / 'static/coffee/src/**/*.coffee')
|
||||
] + [
|
||||
pth.replace(PROJECT_ROOT / 'static/', '')
|
||||
for pth
|
||||
in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')
|
||||
],
|
||||
'output_filename': 'js/application.js',
|
||||
},
|
||||
'module-js': {
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
jQuery.postWithPrefix = (url, data, callback, type) ->
|
||||
$.post("#{CMS.prefix}#{url}", data, callback, type)
|
||||
|
||||
jQuery.getWithPrefix = (url, data, callback, type) ->
|
||||
$.get("#{CMS.prefix}#{url}", data, callback, type)
|
||||
AjaxPrefix.addAjaxPrefix(jQuery, -> CMS.prefix)
|
||||
|
||||
@CMS =
|
||||
Models: {}
|
||||
|
||||
1
common/static/coffee/src/.gitignore
vendored
Normal file
1
common/static/coffee/src/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.js
|
||||
16
common/static/coffee/src/ajax_prefix.coffee
Normal file
16
common/static/coffee/src/ajax_prefix.coffee
Normal file
@@ -0,0 +1,16 @@
|
||||
@AjaxPrefix =
|
||||
addAjaxPrefix: (jQuery, prefix) ->
|
||||
jQuery.postWithPrefix = (url, data, callback, type) ->
|
||||
$.post("#{prefix()}#{url}", data, callback, type)
|
||||
|
||||
jQuery.getWithPrefix = (url, data, callback, type) ->
|
||||
$.get("#{prefix()}#{url}", data, callback, type)
|
||||
|
||||
jQuery.ajaxWithPrefix = (url, settings) ->
|
||||
if settings?
|
||||
$.ajax("#{prefix()}#{url}", settings)
|
||||
else
|
||||
settings = url
|
||||
settings.url = "#{prefix()}#{settings.url}"
|
||||
$.ajax settings
|
||||
|
||||
@@ -7,8 +7,8 @@ class @Logger
|
||||
|
||||
@bind: ->
|
||||
window.onunload = ->
|
||||
$.ajax
|
||||
url: "#{Courseware.prefix}/event"
|
||||
$.ajaxWithPrefix
|
||||
url: "/event"
|
||||
data:
|
||||
event_type: 'page_close'
|
||||
event: ''
|
||||
@@ -184,7 +184,7 @@ ADMIN_MEDIA_PREFIX = '/static/admin/'
|
||||
STATIC_ROOT = ENV_ROOT / "staticfiles"
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
('js/vendor', COMMON_ROOT / "static" / "js" / "vendor"),
|
||||
COMMON_ROOT / "static",
|
||||
PROJECT_ROOT / "static",
|
||||
ASKBOT_ROOT / "askbot" / "skins",
|
||||
|
||||
@@ -365,6 +365,10 @@ PIPELINE_JS = {
|
||||
'application': {
|
||||
# Application will contain all paths not in courseware_only_js
|
||||
'source_filenames': [
|
||||
pth.replace(COMMON_ROOT / 'static/', '')
|
||||
for pth
|
||||
in glob2.glob(COMMON_ROOT / 'static/coffee/src/**/*.coffee')
|
||||
] + [
|
||||
pth.replace(PROJECT_ROOT / 'static/', '')
|
||||
for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')\
|
||||
if pth not in courseware_only_js
|
||||
|
||||
@@ -56,8 +56,8 @@ CACHES = {
|
||||
SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd'
|
||||
|
||||
################################ DEBUG TOOLBAR #################################
|
||||
#INSTALLED_APPS += ('debug_toolbar',)
|
||||
#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
INSTALLED_APPS += ('debug_toolbar',)
|
||||
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
|
||||
DEBUG_TOOLBAR_PANELS = (
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
jQuery.postWithPrefix = (url, data, callback, type) ->
|
||||
$.post("#{Courseware.prefix}#{url}", data, callback, type)
|
||||
|
||||
jQuery.getWithPrefix = (url, data, callback, type) ->
|
||||
$.get("#{Courseware.prefix}#{url}", data, callback, type)
|
||||
AjaxPrefix.addAjaxPrefix(jQuery, -> Courseware.prefix)
|
||||
|
||||
$ ->
|
||||
$.ajaxSetup
|
||||
|
||||
Reference in New Issue
Block a user