Skip to content
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

Include additional UI variables in docs #824

Merged
merged 5 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading