Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
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
configuration
Commits
9d029e23
Commit
9d029e23
authored
Oct 23, 2017
by
Daniel Clemente Laboreo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New feature: SIMPLETHEME_STATIC_FILES_URLS, to download static files from Internet
parent
205b5bce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
5 deletions
+52
-5
playbooks/roles/simple_theme/README.rst
+17
-4
playbooks/roles/simple_theme/defaults/main.yml
+13
-0
playbooks/roles/simple_theme/tasks/deploy.yml
+22
-1
No files found.
playbooks/roles/simple_theme/README.rst
View file @
9d029e23
...
...
@@ -2,10 +2,15 @@ Simple theme
############
This role allows you to deploy a basic theme on deploy time. The theme can be
customized via ansible variables. You can also change the contents of some pages.
customized via ansible variables in the following ways:
- to redefine SASS variables (like colors)
- to include some static files provided in a local directory (e.g. logo)
- to download some static files from URLs (e.g. logo, favicon)
- in addition the theme can be based on an existing theme from a repository
This role will be included by edxapp. The main use case involves deploying a
theme as part of deploying an instance.
theme as part of deploying an instance. The new theme will be enabled when
the instance starts.
Configuration
*************
...
...
@@ -21,7 +26,15 @@ Example: if you have a theme in https://github.com/open-craft/edx-theme/tree/har
- and EDXAPP_COMPREHENSIVE_THEME_VERSION: "harvard-dcex"
If you don't use a skeleton theme, the deployed theme will just contain the SASS
variables definitions you provide through the other variables.
variables definitions you provide through the other variables, and the static files
you provide. For simple changes like colors+logo+image this will be enough.
Static files (like logo and favicon) will be added from the following sources and in
the following order:
- If no skeleton theme nor static files are provided, the theme will have no static files
- If a skeleton theme was provided, its static files will be used
- Local files from SIMPLETHEME_STATIC_FILES_DIR will be copied, replacing previous ones
- Files from SIMPLETHEME_STATIC_FILES_URLS will be downloaded, replacing previous ones
Testing
*******
...
...
@@ -43,7 +56,7 @@ Example script to test this role, to be run from devstack, from "vagrant" user:
- export PYTHONUNBUFFERED=1
- source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate
- cd /edx/app/edx_ansible/edx_ansible/playbooks
- ansible-playbook -i localhost, -c local run_role.yml -e role=simple_theme -e configuration_version=master -e edx_platform_version=master -e EDXAPP_DEFAULT_SITE_THEME=mytheme2 -e '{"SIMPLETHEME_SASS_OVERRIDES": [{"variable": "main-color", "value":"#823456"}, {"variable": "action-primary-bg", "value":"$main-color"}]}' -e EDXAPP_COMPREHENSIVE_THEME_SOURCE_REPO="https://github.com/open-craft/edx-theme/" -e EDXAPP_COMPREHENSIVE_THEME_VERSION="harvard-dcex" -e edxapp_user=vagrant -e common_web_group=www-data -e SIMPLETHEME_ENABLE_DEPLOY=true -e '{"EDXAPP_COMPREHENSIVE_THEME_DIRS":["/edx/var/edxapp/themes"], "EDXAPP_ENABLE_COMPREHENSIVE_THEMING": true}'
- ansible-playbook -i localhost, -c local run_role.yml -e role=simple_theme -e configuration_version=master -e edx_platform_version=master -e EDXAPP_DEFAULT_SITE_THEME=mytheme2 -e '{"SIMPLETHEME_SASS_OVERRIDES": [{"variable": "main-color", "value":"#823456"}, {"variable": "action-primary-bg", "value":"$main-color"}]}' -e EDXAPP_COMPREHENSIVE_THEME_SOURCE_REPO="https://github.com/open-craft/edx-theme/" -e EDXAPP_COMPREHENSIVE_THEME_VERSION="harvard-dcex" -e edxapp_user=vagrant -e common_web_group=www-data -e SIMPLETHEME_ENABLE_DEPLOY=true -e '{"
SIMPLETHEME_STATIC_FILES_URLS": [{"url": "http://docs.ansible.com/ansible/latest/_static/images/logo_invert.png", "dest":"lms/static/images/logo.png"}, {"url": "http://docs.ansible.com/favicon.ico", "dest":"lms/static/images/favicon.ico"}]}' -e '{"
EDXAPP_COMPREHENSIVE_THEME_DIRS":["/edx/var/edxapp/themes"], "EDXAPP_ENABLE_COMPREHENSIVE_THEMING": true}'
Or, if you want to test the task as part of the deployment, change to role=edxapp,
...
...
playbooks/roles/simple_theme/defaults/main.yml
View file @
9d029e23
...
...
@@ -80,6 +80,19 @@ SIMPLETHEME_SASS_OVERRIDES: []
# SIMPLETHEME_STATIC_FILES_DIR: "{{ role_path }}/files/example_static_dir"
SIMPLETHEME_STATIC_FILES_DIR
:
"
"
# These files will be downloaded and included in the static directory after the
# files from SIMPLETHEME_STATIC_FILES_DIR have been copied.
# Local paths must be relative, e.g. "lms/static/images/favicon.ico"
# Example which downloads logo and favicon:
# SIMPLETHEME_STATIC_FILES_URLS:
# - url: http://docs.ansible.com/ansible/latest/_static/images/logo_invert.png
# dest: lms/static/images/logo.png
# - url: http://docs.ansible.com/favicon.ico
# dest: lms/static/images/favicon.ico
SIMPLETHEME_STATIC_FILES_URLS
:
[]
# This fragment will be inserted in _lms-overrides and will affect all pages
# Sample:
# SIMPLETHEME_EXTRA_SASS: |
...
...
playbooks/roles/simple_theme/tasks/deploy.yml
View file @
9d029e23
...
...
@@ -100,7 +100,7 @@
# Note: with_fileglob doesn't take directories, but with_filetree does.
-
block
:
-
name
:
Create directories for static files
-
name
:
Create directories for static files
to be copied
file
:
path
:
"
{{
simpletheme_folder
}}/{{
item.path
|
regex_replace('^([^/]+)/(.+)$','
\\
1/static/
\\
2')
}}"
state
:
directory
...
...
@@ -117,3 +117,24 @@
with_filetree
:
"
{{
SIMPLETHEME_STATIC_FILES_DIR
}}"
when
:
item.state != 'directory'
when
:
SIMPLETHEME_STATIC_FILES_DIR != ""
# Downloading remote files is done in two steps: create directorie + download each file.
# This step is done after the static files from SIMPLETHEME_STATIC_FILES_DIR have been
# copied, therefore remote files may overwrite the previously installed static files.
-
block
:
-
name
:
Create directories for static files to be downloaded
file
:
path
:
"
{{
simpletheme_folder
}}/{{
item.dest
|
regex_replace('/[^/]*$','')
}}"
state
:
directory
owner
:
"
{{
edxapp_user
}}"
group
:
"
{{
common_web_group
}}"
with_items
:
"
{{
SIMPLETHEME_STATIC_FILES_URLS
}}"
-
name
:
Download static files to be included in theme
get_url
:
url
:
"
{{
item.url
}}"
dest
:
"
{{
simpletheme_folder
}}/{{
item.dest
}}"
force
:
yes
owner
:
"
{{
edxapp_user
}}"
group
:
"
{{
common_web_group
}}"
with_items
:
"
{{
SIMPLETHEME_STATIC_FILES_URLS
}}"
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