mirror of
https://github.com/bluxmit/alnoda-workspaces.git
synced 2024-09-16 01:37:08 +12:00
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
|
"""
|
||
|
Basic example of a Mkdocs-macros module.
|
||
|
Include this {{ macros_info() }} in any page to get complete macro info
|
||
|
"""
|
||
|
import os
|
||
|
|
||
|
port_increments = {
|
||
|
"DOCS_URL": 0,
|
||
|
"FILEBROWSER_URL": 1,
|
||
|
"STATICFS_URL": 2,
|
||
|
"CRONICLE_URL": 3,
|
||
|
"UNGIT_URL": 4,
|
||
|
"IDE_URL": 5
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
# this function name should not be changed
|
||
|
def define_env(env):
|
||
|
"""
|
||
|
This is the hook for defining variables, macros and filters
|
||
|
- variables: the dictionary that contains the environment variables
|
||
|
- macro: a decorator function, to declare a macro.
|
||
|
- filter: a function with one of more arguments,
|
||
|
used to perform a transformation
|
||
|
"""
|
||
|
@env.macro
|
||
|
def get_tool_url(env):
|
||
|
try:
|
||
|
return os.environ[name]
|
||
|
except:
|
||
|
# Get host
|
||
|
host = "localhost"
|
||
|
try:
|
||
|
host = os.environ["WRK_HOST"]
|
||
|
except:
|
||
|
pass
|
||
|
# Entry port - port relative to which other ports will be calculated
|
||
|
entry_port = 8020
|
||
|
try:
|
||
|
entry_port = int(os.environ["ENTRY_PORT"])
|
||
|
except:
|
||
|
pass
|
||
|
# Assign port
|
||
|
try:
|
||
|
port = port_increments[env] + entry_port
|
||
|
except:
|
||
|
port = 80
|
||
|
return f"http://{host}:{port}"
|
||
|
|
||
|
|