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
e8c4d1db
Commit
e8c4d1db
authored
Apr 23, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace links to static in problems with links to fingerprinted data
parent
5a4d9691
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
6 deletions
+28
-6
lib/static_replace.py
+19
-0
rakefile
+1
-1
templates/main.html
+4
-2
templates/problem.html
+2
-1
templates/static_content.html
+2
-0
urls.py
+0
-2
No files found.
lib/static_replace.py
0 → 100644
View file @
e8c4d1db
from
staticfiles.storage
import
staticfiles_storage
import
re
PREFIX
=
'/static/'
STATIC_PATTERN
=
re
.
compile
(
r"""
(?P<quote>['"]) # the opening quotes
{prefix} # the prefix
.*? # everything else in the url
(?P=quote) # the first matching closing quote
"""
.
format
(
prefix
=
PREFIX
),
re
.
VERBOSE
)
PREFIX_LEN
=
len
(
PREFIX
)
def
replace
(
static_url
):
quote
=
static_url
[
0
]
url
=
staticfiles_storage
.
url
(
static_url
[
1
+
PREFIX_LEN
:
-
1
])
return
""
.
join
([
quote
,
url
,
quote
])
def
replace_urls
(
text
):
return
STATIC_PATTERN
.
sub
(
replace
,
text
)
rakefile
View file @
e8c4d1db
...
...
@@ -40,7 +40,7 @@ task :package do
set -x
chown -R makeitso:makeitso
#{
INSTALL_DIR_PATH
}
service gunicorn stop
rm -f
#{
LINK_PATH
}
ln -s
#{
INSTALL_DIR_PATH
}
#{
LINK_PATH
}
...
...
templates/main.html
View file @
e8c4d1db
...
...
@@ -23,8 +23,10 @@
</script>
<
%
block
name=
"headextra"
/>
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates -->
<script
type=
"text/javascript"
src=
"${static.url('js/mathjax-MathJax-c9db6ac/MathJax.js')}?config=TeX-AMS_HTML-full"
></script>
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates.
It can't be run through static.url because MathJax uses crazy url introspection to do lazy loading of
MathJax extension libraries -->
<script
type=
"text/javascript"
src=
"/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"
></script>
</head>
<body
class=
"<%block name="
bodyclass
"
/>
">
...
...
templates/problem.html
View file @
e8c4d1db
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<h2
class=
"problem-header"
>
${ problem['name'] }
% if problem['weight']:
: ${ problem['weight'] } points
...
...
@@ -5,7 +6,7 @@
</h2>
<section
class=
"problem"
>
${
problem['html']
}
${
static.replace_urls(problem['html'])
}
<section
class=
"action"
>
<input
type=
"hidden"
name=
"problem_id"
value=
"${ problem['name'] }"
>
...
...
templates/static_content.html
View file @
e8c4d1db
<
%!
from
staticfiles
.
storage
import
staticfiles_storage
from
pipeline_mako
import
compressed_css
,
compressed_js
from
static_replace
import
replace_urls
%
>
<
%
def
name=
'url(file)'
>
${staticfiles_storage.url(file)}
</
%
def>
<
%
def
name=
'css(group)'
>
${compressed_css(group)}
</
%
def>
<
%
def
name=
'js(group)'
>
${compressed_js(group)}
</
%
def>
<
%
def
name=
'replace_urls(text)'
>
${replace_urls(text)}
</
%
def>
urls.py
View file @
e8c4d1db
...
...
@@ -80,5 +80,3 @@ urlpatterns = patterns(*urlpatterns)
if
settings
.
DEBUG
:
urlpatterns
+=
staticfiles_urlpatterns
()
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