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
78879ebc
Commit
78879ebc
authored
Aug 19, 2014
by
Don Mitchell
Committed by
Ben McMorran
Aug 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asset urls must start w/ slash
LMS-11233
parent
2839ad87
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
18 deletions
+22
-18
cms/djangoapps/contentstore/utils.py
+1
-1
cms/djangoapps/contentstore/views/assets.py
+2
-8
common/djangoapps/static_replace/__init__.py
+1
-1
common/lib/xmodule/xmodule/contentstore/content.py
+16
-6
common/lib/xmodule/xmodule/contentstore/mongo.py
+1
-1
lms/djangoapps/courseware/courses.py
+1
-1
No files found.
cms/djangoapps/contentstore/utils.py
View file @
78879ebc
...
@@ -146,7 +146,7 @@ def get_lms_link_for_about_page(course_key):
...
@@ -146,7 +146,7 @@ def get_lms_link_for_about_page(course_key):
def
course_image_url
(
course
):
def
course_image_url
(
course
):
"""Returns the image url for the course."""
"""Returns the image url for the course."""
loc
=
StaticContent
.
compute_location
(
course
.
location
.
course_key
,
course
.
course_image
)
loc
=
StaticContent
.
compute_location
(
course
.
location
.
course_key
,
course
.
course_image
)
path
=
loc
.
to_deprecated_string
(
)
path
=
StaticContent
.
serialize_asset_key_with_slash
(
loc
)
return
path
return
path
...
...
cms/djangoapps/contentstore/views/assets.py
View file @
78879ebc
...
@@ -277,7 +277,7 @@ def _get_asset_json(display_name, date, location, thumbnail_location, locked):
...
@@ -277,7 +277,7 @@ def _get_asset_json(display_name, date, location, thumbnail_location, locked):
"""
"""
Helper method for formatting the asset information to send to client.
Helper method for formatting the asset information to send to client.
"""
"""
asset_url
=
_add_slash
(
location
.
to_deprecated_string
()
)
asset_url
=
StaticContent
.
serialize_asset_key_with_slash
(
location
)
external_url
=
settings
.
LMS_BASE
+
asset_url
external_url
=
settings
.
LMS_BASE
+
asset_url
return
{
return
{
'display_name'
:
display_name
,
'display_name'
:
display_name
,
...
@@ -285,14 +285,8 @@ def _get_asset_json(display_name, date, location, thumbnail_location, locked):
...
@@ -285,14 +285,8 @@ def _get_asset_json(display_name, date, location, thumbnail_location, locked):
'url'
:
asset_url
,
'url'
:
asset_url
,
'external_url'
:
external_url
,
'external_url'
:
external_url
,
'portable_url'
:
StaticContent
.
get_static_path_from_location
(
location
),
'portable_url'
:
StaticContent
.
get_static_path_from_location
(
location
),
'thumbnail'
:
_add_slash
(
unicode
(
thumbnail_location
)
)
if
thumbnail_location
else
None
,
'thumbnail'
:
StaticContent
.
serialize_asset_key_with_slash
(
thumbnail_location
)
if
thumbnail_location
else
None
,
'locked'
:
locked
,
'locked'
:
locked
,
# Needed for Backbone delete/update.
# Needed for Backbone delete/update.
'id'
:
unicode
(
location
)
'id'
:
unicode
(
location
)
}
}
def
_add_slash
(
url
):
if
not
url
.
startswith
(
'/'
):
url
=
'/'
+
url
# TODO - re-address this once LMS-11198 is tackled.
return
url
common/djangoapps/static_replace/__init__.py
View file @
78879ebc
...
@@ -97,7 +97,7 @@ def replace_static_urls(text, data_directory, course_id=None, static_asset_path=
...
@@ -97,7 +97,7 @@ def replace_static_urls(text, data_directory, course_id=None, static_asset_path=
Replace /static/$stuff urls either with their correct url as generated by collectstatic,
Replace /static/$stuff urls either with their correct url as generated by collectstatic,
(/static/$md5_hashed_stuff) or by the course-specific content static url
(/static/$md5_hashed_stuff) or by the course-specific content static url
/static/$course_data_dir/$stuff, or, if course_namespace is not None, by the
/static/$course_data_dir/$stuff, or, if course_namespace is not None, by the
correct url in the contentstore (
c4x://
)
correct url in the contentstore (
/c4x/.. or /asset-loc:..
)
text: The source text to do the substitution in
text: The source text to do the substitution in
data_directory: The directory in which course data is stored
data_directory: The directory in which course data is stored
...
...
common/lib/xmodule/xmodule/contentstore/content.py
View file @
78879ebc
...
@@ -64,9 +64,6 @@ class StaticContent(object):
...
@@ -64,9 +64,6 @@ class StaticContent(object):
def
get_id
(
self
):
def
get_id
(
self
):
return
self
.
location
return
self
.
location
def
get_url_path
(
self
):
return
self
.
location
.
to_deprecated_string
()
@property
@property
def
data
(
self
):
def
data
(
self
):
return
self
.
_data
return
self
.
_data
...
@@ -108,7 +105,9 @@ class StaticContent(object):
...
@@ -108,7 +105,9 @@ class StaticContent(object):
assert
(
isinstance
(
course_key
,
CourseKey
))
assert
(
isinstance
(
course_key
,
CourseKey
))
placeholder_id
=
uuid
.
uuid4
()
.
hex
placeholder_id
=
uuid
.
uuid4
()
.
hex
# create a dummy asset location with a fake but unique name. strip off the name, and return it
# create a dummy asset location with a fake but unique name. strip off the name, and return it
url_path
=
unicode
(
course_key
.
make_asset_key
(
'asset'
,
placeholder_id
)
.
for_branch
(
None
))
url_path
=
StaticContent
.
serialize_asset_key_with_slash
(
course_key
.
make_asset_key
(
'asset'
,
placeholder_id
)
.
for_branch
(
None
)
)
return
url_path
.
replace
(
placeholder_id
,
''
)
return
url_path
.
replace
(
placeholder_id
,
''
)
@staticmethod
@staticmethod
...
@@ -133,7 +132,7 @@ class StaticContent(object):
...
@@ -133,7 +132,7 @@ class StaticContent(object):
# Generate url of urlparse.path component
# Generate url of urlparse.path component
scheme
,
netloc
,
orig_path
,
params
,
query
,
fragment
=
urlparse
(
path
)
scheme
,
netloc
,
orig_path
,
params
,
query
,
fragment
=
urlparse
(
path
)
loc
=
StaticContent
.
compute_location
(
course_id
,
orig_path
)
loc
=
StaticContent
.
compute_location
(
course_id
,
orig_path
)
loc_url
=
loc
.
to_deprecated_string
(
)
loc_url
=
StaticContent
.
serialize_asset_key_with_slash
(
loc
)
# parse the query params for "^/static/" and replace with the location url
# parse the query params for "^/static/" and replace with the location url
orig_query
=
parse_qsl
(
query
)
orig_query
=
parse_qsl
(
query
)
...
@@ -144,7 +143,7 @@ class StaticContent(object):
...
@@ -144,7 +143,7 @@ class StaticContent(object):
course_id
,
course_id
,
query_value
[
len
(
'/static/'
):],
query_value
[
len
(
'/static/'
):],
)
)
new_query_url
=
new_query
.
to_deprecated_string
(
)
new_query_url
=
StaticContent
.
serialize_asset_key_with_slash
(
new_query
)
new_query_list
.
append
((
query_name
,
new_query_url
))
new_query_list
.
append
((
query_name
,
new_query_url
))
else
:
else
:
new_query_list
.
append
((
query_name
,
query_value
))
new_query_list
.
append
((
query_name
,
query_value
))
...
@@ -155,6 +154,17 @@ class StaticContent(object):
...
@@ -155,6 +154,17 @@ class StaticContent(object):
def
stream_data
(
self
):
def
stream_data
(
self
):
yield
self
.
_data
yield
self
.
_data
@staticmethod
def
serialize_asset_key_with_slash
(
asset_key
):
"""
Legacy code expects the serialized asset key to start w/ a slash; so, do that in one place
:param asset_key:
"""
url
=
unicode
(
asset_key
)
if
not
url
.
startswith
(
'/'
):
url
=
'/'
+
url
# TODO - re-address this once LMS-11198 is tackled.
return
url
class
StaticContentStream
(
StaticContent
):
class
StaticContentStream
(
StaticContent
):
def
__init__
(
self
,
loc
,
name
,
content_type
,
stream
,
last_modified_at
=
None
,
thumbnail_location
=
None
,
import_path
=
None
,
def
__init__
(
self
,
loc
,
name
,
content_type
,
stream
,
last_modified_at
=
None
,
thumbnail_location
=
None
,
import_path
=
None
,
...
...
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
78879ebc
...
@@ -66,7 +66,7 @@ class MongoContentStore(ContentStore):
...
@@ -66,7 +66,7 @@ class MongoContentStore(ContentStore):
self
.
delete
(
content_id
)
# delete is a noop if the entry doesn't exist; so, don't waste time checking
self
.
delete
(
content_id
)
# delete is a noop if the entry doesn't exist; so, don't waste time checking
thumbnail_location
=
content
.
thumbnail_location
.
to_deprecated_list_repr
()
if
content
.
thumbnail_location
else
None
thumbnail_location
=
content
.
thumbnail_location
.
to_deprecated_list_repr
()
if
content
.
thumbnail_location
else
None
with
self
.
fs
.
new_file
(
_id
=
content_id
,
filename
=
content
.
get_url_path
(
),
content_type
=
content
.
content_type
,
with
self
.
fs
.
new_file
(
_id
=
content_id
,
filename
=
unicode
(
content
.
location
),
content_type
=
content
.
content_type
,
displayname
=
content
.
name
,
content_son
=
content_son
,
displayname
=
content
.
name
,
content_son
=
content_son
,
thumbnail_location
=
thumbnail_location
,
thumbnail_location
=
thumbnail_location
,
import_path
=
content
.
import_path
,
import_path
=
content
.
import_path
,
...
...
lms/djangoapps/courseware/courses.py
View file @
78879ebc
...
@@ -118,7 +118,7 @@ def course_image_url(course):
...
@@ -118,7 +118,7 @@ def course_image_url(course):
url
+=
'/images/course_image.jpg'
url
+=
'/images/course_image.jpg'
else
:
else
:
loc
=
StaticContent
.
compute_location
(
course
.
id
,
course
.
course_image
)
loc
=
StaticContent
.
compute_location
(
course
.
id
,
course
.
course_image
)
url
=
loc
.
to_deprecated_string
(
)
url
=
StaticContent
.
serialize_asset_key_with_slash
(
loc
)
return
url
return
url
...
...
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