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
b549adf4
Commit
b549adf4
authored
Jan 12, 2016
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10623 from eduNEXT/fmo/wiki-support-for-microsites
WIP wiki support for microsite templates
parents
6f664838
f2a6a27e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
4 deletions
+36
-4
common/djangoapps/microsite_configuration/templatetags/microsite.py
+11
-0
common/djangoapps/microsite_configuration/tests/test_microsites.py
+7
-0
lms/startup.py
+15
-1
lms/templates/main_django.html
+3
-3
No files found.
common/djangoapps/microsite_configuration/templatetags/microsite.py
View file @
b549adf4
...
@@ -63,3 +63,14 @@ def microsite_css_overrides_file():
...
@@ -63,3 +63,14 @@ def microsite_css_overrides_file():
return
"<link href='{}' rel='stylesheet' type='text/css'>"
.
format
(
static
(
file_path
))
return
"<link href='{}' rel='stylesheet' type='text/css'>"
.
format
(
static
(
file_path
))
else
:
else
:
return
""
return
""
@register.filter
def
microsite_template_path
(
template_name
):
"""
Django template filter to apply template overriding to microsites.
The django_templates loader does not support the leading slash, therefore
it is stripped before returning.
"""
template_name
=
microsite
.
get_template_path
(
template_name
)
return
template_name
[
1
:]
if
template_name
[
0
]
==
'/'
else
template_name
common/djangoapps/microsite_configuration/tests/test_microsites.py
View file @
b549adf4
...
@@ -32,3 +32,10 @@ class MicroSiteTests(TestCase):
...
@@ -32,3 +32,10 @@ class MicroSiteTests(TestCase):
expected
=
u'my | less specific | Page | edX'
expected
=
u'my | less specific | Page | edX'
title
=
microsite
.
page_title_breadcrumbs_tag
(
None
,
*
crumbs
)
title
=
microsite
.
page_title_breadcrumbs_tag
(
None
,
*
crumbs
)
self
.
assertEqual
(
expected
,
title
)
self
.
assertEqual
(
expected
,
title
)
def
test_microsite_template_path
(
self
):
"""
When an unexistent path is passed to the filter, it should return the same path
"""
path
=
microsite
.
microsite_template_path
(
'footer.html'
)
self
.
assertEqual
(
"footer.html"
,
path
)
lms/startup.py
View file @
b549adf4
...
@@ -31,6 +31,9 @@ def run():
...
@@ -31,6 +31,9 @@ def run():
if
settings
.
FEATURES
.
get
(
'ENABLE_THIRD_PARTY_AUTH'
,
False
):
if
settings
.
FEATURES
.
get
(
'ENABLE_THIRD_PARTY_AUTH'
,
False
):
enable_third_party_auth
()
enable_third_party_auth
()
if
settings
.
FEATURES
.
get
(
'USE_MICROSITES'
,
False
):
enable_microsites_pre_startup
()
django
.
setup
()
django
.
setup
()
autostartup
()
autostartup
()
...
@@ -116,6 +119,18 @@ def enable_stanford_theme():
...
@@ -116,6 +119,18 @@ def enable_stanford_theme():
settings
.
LOCALE_PATHS
=
(
theme_root
/
'conf/locale'
,)
+
settings
.
LOCALE_PATHS
settings
.
LOCALE_PATHS
=
(
theme_root
/
'conf/locale'
,)
+
settings
.
LOCALE_PATHS
def
enable_microsites_pre_startup
():
"""
The TEMPLATE_ENGINE directory to search for microsite templates
in non-mako templates must be loaded before the django startup
"""
microsites_root
=
settings
.
MICROSITE_ROOT_DIR
microsite_config_dict
=
settings
.
MICROSITE_CONFIGURATION
if
microsite_config_dict
:
settings
.
DEFAULT_TEMPLATE_ENGINE
[
'DIRS'
]
.
append
(
microsites_root
)
def
enable_microsites
():
def
enable_microsites
():
"""
"""
Enable the use of microsites, which are websites that allow
Enable the use of microsites, which are websites that allow
...
@@ -151,7 +166,6 @@ def enable_microsites():
...
@@ -151,7 +166,6 @@ def enable_microsites():
# if we have any valid microsites defined, let's wire in the Mako and STATIC_FILES search paths
# if we have any valid microsites defined, let's wire in the Mako and STATIC_FILES search paths
if
microsite_config_dict
:
if
microsite_config_dict
:
settings
.
DEFAULT_TEMPLATE_ENGINE
[
'DIRS'
]
.
append
(
microsites_root
)
edxmako
.
paths
.
add_lookup
(
'main'
,
microsites_root
)
edxmako
.
paths
.
add_lookup
(
'main'
,
microsites_root
)
settings
.
STATICFILES_DIRS
.
insert
(
0
,
microsites_root
)
settings
.
STATICFILES_DIRS
.
insert
(
0
,
microsites_root
)
...
...
lms/templates/main_django.html
View file @
b549adf4
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
{% block headextra %}{% endblock %}
{% block headextra %}{% endblock %}
{% render_block "css" %}
{% render_block "css" %}
{% optional_include "head-extra.html" %}
{% optional_include "head-extra.html"
|microsite_template_path
%}
<meta
name=
"path_prefix"
content=
"{{EDX_ROOT_URL}}"
>
<meta
name=
"path_prefix"
content=
"{{EDX_ROOT_URL}}"
>
</head>
</head>
...
@@ -28,14 +28,14 @@
...
@@ -28,14 +28,14 @@
<div
class=
"window-wrap"
dir=
"${static.dir_rtl()}"
>
<div
class=
"window-wrap"
dir=
"${static.dir_rtl()}"
>
<a
class=
"nav-skip"
href=
"{% block nav_skip %}#content{% endblock %}"
>
{% trans "Skip to main content" %}
</a>
<a
class=
"nav-skip"
href=
"{% block nav_skip %}#content{% endblock %}"
>
{% trans "Skip to main content" %}
</a>
{% with course=request.course %}
{% with course=request.course %}
{% include "header.html" %}
{% include "header.html"
|microsite_template_path
%}
{% endwith %}
{% endwith %}
<div
class=
"content-wrapper"
id=
"content"
>
<div
class=
"content-wrapper"
id=
"content"
>
{% block body %}{% endblock %}
{% block body %}{% endblock %}
{% block bodyextra %}{% endblock %}
{% block bodyextra %}{% endblock %}
</div>
</div>
{% with course=request.course %}
{% with course=request.course %}
{% include "footer.html" %}
{% include "footer.html"
|microsite_template_path
%}
{% endwith %}
{% endwith %}
</div>
</div>
...
...
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