customization: Serve static files from customization directory

- Static files are directly served by the CherryPy web server.
- .gitignore file placed as a placeholder to be able to commit the directory

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-09-28 11:04:21 +05:30 committed by James Valleroy
parent 8c89756b63
commit 9721eeac2b
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
6 changed files with 26 additions and 4 deletions

View File

@ -7,6 +7,7 @@ log_dir = /var/log/plinth
server_dir = /plinth
actions_dir = /usr/share/plinth/actions
doc_dir = /usr/share/doc/plinth
custom_static_dir = /var/www/plinth/custom/static
# file locations
store_file = %(data_dir)s/plinth.sqlite3

View File

@ -0,0 +1 @@
themes/default/

View File

@ -0,0 +1,5 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -7,6 +7,7 @@ log_dir = %(file_root)s/data/var/log/plinth
server_dir = /plinth
actions_dir = %(file_root)s/actions
doc_dir = %(file_root)s/doc
custom_static_dir = %(file_root)s/data/var/www/plinth/custom/static
# file locations
store_file = %(data_dir)s/plinth.sqlite3

View File

@ -112,6 +112,19 @@ def setup_server():
logger.debug('Serving static directory %s on %s', static_dir,
django.conf.settings.STATIC_URL)
custom_static_dir = cfg.custom_static_dir
custom_static_url = '/plinth/custom/static'
config = {
'/': {
'tools.staticdir.root': custom_static_dir,
'tools.staticdir.on': True,
'tools.staticdir.dir': '.'
}
}
cherrypy.tree.mount(None, custom_static_url, config)
logger.debug('Serving custom static directory %s on %s', custom_static_dir,
custom_static_url)
js_dir = '/usr/share/javascript'
js_url = '/javascript'
config = {

View File

@ -26,6 +26,7 @@ root = None
file_root = None
config_dir = None
data_dir = None
custom_static_dir = None
store_file = None
actions_dir = None
doc_dir = None
@ -81,10 +82,9 @@ def read(config_path=None, root_directory=None):
global config_file # pylint: disable-msg=invalid-name,global-statement
config_file = config_path
parser = configparser.ConfigParser(
defaults={
'root': os.path.realpath(root_directory),
})
parser = configparser.ConfigParser(defaults={
'root': os.path.realpath(root_directory),
})
parser.read(config_file)
config_items = (
@ -92,6 +92,7 @@ def read(config_path=None, root_directory=None):
('Path', 'file_root', 'string'),
('Path', 'config_dir', 'string'),
('Path', 'data_dir', 'string'),
('Path', 'custom_static_dir', 'string'),
('Path', 'store_file', 'string'),
('Path', 'actions_dir', 'string'),
('Path', 'doc_dir', 'string'),