Skip to content

Commit

Permalink
Include additional UI variables in docs (#824)
Browse files Browse the repository at this point in the history
* Update per UI variables

per wmo-im/wis2box-ui#95

* Update wis2box-create-config.py

* Fix flake8

* Use UI prefix for env variables

per wmo-im/wis2box-ui#103

* Update based on PR feedback
  • Loading branch information
webb-ben authored Dec 21, 2024
1 parent c079059 commit 954a88a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/source/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ Web application
^^^^^^^^^^^^^^^

Web application configuration provides the ability to customize web components.
All of the below directives are optional.

.. code-block:: bash
WIS2BOX_BASEMAP_URL="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" # URL of map tile server to use
WIS2BOX_BASEMAP_ATTRIBUTION="<a href="https://osm.org/copyright">OpenStreetMap</a> contributors" # attribution of map tile server
WIS2BOX_UI_CLUSTER=False # default setting of the cluster toggle
WIS2BOX_UI_LANG="en" # default language, one of: ar, en, es, fr, ru, zh
WIS2BOX_UI_LOGO=http://example.com/logo.png # use custom organization logo in the UI
WIS2BOX_UI_BANNER_COLOR="#014e9e" # use custom background color for header and footer
WIS2BOX_UI_DISABLE_SEPARATOR_IMAGE=false # boolean to disable WMO separator
Other
^^^^^
Expand Down
38 changes: 36 additions & 2 deletions wis2box-create-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import random
import string
from string import Template
from typing import Tuple
from typing import Tuple, Union

# Identify platform type
WINDOWS = False
Expand Down Expand Up @@ -284,6 +284,39 @@ def get_wis2box_url() -> str:
return wis2box_url


def get_custom_ui_logo():
"""
Prompt the user to enter a custom UI logo path or URL.
:returns: string of URL logo
"""
while True:
logo = input("Enter the URL for the custom UI logo (leave blank to skip): ").strip() # noqa
msg = f"Confirm custom UI logo: '{logo or 'Default'}'? (y/n): "
confirm = input(msg).strip().lower()
if confirm == 'y':
return logo or None


def get_default_ui_language() -> Union[str, None]:
"""
Prompt the user to enter a default UI language and
validate against possible values.
:returns: string of languge
"""
valid_languages = ['en', 'fr', 'es', 'ar', 'zh', 'ru']
while True:
language = input("Enter the default UI language (e.g., 'fr' for French, 'ar' for Arabic, leave blank for 'en'): ").strip() or 'en' # noqa
if language in valid_languages:
msg = f"Confirm default UI language: '{language}'? (y/n): "
confirm = input(msg).strip().lower()
if confirm == 'y':
return language
else:
print(f"Invalid language. Please choose from: {', '.join(valid_languages)}.") # noqa


def create_wis2box_env(host_datadir: str) -> None:
"""
creates the wis2box.env file in the host_datadir
Expand All @@ -305,7 +338,8 @@ def create_wis2box_env(host_datadir: str) -> None:
fh.write('# wis2box public URL\n')
fh.write(f'WIS2BOX_URL={wis2box_url}\n')
fh.write('WIS2BOX_UI_CLUSTER=false\n')
fh.write('WIS2BOX_UI_LANG=en\n')
fh.write(f'WIS2BOX_UI_LOGO="{get_custom_ui_logo() or ""}"\n')
fh.write(f'WIS2BOX_UI_LANG={get_default_ui_language()}\n')
fh.write('\n')
fh.write('# api\n')
fh.write('WIS2BOX_API_TYPE=pygeoapi\n')
Expand Down

0 comments on commit 954a88a

Please sign in to comment.