Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
426e9e0
Enable theming in base LMS template
natehardison May 31, 2013
f243dd2
Use a setting for the favicon path
natehardison May 31, 2013
708db25
Inject theming hooks into navigation bar
natehardison May 31, 2013
08421bd
Add theming hooks to (old) landing page
natehardison May 31, 2013
f004512
Add the `PLATFORM_NAME` setting for display config
natehardison May 31, 2013
82d5dbd
Theme the base registration page
natehardison Jun 1, 2013
bd02fcd
Theme the login page
natehardison Jun 1, 2013
ebe991c
Don't return any news if a theme is enabled
natehardison Jun 1, 2013
3949674
Theme the courseware dashboard
natehardison Jun 1, 2013
606e059
Theme the individual course about pages
natehardison Jun 1, 2013
836d902
Theme the authenticated index view
natehardison Jun 1, 2013
dbcee9a
Fix forgot password modal for theming
natehardison Jun 1, 2013
be89d40
Add setting for technical support email config
natehardison Jun 1, 2013
f4e7a4f
Theme static error pages
natehardison Jun 1, 2013
62bbff1
Add settings for contact and bugs emails
natehardison Jun 1, 2013
94d10d5
Use the contact email setting instead of if/else
natehardison Jun 1, 2013
9ed5111
Use bugs email from settings, not hardcoded value
natehardison Jun 1, 2013
b0c6a7e
Use settings in LMS emails, not hardcoded values
natehardison Jun 1, 2013
30457de
Make email change templates use main layout
natehardison Jun 1, 2013
e96ca11
Stanfordize LMS emails
natehardison Jun 1, 2013
0bedf62
Move theme import right after variables import
natehardison Jun 1, 2013
52123d9
Rewrite the main course.scss file as well
natehardison Jun 1, 2013
1216f3e
Adjust available routes based on theme presence
natehardison Jun 1, 2013
efee0ca
Use default `PLATFORM_NAME` in AWS settings
natehardison Jun 3, 2013
64866ec
Override `MKTG_URL_LINK_MAP`, don't delete keys
natehardison Jun 3, 2013
c997fc5
Change `if ... is not None` to `if ...`
natehardison Jun 3, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ conf/locale/en/LC_MESSAGES/*.po
!messages.po
lms/static/sass/*.css
lms/static/sass/application.scss
lms/static/sass/course.scss
cms/static/sass/*.css
lms/lib/comment_client/python
nosetests.xml
Expand Down
4 changes: 3 additions & 1 deletion common/djangoapps/mitxmako/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def marketing_link(name):
return settings.MKTG_URLS.get('ROOT') + settings.MKTG_URLS.get(name)
# only link to the old pages when the marketing site isn't on
elif not settings.MITX_FEATURES.get('ENABLE_MKTG_SITE') and name in link_map:
return reverse(link_map[name])
# don't try to reverse disabled marketing links
if link_map[name] is not None:
return reverse(link_map[name])
else:
log.warning("Cannot find corresponding link for name: {name}".format(name=name))
return '#'
Expand Down
4 changes: 4 additions & 0 deletions common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,10 @@ def accept_name_change(request):
def _get_news(top=None):
"Return the n top news items on settings.RSS_URL"

# Don't return anything if we're in a themed site
if settings.MITX_FEATURES["USE_CUSTOM_THEME"]:
return None

feed_data = cache.get("students_index_rss_feed_data")
if feed_data is None:
if hasattr(settings, 'RSS_URL'):
Expand Down
10 changes: 10 additions & 0 deletions lms/envs/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file:
ENV_TOKENS = json.load(env_file)

PLATFORM_NAME = ENV_TOKENS.get('PLATFORM_NAME', PLATFORM_NAME)

SITE_NAME = ENV_TOKENS['SITE_NAME']
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')

Expand All @@ -113,11 +115,19 @@
DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBACK_EMAIL)
ADMINS = ENV_TOKENS.get('ADMINS', ADMINS)
SERVER_EMAIL = ENV_TOKENS.get('SERVER_EMAIL', SERVER_EMAIL)
TECH_SUPPORT_EMAIL = ENV_TOKENS.get('TECH_SUPPORT_EMAIL', TECH_SUPPORT_EMAIL)
CONTACT_EMAIL = ENV_TOKENS.get('CONTACT_EMAIL', CONTACT_EMAIL)
BUGS_EMAIL = ENV_TOKENS.get('BUGS_EMAIL', BUGS_EMAIL)

#Theme overrides
THEME_NAME = ENV_TOKENS.get('THEME_NAME', None)
if not THEME_NAME is None:
enable_theme(THEME_NAME)
FAVICON_PATH = 'themes/%s/images/favicon.ico' % THEME_NAME

# Marketing link overrides
for key, value in ENV_TOKENS.get('MKTG_URL_LINK_MAP', {}).items():
MKTG_URL_LINK_MAP[key] = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, but FWIW, this can just be be written as MKTG_URL_LINK_MAP.update(ENV_TOKENS.get('MKTG_URL_LINK_MAP', {}))


#Timezone overrides
TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE)
Expand Down
8 changes: 8 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from .discussionsettings import *

################################### FEATURES ###################################
# The display name of the platform to be used in templates/emails/etc.
PLATFORM_NAME = "edX"

COURSEWARE_ENABLED = True
ENABLE_JASMINE = False

Expand Down Expand Up @@ -315,6 +318,9 @@
DEFAULT_FROM_EMAIL = 'registration@edx.org'
DEFAULT_FEEDBACK_EMAIL = 'feedback@edx.org'
SERVER_EMAIL = 'devops@edx.org'
TECH_SUPPORT_EMAIL = 'technical@edx.org'
CONTACT_EMAIL = 'info@edx.org'
BUGS_EMAIL = 'bugs@edx.org'
ADMINS = (
('edX Admins', 'admin@edx.org'),
)
Expand All @@ -330,6 +336,8 @@
PROJECT_ROOT / "static",
]

FAVICON_PATH = 'images/favicon.ico'

# Locale/Internationalization
TIME_ZONE = 'America/New_York' # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html
Expand Down
27 changes: 14 additions & 13 deletions lms/static/sass/application.scss.mako
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
@import 'base/font_face';
@import 'base/mixins';
@import 'base/variables';

## THEMING
## -------
## Set up this file to import an edX theme library if the environment
## indicates that a theme should be used. The assumption is that the
## theme resides outside of this main edX repository, in a directory
## called themes/<theme-name>/, with its base Sass file in
## themes/<theme-name>/static/sass/_<theme-name>.scss. That one entry
## point can be used to @import in as many other things as needed.
% if env.get('THEME_NAME') is not None:
// import theme's Sass overrides
@import '${env.get('THEME_NAME')}';
% endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize the env var is part of the hackery that is preprocess_with_mako, but it'd be nice if we eventually pass a theme var in the context so that it reads like:

% if theme:
    @import '${theme}';
% endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. In #5, I set up a Django management command that will pass in some whitelisted settings. This really depends on how @cpennington wants to implement the Django settings context processor that he introduced.


@import 'base/base';
@import 'base/extends';
@import 'base/animations';
Expand Down Expand Up @@ -36,16 +50,3 @@
@import 'news';

@import 'shame';

## THEMING
## -------
## Set up this file to import an edX theme library if the environment
## indicates that a theme should be used. The assumption is that the
## theme resides outside of this main edX repository, in a directory
## called themes/<theme-name>/, with its base Sass file in
## themes/<theme-name>/static/sass/_<theme-name>.scss. That one entry
## point can be used to @import in as many other things as needed.
% if env.get('THEME_NAME') is not None:
// import theme's Sass overrides
@import '${env.get('THEME_NAME')}'
% endif
14 changes: 14 additions & 0 deletions lms/static/sass/course.scss → lms/static/sass/course.scss.mako
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
@import 'base/font_face';
@import 'base/mixins';
@import 'base/variables';

## THEMING
## -------
## Set up this file to import an edX theme library if the environment
## indicates that a theme should be used. The assumption is that the
## theme resides outside of this main edX repository, in a directory
## called themes/<theme-name>/, with its base Sass file in
## themes/<theme-name>/static/sass/_<theme-name>.scss. That one entry
## point can be used to @import in as many other things as needed.
% if env.get('THEME_NAME') is not None:
// import theme's Sass overrides
@import '${env.get('THEME_NAME')}';
% endif

@import 'base/base';
@import 'base/extends';
@import 'base/animations';
Expand Down
7 changes: 6 additions & 1 deletion lms/templates/course.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%namespace name='static' file='static_content.html'/>
<%namespace file='main.html' import="stanford_theme_enabled"/>
<%!
from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section
Expand All @@ -24,7 +25,11 @@ <h2><span class="course-number">${course.number}</span> ${get_course_about_secti
<p>${get_course_about_section(course, 'short_description')}</p>
</div>
<div class="bottom">
<a href="${reverse('university_profile', args=[course.org])}" class="university">${get_course_about_section(course, 'university')}</a>
% if stanford_theme_enabled():
<span class="university">${get_course_about_section(course, 'university')}</span>
% else:
<a href="${reverse('university_profile', args=[course.org])}" class="university">${get_course_about_section(course, 'university')}</a>
% endif
<span class="start-date">${course.start_date_text}</span>
</div>
</section>
Expand Down
41 changes: 31 additions & 10 deletions lms/templates/courseware/course_about.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<%inherit file="../main.html" />

<%block name="headextra">
<%include file="../google_analytics.html" />
% if self.theme_enabled():
<%include file="../theme-google-analytics.html" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sefk had a good question about why I prefixed the theme template file (and all theme templates, actually) with theme-. The reason is that in some cases, we want the ability for theme templates to inherit from the base (edX default) templates. If we just plopped the theme templates into the TEMPLATE_DIRS search path ahead of the edX templates, (and didn't use a theme- prefix) then we'd lose this ability as the template lookup would only find the theme templates.

What would be really nice would be a way to namespace the theme template files, just like you can do with static files. The way to do this right now would be to have a theme directory structure like themes/<theme-name>/templates/theme/<theme-name>/, which sucks. I guess you could probably also hack it with symlinks, but that's nasty too.

% else:
<%include file="../google_analytics.html" />
% endif
</%block>

<%block name="js_extra">
Expand Down Expand Up @@ -46,7 +50,12 @@
<div class="table">
<section class="intro">
<hgroup>
<h1>${course.number}: ${get_course_about_section(course, "title")}<a href="${reverse('university_profile', args=[course.org])}">${get_course_about_section(course, "university")}</a></h1>
<h1>
${course.number}: ${get_course_about_section(course, "title")}
% if not self.theme_enabled():
<a href="${reverse('university_profile', args=[course.org])}">${get_course_about_section(course, "university")}</a>
% endif
</h1>
</hgroup>

<div class="main-cta">
Expand Down Expand Up @@ -105,14 +114,26 @@ <h1>${course.number}: ${get_course_about_section(course, "title")}<a href="${rev
<header>
<div class="social-sharing">
<div class="sharing-message">Share with friends and family!</div>
<a href="http://twitter.com/intent/tweet?text=I+just+registered+for+${course.number}+${get_course_about_section(course, 'title')}+through+@edxonline:+http://www.edx.org${reverse('about_course', args=[course.id])}" class="share">
<img src="${static.url('images/social/twitter-sharing.png')}">
</a>
<a href="http://www.facebook.com/EdxOnline" class="share"> <img src="${static.url('images/social/facebook-sharing.png')}">
</a>
<a href="mailto:?subject=Take%20a%20course%20with%20edX%20online&body=I%20just%20registered%20for%20${course.number}%20${get_course_about_section(course, 'title')}%20through%20edX:+http://edx.org/${reverse('about_course', args=[course.id])}" class="share">
<img src="${static.url('images/social/email-sharing.png')}">
</a>
## TODO: this should probably be an overrideable block,
## or something allowing themes to do whatever they
## want here (and on this whole page, really).
% if self.stanford_theme_enabled():
<a href="http://twitter.com/intent/tweet?text=I+just+registered+for+${course.number}+${get_course_about_section(course, 'title')}!+(http://class.stanford.edu)" class="share">
<img src="${static.url('images/social/twitter-sharing.png')}">
</a>
<a href="mailto:?subject=Take%20a%20course%20at%20Stanford%20online!&body=I%20just%20registered%20for%20${course.number}%20${get_course_about_section(course, 'title')}+(http://class.stanford.edu)" class="share">
<img src="${static.url('images/social/email-sharing.png')}">
</a>
% else:
<a href="http://twitter.com/intent/tweet?text=I+just+registered+for+${course.number}+${get_course_about_section(course, 'title')}+through+@edxonline:+http://www.edx.org${reverse('about_course', args=[course.id])}" class="share">
<img src="${static.url('images/social/twitter-sharing.png')}">
</a>
<a href="http://www.facebook.com/EdxOnline" class="share"> <img src="${static.url('images/social/facebook-sharing.png')}">
</a>
<a href="mailto:?subject=Take%20a%20course%20with%20edX%20online&body=I%20just%20registered%20for%20${course.number}%20${get_course_about_section(course, 'title')}%20through%20edX:+http://edx.org/${reverse('about_course', args=[course.id])}" class="share">
<img src="${static.url('images/social/email-sharing.png')}">
</a>
% endif
</div>
</header>

Expand Down
14 changes: 11 additions & 3 deletions lms/templates/courseware/courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
<%block name="title"><title>Courses</title></%block>

<section class="find-courses">
<header class="search" style="background: url('/static/images/homepage-bg.jpg')">
<header class="search">
<div class="inner-wrapper main-search">
<hgroup>
<div class="logo">
<img src="${static.url('images/edx_bw.png')}" />
% if self.stanford_theme_enabled():
<img src="${static.url('themes/stanford/images/seal.png')}" />
% else:
<img src="${static.url('images/edx_bw.png')}" />
% endif
</div>
<h2>Explore free courses from leading universities.</h2>
% if self.stanford_theme_enabled():
<h2>Explore free courses from Stanford University.</h2>
% else:
<h2>Explore free courses from leading universities.</h2>
% endif
</hgroup>
</div>
</header>
Expand Down
8 changes: 5 additions & 3 deletions lms/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ <h1 class="user-name">${ user.username }</h1>
</ul>
</section>

## `news` should be `None` whenever a non-edX theme is enabled:
## see common/djangoapps/student/views.py#_get_news
%if news:
<article class="news-carousel">
<header>
Expand Down Expand Up @@ -292,7 +294,7 @@ <h3>
${"{0:.0f}%".format(float(course.lowest_passing_grade)*100)}</span>.
% elif cert_status['status'] == 'restricted':
<p class="message-copy">
Your certificate is being held pending confirmation that the issuance of your certificate is in compliance with strict U.S. embargoes on Iran, Cuba, Syria and Sudan. If you think our system has mistakenly identified you as being connected with one of those countries, please let us know by contacting <a class="contact-link" href="mailto:info@edx.org">info@edx.org</a>.
Your certificate is being held pending confirmation that the issuance of your certificate is in compliance with strict U.S. embargoes on Iran, Cuba, Syria and Sudan. If you think our system has mistakenly identified you as being connected with one of those countries, please let us know by contacting <a class="contact-link" href="mailto:${settings.CONTACT_EMAIL}">${settings.CONTACT_EMAIL}</a>.
</p>
% endif
</p>
Expand Down Expand Up @@ -449,11 +451,11 @@ <h2>Change your name</h2>
<div id="change_name_body">
<form id="change_name_form">
<div id="change_name_error" class="modal-form-error"> </div>
<p>To uphold the credibility of edX certificates, all name changes will be logged and recorded.</p>
<p>To uphold the credibility of ${settings.PLATFORM_NAME} certificates, all name changes will be logged and recorded.</p>
<br/>
<fieldset>
<div class="input-group">
<label>Enter your desired full name, as it will appear on the edX certificates: </label>
<label>Enter your desired full name, as it will appear on the ${settings.PLATFORM_NAME} certificates: </label>
<input id="new_name_field" value="" type="text" />
<label>Reason for name change:</label>
<textarea id="name_rationale_field" value=""></textarea>
Expand Down
14 changes: 12 additions & 2 deletions lms/templates/email_change_failed.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<h1>E-mail change failed.</h1>
<%inherit file="main.html" />

<p>We were unable to send a confirmation email to ${email}</p>
<section class="container activation">

<section class="message">
<h1 class="invalid">E-mail change failed</h1>
<hr class="horizontal-divider">

<p>We were unable to send a confirmation email to ${email}</p>

<p>Go back to the <a href="/">home page</a>.</p>
</section>
</section>
13 changes: 11 additions & 2 deletions lms/templates/email_change_successful.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<h1>E-mail change successful!</h1>
<%! from django.core.urlresolvers import reverse %>
<%inherit file="main.html" />

<p>You should see your new email in your <a href="/dashboard">dashboard</a>.</p>
<section class="container activation">

<section class="message">
<h1 class="valid">E-mail change successful!</h1>
<hr class="horizontal-divider">

<p>You should see your new email in your <a href="${reverse('dashboard')}">dashboard</a>.</p>
</section>
</section>
14 changes: 12 additions & 2 deletions lms/templates/email_exists.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<h1> Could not change e-mail </h1>
<%inherit file="main.html" />

An account with the new e-mail address already exists. Sorry.
<section class="container activation">

<section class="message">
<h1 class="invalid">E-mail change failed</h1>
<hr class="horizontal-divider">

<p>An account with the new e-mail address already exists.</p>

<p>Go back to the <a href="/">home page</a>.</p>
</section>
</section>
23 changes: 17 additions & 6 deletions lms/templates/emails/activation_email.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
Thank you for signing up for edX! To activate your account,
please copy and paste this address into your web browser's
address bar:
<%namespace file="../main.html" import="stanford_theme_enabled" />

Thank you for signing up for ${settings.PLATFORM_NAME}! To activate
your account, please copy and paste this address into your web
browser's address bar:

% if is_secure:
https://${ site }/activate/${ key }
% else:
http://${ site }/activate/${ key }
% endif

If you didn't request this, you don't need to do anything; you won't
receive any more email from us. Please do not reply to this e-mail; if
you require assistance, check the help section of the edX web site.
## Temporary hack until we develop a better way to adjust language
% if stanford_theme_enabled():
If you didn't request this, you don't need to do anything; you won't
receive any more email from us. Please do not reply to this e-mail;
if you require assistance, check the about section of the
${settings.PLATFORM_NAME} Courses web site.
% else:
If you didn't request this, you don't need to do anything; you won't
receive any more email from us. Please do not reply to this e-mail;
if you require assistance, check the help section of the
${settings.PLATFORM_NAME} web site.
% endif
2 changes: 1 addition & 1 deletion lms/templates/emails/activation_email_subject.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Your account for edX
Your account for ${settings.PLATFORM_NAME}
25 changes: 19 additions & 6 deletions lms/templates/emails/confirm_email_change.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
<%! from django.core.urlresolvers import reverse %>
This is to confirm that you changed the e-mail associated with edX
from ${old_email} to ${new_email}. If you did not make this request,
please contact us immediately. Contact information is listed at:
<%namespace file="../main.html" import="stanford_theme_enabled" />
## Again, ugly hack that needs to be changed
## TODO: this probably needs better formatting to look nice in an
## email client (Mako leaves awkward whitespace)
% if stanford_theme_enabled():
This is to confirm that you changed the e-mail associated with
${settings.PLATFORM_NAME} from ${old_email} to ${new_email}. If you
did not make this request, please contact us at

% if is_secure:
https://${ site }${reverse('contact')}
${settings.CONTACT_EMAIL}
% else:
http://${ site }${reverse('contact')}
This is to confirm that you changed the e-mail associated with
${settings.PLATFORM_NAME} from ${old_email} to ${new_email}. If you
did not make this request, please contact us immediately. Contact
information is listed at:

% if is_secure:
https://${ site }${reverse('contact')}
% else:
http://${ site }${reverse('contact')}
% endif
% endif

We keep a log of old e-mails, so if this request was unintentional, we
Expand Down
Loading