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
8d69b10c
Commit
8d69b10c
authored
May 22, 2013
by
Nate Hardison
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1907 from edx/feature/nate/custom-header-footer
Add theming settings and simple base Sass preprocessing.
parents
d724223a
185ab4c3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
8 deletions
+106
-8
.gitignore
+1
-0
lms/envs/aws.py
+5
-0
lms/envs/common.py
+33
-2
lms/static/sass/application.scss.mako
+13
-0
rakefile
+8
-0
rakefiles/assets.rake
+46
-6
No files found.
.gitignore
View file @
8d69b10c
...
@@ -26,6 +26,7 @@ Gemfile.lock
...
@@ -26,6 +26,7 @@ Gemfile.lock
conf/locale/en/LC_MESSAGES/*.po
conf/locale/en/LC_MESSAGES/*.po
!messages.po
!messages.po
lms/static/sass/*.css
lms/static/sass/*.css
lms/static/sass/application.scss
cms/static/sass/*.css
cms/static/sass/*.css
lms/lib/comment_client/python
lms/lib/comment_client/python
nosetests.xml
nosetests.xml
...
...
lms/envs/aws.py
View file @
8d69b10c
...
@@ -114,6 +114,11 @@ DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBA
...
@@ -114,6 +114,11 @@ DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBA
ADMINS
=
ENV_TOKENS
.
get
(
'ADMINS'
,
ADMINS
)
ADMINS
=
ENV_TOKENS
.
get
(
'ADMINS'
,
ADMINS
)
SERVER_EMAIL
=
ENV_TOKENS
.
get
(
'SERVER_EMAIL'
,
SERVER_EMAIL
)
SERVER_EMAIL
=
ENV_TOKENS
.
get
(
'SERVER_EMAIL'
,
SERVER_EMAIL
)
#Theme overrides
THEME_NAME
=
ENV_TOKENS
.
get
(
'THEME_NAME'
,
None
)
if
not
THEME_NAME
is
None
:
enable_theme
(
THEME_NAME
)
#Timezone overrides
#Timezone overrides
TIME_ZONE
=
ENV_TOKENS
.
get
(
'TIME_ZONE'
,
TIME_ZONE
)
TIME_ZONE
=
ENV_TOKENS
.
get
(
'TIME_ZONE'
,
TIME_ZONE
)
...
...
lms/envs/common.py
View file @
8d69b10c
...
@@ -110,6 +110,9 @@ MITX_FEATURES = {
...
@@ -110,6 +110,9 @@ MITX_FEATURES = {
# Enable URL that shows information about the status of variuous services
# Enable URL that shows information about the status of variuous services
'ENABLE_SERVICE_STATUS'
:
False
,
'ENABLE_SERVICE_STATUS'
:
False
,
# Toggle to indicate use of a custom theme
'USE_CUSTOM_THEME'
:
False
}
}
# Used for A/B testing
# Used for A/B testing
...
@@ -167,12 +170,12 @@ MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates',
...
@@ -167,12 +170,12 @@ MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates',
# This is where Django Template lookup is defined. There are a few of these
# This is where Django Template lookup is defined. There are a few of these
# still left lying around.
# still left lying around.
TEMPLATE_DIRS
=
(
TEMPLATE_DIRS
=
[
PROJECT_ROOT
/
"templates"
,
PROJECT_ROOT
/
"templates"
,
COMMON_ROOT
/
'templates'
,
COMMON_ROOT
/
'templates'
,
COMMON_ROOT
/
'lib'
/
'capa'
/
'capa'
/
'templates'
,
COMMON_ROOT
/
'lib'
/
'capa'
/
'capa'
/
'templates'
,
COMMON_ROOT
/
'djangoapps'
/
'pipeline_mako'
/
'templates'
,
COMMON_ROOT
/
'djangoapps'
/
'pipeline_mako'
/
'templates'
,
)
]
TEMPLATE_CONTEXT_PROCESSORS
=
(
TEMPLATE_CONTEXT_PROCESSORS
=
(
'django.core.context_processors.request'
,
'django.core.context_processors.request'
,
...
@@ -714,3 +717,31 @@ MKTG_URL_LINK_MAP = {
...
@@ -714,3 +717,31 @@ MKTG_URL_LINK_MAP = {
'HONOR'
:
'honor'
,
'HONOR'
:
'honor'
,
'PRIVACY'
:
'privacy_edx'
,
'PRIVACY'
:
'privacy_edx'
,
}
}
############################### THEME ################################
def
enable_theme
(
theme_name
):
"""
Enable the settings for a custom theme, whose files should be stored
in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford).
The THEME_NAME setting should be configured separately since it can't
be set here (this function closes too early). An idiom for doing this
is:
THEME_NAME = "stanford"
enable_theme(THEME_NAME)
"""
MITX_FEATURES
[
'USE_CUSTOM_THEME'
]
=
True
# Calculate the location of the theme's files
theme_root
=
ENV_ROOT
/
"themes"
/
theme_name
# Include the theme's templates in the template search paths
TEMPLATE_DIRS
.
append
(
theme_root
/
'templates'
)
MAKO_TEMPLATES
[
'main'
]
.
append
(
theme_root
/
'templates'
)
# Namespace the theme's static files to 'themes/<theme_name>' to
# avoid collisions with default edX static files
STATICFILES_DIRS
.
append
((
u'themes/
%
s'
%
theme_name
,
theme_root
/
'static'
))
lms/static/sass/application.scss
→
lms/static/sass/application.scss
.mako
View file @
8d69b10c
...
@@ -36,3 +36,16 @@
...
@@ -36,3 +36,16 @@
@import 'news';
@import 'news';
@import 'shame';
@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 not env['THEME_NAME'] is None:
// import theme's Sass overrides
@import '${env['THEME_NAME']}'
% endif
rakefile
View file @
8d69b10c
require
'json'
require
'rake/clean'
require
'rake/clean'
require
'./rakefiles/helpers.rb'
require
'./rakefiles/helpers.rb'
...
@@ -7,6 +8,13 @@ end
...
@@ -7,6 +8,13 @@ end
# Build Constants
# Build Constants
REPO_ROOT
=
File
.
dirname
(
__FILE__
)
REPO_ROOT
=
File
.
dirname
(
__FILE__
)
ENV_ROOT
=
File
.
dirname
(
REPO_ROOT
)
REPORT_DIR
=
File
.
join
(
REPO_ROOT
,
"reports"
)
REPORT_DIR
=
File
.
join
(
REPO_ROOT
,
"reports"
)
# Environment constants
SERVICE_VARIANT
=
ENV
[
'SERVICE_VARIANT'
]
CONFIG_PREFIX
=
SERVICE_VARIANT
?
SERVICE_VARIANT
+
"."
:
""
ENV_FILE
=
File
.
join
(
ENV_ROOT
,
CONFIG_PREFIX
+
"env.json"
)
ENV_TOKENS
=
File
.
exists?
(
ENV_FILE
)
?
JSON
.
parse
(
File
.
read
(
ENV_FILE
))
:
{}
task
:default
=>
[
:test
,
:pep8
,
:pylint
]
task
:default
=>
[
:test
,
:pep8
,
:pylint
]
rakefiles/assets.rake
View file @
8d69b10c
# Theming constants
THEME_NAME
=
ENV_TOKENS
[
'THEME_NAME'
]
USE_CUSTOM_THEME
=
!
(
THEME_NAME
.
nil?
||
THEME_NAME
.
empty?
)
if
USE_CUSTOM_THEME
THEME_ROOT
=
File
.
join
(
ENV_ROOT
,
"themes"
,
THEME_NAME
)
THEME_SASS
=
File
.
join
(
THEME_ROOT
,
"static"
,
"sass"
)
end
# Run the specified file through the Mako templating engine, providing
# the ENV_TOKENS to the templating context.
def
preprocess_with_mako
(
filename
)
# simple command-line invocation of Mako engine
mako
=
"from mako.template import Template;"
+
"print Template(filename=
\"
#{
filename
}
\"
)"
+
# Total hack. It works because a Python dict literal has
# the same format as a JSON object.
".render(env=
#{
ENV_TOKENS
.
to_json
}
);"
# strip off the .mako extension
output_filename
=
filename
.
chomp
(
File
.
extname
(
filename
))
# just pipe from stdout into the new file
File
.
open
(
output_filename
,
'w'
)
do
|
file
|
file
.
write
(
`python -c '
#{
mako
}
'`
)
end
end
def
xmodule_cmd
(
watch
=
false
,
debug
=
false
)
def
xmodule_cmd
(
watch
=
false
,
debug
=
false
)
xmodule_cmd
=
'xmodule_assets common/static/xmodule'
xmodule_cmd
=
'xmodule_assets common/static/xmodule'
...
@@ -32,10 +58,17 @@ def coffee_cmd(watch=false, debug=false)
...
@@ -32,10 +58,17 @@ def coffee_cmd(watch=false, debug=false)
end
end
def
sass_cmd
(
watch
=
false
,
debug
=
false
)
def
sass_cmd
(
watch
=
false
,
debug
=
false
)
sass_load_paths
=
[
"./common/static/sass"
]
sass_watch_paths
=
[
"*/static"
]
if
USE_CUSTOM_THEME
sass_load_paths
<<
THEME_SASS
sass_watch_paths
<<
THEME_SASS
end
"sass
#{
debug
?
'--debug-info'
:
'--style compressed'
}
"
+
"sass
#{
debug
?
'--debug-info'
:
'--style compressed'
}
"
+
"--load-path
./common/static/sass
"
+
"--load-path
#{
sass_load_paths
.
join
(
' '
)
}
"
+
"--require ./common/static/sass/bourbon/lib/bourbon.rb "
+
"--require ./common/static/sass/bourbon/lib/bourbon.rb "
+
"
#{
watch
?
'--watch'
:
'--update'
}
*/static
"
"
#{
watch
?
'--watch'
:
'--update'
}
#{
sass_watch_paths
.
join
(
' '
)
}
"
end
end
desc
"Compile all assets"
desc
"Compile all assets"
...
@@ -46,6 +79,13 @@ namespace :assets do
...
@@ -46,6 +79,13 @@ namespace :assets do
desc
"Compile all assets in debug mode"
desc
"Compile all assets in debug mode"
multitask
:debug
multitask
:debug
desc
"Preprocess all static assets that have the .mako extension"
task
:preprocess
do
# Run assets through the Mako templating engine. Right now we
# just hardcode the asset filenames.
preprocess_with_mako
(
"lms/static/sass/application.scss.mako"
)
end
desc
"Watch all assets for changes and automatically recompile"
desc
"Watch all assets for changes and automatically recompile"
task
:watch
=>
'assets:_watch'
do
task
:watch
=>
'assets:_watch'
do
puts
"Press ENTER to terminate"
.
red
puts
"Press ENTER to terminate"
.
red
...
@@ -54,9 +94,9 @@ namespace :assets do
...
@@ -54,9 +94,9 @@ namespace :assets do
{
:xmodule
=>
:install_python_prereqs
,
{
:xmodule
=>
:install_python_prereqs
,
:coffee
=>
:install_node_prereqs
,
:coffee
=>
:install_node_prereqs
,
:sass
=>
:install_ruby_prereqs
}.
each_pair
do
|
asset_type
,
prereq_task
|
:sass
=>
[
:install_ruby_prereqs
,
:preprocess
]}.
each_pair
do
|
asset_type
,
prereq_tasks
|
desc
"Compile all
#{
asset_type
}
assets"
desc
"Compile all
#{
asset_type
}
assets"
task
asset_type
=>
prereq_task
do
task
asset_type
=>
prereq_task
s
do
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
false
,
debug
=
false
)
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
false
,
debug
=
false
)
if
cmd
.
kind_of?
(
Array
)
if
cmd
.
kind_of?
(
Array
)
cmd
.
each
{
|
c
|
sh
(
c
)}
cmd
.
each
{
|
c
|
sh
(
c
)}
...
@@ -71,7 +111,7 @@ namespace :assets do
...
@@ -71,7 +111,7 @@ namespace :assets do
namespace
asset_type
do
namespace
asset_type
do
desc
"Compile all
#{
asset_type
}
assets in debug mode"
desc
"Compile all
#{
asset_type
}
assets in debug mode"
task
:debug
=>
prereq_task
do
task
:debug
=>
prereq_task
s
do
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
false
,
debug
=
true
)
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
false
,
debug
=
true
)
sh
(
cmd
)
sh
(
cmd
)
end
end
...
@@ -82,7 +122,7 @@ namespace :assets do
...
@@ -82,7 +122,7 @@ namespace :assets do
$stdin
.
gets
$stdin
.
gets
end
end
task
:_watch
=>
prereq_task
do
task
:_watch
=>
prereq_task
s
do
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
true
,
debug
=
true
)
cmd
=
send
(
asset_type
.
to_s
+
"_cmd"
,
watch
=
true
,
debug
=
true
)
if
cmd
.
kind_of?
(
Array
)
if
cmd
.
kind_of?
(
Array
)
cmd
.
each
{
|
c
|
background_process
(
c
)}
cmd
.
each
{
|
c
|
background_process
(
c
)}
...
...
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