-
Notifications
You must be signed in to change notification settings - Fork 64
Load Explorer HTML and CSS from extensions #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…tensions, and load them. For CSS, also walk through config/extensions.
stijn-uva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best if we could combine the template gathering code with the other modular file collection code in ModuleLoader, to keep that functionality centralised and not repeat ourselves too much. There's a load_modules and load_datasources in there - a load_templates could fit in as well. Otherwise looks like a good change.
webtool/__init__.py
Outdated
|
|
||
| # Load Explorer HTML templates from extensions | ||
| extension_explorer_templates = {} | ||
| def get_explorer_templates_from_extensions(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be done in ModuleLoader()? That already has logic to traverse the extension folders and could also collect template files, then they could be passed to app.jinja_loader here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have a config.get("PATH_EXTENSIONS") that ca be used instead of re-constructing the path here
webtool/views/views_explorer.py
Outdated
| with open(standard_path, "r", encoding="utf-8") as f: | ||
| return f.read() | ||
|
|
||
| # Check extensions folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise this could perhaps be collected on startup in ModuleLoader, also saves some time on pageview
|
Will make the changes. @stijn-uva I was doubting whether to also put Explorer templates in datasource folders. That's how it was originally, and it keeps datasource files nicely contained in one directory. But it doesn't really follow the logic of front/backend and will require traversing datasources for Explorer templates as well--though these are already walked through in the module loader of course. Any preference? |
|
@stijn-uva , okay, I moved the Explorer html and css files to datasource folders. The module loader now adds a 'explorer-templates' key with css and html files, if present for this datasource. These are then loaded in with a new function in One thing I'm not sure about is whether/if to use |
This allows to add files with the name
[datasource-id]-explorer.htmland[datasource-id]-explorer.cssto be added to config/extensions. These are then used in the Explorer. For HTML, Flask needs to know where to read templates from, which becomes a bit tricky if it's not inwebtool. So on startup, it now walks throughconfig/extensionsand loads Explorer templates there if present. Speed and memory hits should be minimal.