mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
help: Move custom static file handling into app from central place
Tests performed: - Print the calls to _mount_static_directory() before and after the changes. They should print the same. - With English as the preferred language, visit the user manual. Images should be visible. Visit MediaWiki manual page with learn more link in MediaWiki. Images should be visible. - Repeat with Spanish as the preferred language. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
b80083cfce
commit
56250562d4
@ -3,10 +3,12 @@
|
||||
FreedomBox app for help pages.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import app as app_module
|
||||
from plinth import menu
|
||||
from plinth import cfg, menu, web_server
|
||||
|
||||
version = 1
|
||||
|
||||
@ -51,6 +53,17 @@ class HelpApp(app_module.App):
|
||||
order=100)
|
||||
self.add(menu_item)
|
||||
|
||||
directory_map = {}
|
||||
langs = os.listdir(os.path.join(cfg.doc_dir, 'manual'))
|
||||
for lang in langs:
|
||||
manual_dir = os.path.join(cfg.doc_dir, 'manual', lang, 'images')
|
||||
manual_url = f'/help/manual/{lang}/images'
|
||||
directory_map[manual_url] = manual_dir
|
||||
|
||||
static_files = web_server.StaticFiles('static-files-help',
|
||||
directory_map)
|
||||
self.add(static_files)
|
||||
|
||||
|
||||
def init():
|
||||
"""Initialize the Help module"""
|
||||
|
||||
@ -56,13 +56,6 @@ def init():
|
||||
|
||||
_mount_static_directory('/usr/share/javascript', '/javascript')
|
||||
|
||||
langs = os.listdir(os.path.join(cfg.doc_dir, 'manual'))
|
||||
for lang in langs:
|
||||
manual_dir = os.path.join(cfg.doc_dir, 'manual', lang, 'images')
|
||||
manual_url = '/'.join([cfg.server_dir, f'help/manual/{lang}/images']) \
|
||||
.replace('//', '/')
|
||||
_mount_static_directory(manual_dir, manual_url)
|
||||
|
||||
for module_name, module in module_loader.loaded_modules.items():
|
||||
module_path = os.path.dirname(module.__file__)
|
||||
static_dir = os.path.join(module_path, 'static')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user