mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Allow placing templates inside module directories
This commit is contained in:
parent
4b44741c68
commit
a54672ae01
25
plinth.py
25
plinth.py
@ -89,6 +89,26 @@ def load_modules():
|
|||||||
else:
|
else:
|
||||||
cfg.log("skipping %s" % name)
|
cfg.log("skipping %s" % name)
|
||||||
|
|
||||||
|
|
||||||
|
def get_template_directories():
|
||||||
|
"""Return the list of template directories"""
|
||||||
|
directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
core_directory = os.path.join(directory, 'templates')
|
||||||
|
|
||||||
|
directories = set((core_directory,))
|
||||||
|
for name in os.listdir('modules'):
|
||||||
|
if not name.endswith(".py") or name.startswith('.'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
real_name = os.path.realpath(os.path.join('modules', name))
|
||||||
|
directory = os.path.dirname(real_name)
|
||||||
|
directories.add(os.path.join(directory, 'templates'))
|
||||||
|
|
||||||
|
cfg.log.info('Template directories - %s' % directories)
|
||||||
|
|
||||||
|
return directories
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
parser = argparse.ArgumentParser(description='Plinth web interface for the FreedomBox.')
|
parser = argparse.ArgumentParser(description='Plinth web interface for the FreedomBox.')
|
||||||
parser.add_argument('--pidfile',
|
parser.add_argument('--pidfile',
|
||||||
@ -185,9 +205,8 @@ def main():
|
|||||||
setup()
|
setup()
|
||||||
|
|
||||||
# Configure Django
|
# Configure Django
|
||||||
directory = os.path.dirname(os.path.abspath(__file__))
|
template_directories = get_template_directories()
|
||||||
templates_directory = os.path.join(directory, 'templates')
|
django.conf.settings.configure(TEMPLATE_DIRS=template_directories)
|
||||||
django.conf.settings.configure(TEMPLATE_DIRS=(templates_directory,))
|
|
||||||
|
|
||||||
cherrypy.engine.start()
|
cherrypy.engine.start()
|
||||||
cherrypy.engine.block()
|
cherrypy.engine.block()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user