Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2bc68c0f
Commit
2bc68c0f
authored
May 14, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add path prefix to all AJAX requests
This will handle the case where the site was deployed under a path prefix.
parent
80ba9bd0
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
23 additions
and
15 deletions
+23
-15
static/coffee/spec/calculator_spec.coffee
+1
-1
static/coffee/spec/feedback_form_spec.coffee
+1
-1
static/coffee/src/calculator.coffee
+1
-1
static/coffee/src/courseware.coffee
+1
-0
static/coffee/src/feedback_form.coffee
+1
-1
static/coffee/src/main.coffee
+8
-2
templates/coffee/src/logger.coffee
+2
-2
templates/coffee/src/modules/problem.coffee
+4
-4
templates/coffee/src/modules/sequence.coffee
+1
-1
templates/coffee/src/modules/video/video_caption.coffee
+1
-1
templates/main.html
+1
-0
templates/profile.html
+1
-1
No files found.
static/coffee/spec/calculator_spec.coffee
View file @
2bc68c0f
...
@@ -60,7 +60,7 @@ describe 'Calculator', ->
...
@@ -60,7 +60,7 @@ describe 'Calculator', ->
@
calculator
.
calculate
()
@
calculator
.
calculate
()
it
'send data to /calculate'
,
->
it
'send data to /calculate'
,
->
expect
(
$
.
get
JSON
).
toHaveBeenCalledWith
'/calculate'
,
expect
(
$
.
get
WithPrefix
).
toHaveBeenCalledWith
'/calculate'
,
equation
:
'1+2'
equation
:
'1+2'
,
jasmine
.
any
(
Function
)
,
jasmine
.
any
(
Function
)
...
...
static/coffee/spec/feedback_form_spec.coffee
View file @
2bc68c0f
...
@@ -16,7 +16,7 @@ describe 'FeedbackForm', ->
...
@@ -16,7 +16,7 @@ describe 'FeedbackForm', ->
$
(
'#feedback_message'
).
val
'This site is really good.'
$
(
'#feedback_message'
).
val
'This site is really good.'
$
(
'#feedback_button'
).
click
()
$
(
'#feedback_button'
).
click
()
expect
(
$
.
post
).
toHaveBeenCalledWith
'/send_feedback'
,
{
expect
(
$
.
post
WithPrefix
).
toHaveBeenCalledWith
'/send_feedback'
,
{
subject
:
'Awesome!'
subject
:
'Awesome!'
message
:
'This site is really good.'
message
:
'This site is really good.'
url
:
window
.
location
.
href
url
:
window
.
location
.
href
...
...
static/coffee/src/calculator.coffee
View file @
2bc68c0f
...
@@ -20,5 +20,5 @@ class @Calculator
...
@@ -20,5 +20,5 @@ class @Calculator
$
(
'.help'
).
toggleClass
'shown'
$
(
'.help'
).
toggleClass
'shown'
calculate
:
->
calculate
:
->
$
.
get
JSON
'/calculate'
,
{
equation
:
$
(
'#calculator_input'
).
val
()
},
(
data
)
->
$
.
get
WithPrefix
'/calculate'
,
{
equation
:
$
(
'#calculator_input'
).
val
()
},
(
data
)
->
$
(
'#calculator_output'
).
val
(
data
.
result
)
$
(
'#calculator_output'
).
val
(
data
.
result
)
static/coffee/src/courseware.coffee
View file @
2bc68c0f
class
@
Courseware
class
@
Courseware
constructor
:
->
constructor
:
->
Courseware
.
prefix
=
$
(
"meta[name='path_prefix']"
).
attr
(
'content'
)
new
Navigation
new
Navigation
new
Calculator
new
Calculator
new
FeedbackForm
new
FeedbackForm
...
...
static/coffee/src/feedback_form.coffee
View file @
2bc68c0f
...
@@ -5,6 +5,6 @@ class @FeedbackForm
...
@@ -5,6 +5,6 @@ class @FeedbackForm
subject
:
$
(
'#feedback_subject'
).
val
()
subject
:
$
(
'#feedback_subject'
).
val
()
message
:
$
(
'#feedback_message'
).
val
()
message
:
$
(
'#feedback_message'
).
val
()
url
:
window
.
location
.
href
url
:
window
.
location
.
href
$
.
post
'/send_feedback'
,
data
,
->
$
.
post
WithPrefix
'/send_feedback'
,
data
,
->
$
(
'#feedback_div'
).
html
'Feedback submitted. Thank you'
$
(
'#feedback_div'
).
html
'Feedback submitted. Thank you'
,
'json'
,
'json'
static/coffee/src/main.coffee
View file @
2bc68c0f
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
)
$
->
$
->
$
.
ajaxSetup
$
.
ajaxSetup
headers
:
{
'X-CSRFToken'
:
$
.
cookie
'csrftoken'
}
headers
:
{
'X-CSRFToken'
:
$
.
cookie
'csrftoken'
}
...
@@ -18,8 +24,8 @@ $ ->
...
@@ -18,8 +24,8 @@ $ ->
element
.
schematic
.
update_value
()
element
.
schematic
.
update_value
()
schematic_value
$
(
"#schematic_
#{
circuit_id
}
"
).
attr
(
"value"
)
schematic_value
$
(
"#schematic_
#{
circuit_id
}
"
).
attr
(
"value"
)
$
.
post
"/save_circuit/
#{
circuit_id
}
"
,
schematic
:
schematic_value
,
(
data
)
->
$
.
post
WithPrefix
"/save_circuit/
#{
circuit_id
}
"
,
schematic
:
schematic_value
,
(
data
)
->
alert
(
'Saved'
)
if
data
.
results
==
'success'
alert
(
'Saved'
)
if
data
.
results
==
'success'
window
.
postJSON
=
(
url
,
data
,
callback
)
->
window
.
postJSON
=
(
url
,
data
,
callback
)
->
$
.
post
url
,
data
,
callback
$
.
post
WithPrefix
url
,
data
,
callback
templates/coffee/src/logger.coffee
View file @
2bc68c0f
class
@
Logger
class
@
Logger
@
log
:
(
event_type
,
data
)
->
@
log
:
(
event_type
,
data
)
->
$
.
get
JSON
'/event'
,
$
.
get
WithPrefix
'/event'
,
event_type
:
event_type
event_type
:
event_type
event
:
JSON
.
stringify
(
data
)
event
:
JSON
.
stringify
(
data
)
page
:
window
.
location
.
href
page
:
window
.
location
.
href
...
@@ -8,7 +8,7 @@ class @Logger
...
@@ -8,7 +8,7 @@ class @Logger
@
bind
:
->
@
bind
:
->
window
.
onunload
=
->
window
.
onunload
=
->
$
.
ajax
$
.
ajax
url
:
'/event'
url
:
"
#{
Courseware
.
prefix
}
/event"
data
:
data
:
event_type
:
'page_close'
event_type
:
'page_close'
event
:
''
event
:
''
...
...
templates/coffee/src/modules/problem.coffee
View file @
2bc68c0f
...
@@ -25,7 +25,7 @@ class @Problem
...
@@ -25,7 +25,7 @@ class @Problem
check
:
=>
check
:
=>
Logger
.
log
'problem_check'
,
@
answers
Logger
.
log
'problem_check'
,
@
answers
$
.
post
"/modx/problem/
#{
@
id
}
/problem_check"
,
@
answers
,
(
response
)
=>
$
.
post
WithPrefix
"/modx/problem/
#{
@
id
}
/problem_check"
,
@
answers
,
(
response
)
=>
switch
response
.
success
switch
response
.
success
when
'incorrect'
,
'correct'
when
'incorrect'
,
'correct'
@
render
(
response
.
contents
)
@
render
(
response
.
contents
)
...
@@ -34,18 +34,18 @@ class @Problem
...
@@ -34,18 +34,18 @@ class @Problem
reset
:
=>
reset
:
=>
Logger
.
log
'problem_reset'
,
@
answers
Logger
.
log
'problem_reset'
,
@
answers
$
.
post
"/modx/problem/
#{
@
id
}
/problem_reset"
,
id
:
@
id
,
(
content
)
=>
$
.
post
WithPrefix
"/modx/problem/
#{
@
id
}
/problem_reset"
,
id
:
@
id
,
(
content
)
=>
@
render
(
content
)
@
render
(
content
)
show
:
=>
show
:
=>
Logger
.
log
'problem_show'
,
problem
:
@
id
Logger
.
log
'problem_show'
,
problem
:
@
id
$
.
post
"/modx/problem/
#{
@
id
}
/problem_show"
,
(
response
)
=>
$
.
post
WithPrefix
"/modx/problem/
#{
@
id
}
/problem_show"
,
(
response
)
=>
$
.
each
response
,
(
key
,
value
)
=>
$
.
each
response
,
(
key
,
value
)
=>
@
$
(
"#answer_
#{
key
}
"
).
text
(
value
)
@
$
(
"#answer_
#{
key
}
"
).
text
(
value
)
save
:
=>
save
:
=>
Logger
.
log
'problem_save'
,
@
answers
Logger
.
log
'problem_save'
,
@
answers
$
.
post
"/modx/problem/
#{
@
id
}
/problem_save"
,
@
answers
,
(
response
)
=>
$
.
post
WithPrefix
"/modx/problem/
#{
@
id
}
/problem_save"
,
@
answers
,
(
response
)
=>
if
response
.
success
if
response
.
success
alert
'Saved'
alert
'Saved'
...
...
templates/coffee/src/modules/sequence.coffee
View file @
2bc68c0f
...
@@ -36,7 +36,7 @@ class @Sequence
...
@@ -36,7 +36,7 @@ class @Sequence
render
:
(
new_position
)
->
render
:
(
new_position
)
->
if
@
position
!=
undefined
if
@
position
!=
undefined
@
mark_visited
@
position
@
mark_visited
@
position
$
.
post
"/modx/
#{
@
tag
}
/
#{
@
id
}
/goto_position"
,
position
:
new_position
$
.
post
WithPrefix
"/modx/
#{
@
tag
}
/
#{
@
id
}
/goto_position"
,
position
:
new_position
if
@
position
!=
new_position
if
@
position
!=
new_position
@
mark_active
new_position
@
mark_active
new_position
...
...
templates/coffee/src/modules/video/video_caption.coffee
View file @
2bc68c0f
...
@@ -45,7 +45,7 @@ class VideoCaption
...
@@ -45,7 +45,7 @@ class VideoCaption
.
append
(
$
(
'<li class="spacing">'
).
height
(
@
bottomSpacingHeight
()))
.
append
(
$
(
'<li class="spacing">'
).
height
(
@
bottomSpacingHeight
()))
fetchCaption
:
->
fetchCaption
:
->
$
.
get
JSON
@
captionURL
(),
(
captions
)
=>
$
.
get
WithPrefix
@
captionURL
(),
(
captions
)
=>
@
captions
=
captions
.
text
@
captions
=
captions
.
text
@
start
=
captions
.
start
@
start
=
captions
.
start
for
index
in
[
0
...
captions
.
start
.
length
]
for
index
in
[
0
...
captions
.
start
.
length
]
...
...
templates/main.html
View file @
2bc68c0f
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
It can't be run through static.url because MathJax uses crazy url introspection to do lazy loading of
It can't be run through static.url because MathJax uses crazy url introspection to do lazy loading of
MathJax extension libraries -->
MathJax extension libraries -->
<script
type=
"text/javascript"
src=
"/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"
></script>
<script
type=
"text/javascript"
src=
"/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"
></script>
<meta
name=
"path_prefix"
content=
"${MITX_ROOT_URL}"
>
</head>
</head>
<body
class=
"<%block name='bodyclass'/>"
>
<body
class=
"<%block name='bodyclass'/>"
>
...
...
templates/profile.html
View file @
2bc68c0f
...
@@ -75,7 +75,7 @@ $(function() {
...
@@ -75,7 +75,7 @@ $(function() {
});
});
$
(
'#pwd_reset_button'
).
click
(
function
()
{
$
(
'#pwd_reset_button'
).
click
(
function
()
{
$
.
post
(
'/password_reset/'
,{
"csrfmiddlewaretoken"
:
"${ csrf }"
,
$
.
post
WithPrefix
(
'/password_reset/'
,{
"csrfmiddlewaretoken"
:
"${ csrf }"
,
"email"
:
$
(
'#id_email'
).
val
()},
function
(
data
){
"email"
:
$
(
'#id_email'
).
val
()},
function
(
data
){
$
(
"#password_reset_complete_link"
).
click
();
$
(
"#password_reset_complete_link"
).
click
();
log_event
(
"profile"
,
{
"type"
:
"password_send"
});
log_event
(
"profile"
,
{
"type"
:
"password_send"
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment