diff options
author | Evgeny Sorokin <me@ch1p.io> | 2024-04-03 01:26:41 +0300 |
---|---|---|
committer | Evgeny Sorokin <me@ch1p.io> | 2024-04-03 01:26:41 +0300 |
commit | 8314dc42dc21185f556b4bb257ce198378d30d71 (patch) | |
tree | ab11a973c920f99063f55a58ed2affc397fd8945 | |
parent | 63ff5dd151ca6a21dbae8a654d81cf60f2f6f0cc (diff) |
web_kbn: relative paths
-rwxr-xr-x | bin/web_kbn.py | 24 | ||||
-rw-r--r-- | web/kbn_assets/app.js | 4 | ||||
-rw-r--r-- | web/kbn_templates/base.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/cams.j2 | 4 | ||||
-rw-r--r-- | web/kbn_templates/index.j2 | 16 | ||||
-rw-r--r-- | web/kbn_templates/inverter.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/modem_data.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/modem_verbose.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/pump.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/routing_header.j2 | 6 | ||||
-rw-r--r-- | web/kbn_templates/routing_main.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/routing_rules.j2 | 4 | ||||
-rw-r--r-- | web/kbn_templates/sms.j2 | 8 |
13 files changed, 39 insertions, 39 deletions
diff --git a/bin/web_kbn.py b/bin/web_kbn.py index 9629598..0439c94 100755 --- a/bin/web_kbn.py +++ b/bin/web_kbn.py @@ -248,7 +248,7 @@ async def render(req: web.Request, @routes.get('/') async def index0(req: web.Request): - raise web.HTTPFound('/main.cgi') + raise web.HTTPFound('main.cgi') @routes.get('/main.cgi') @@ -256,7 +256,7 @@ async def index(req: web.Request): tabs = ['zones', 'list'] tab = req.query.get('tab', None) if tab and (tab not in tabs or tab == tabs[0]): - raise web.HTTPFound('/main.cgi') + raise web.HTTPFound('main.cgi') if tab is None: tab = tabs[0] @@ -284,7 +284,7 @@ async def modems(req: web.Request): context=dict(modems=ModemsConfig())) -@routes.get('/modems/info.ajx') +@routes.get('/modems_info.ajx') async def modems_ajx(req: web.Request): mc = ModemsConfig() modem = req.query.get('id', None) @@ -303,7 +303,7 @@ async def modems_ajx(req: web.Request): return http.ajax_ok({'html': html}) -@routes.get('/modems/verbose.cgi') +@routes.get('/modems_verbose.cgi') async def modems_verbose(req: web.Request): modem = req.query.get('id', None) if modem not in ModemsConfig().keys(): @@ -356,7 +356,7 @@ async def sms_post(req: web.Request): phone = fd.get('phone', None) text = fd.get('text', None) - return_url = f'/sms.cgi?id={modem}&outbox={int(is_outbox)}' + return_url = f'sms.cgi?id={modem}&outbox={int(is_outbox)}' phone = re.sub('\s+', '', phone) if len(phone) > 4: @@ -383,7 +383,7 @@ async def inverter(req: web.Request): cl = get_inverter_client() cl.exec('set-output-source-priority', arguments=(val.upper(),)) - raise web.HTTPFound('/inverter.cgi') + raise web.HTTPFound('inverter.cgi') status, rated, html = await asyncio.get_event_loop().run_in_executor(None, get_inverter_data) return await render(req, 'inverter', @@ -408,7 +408,7 @@ async def pump(req: web.Request): action = req.query.get('set', None) if action in ('on', 'off'): getattr(cl, action)() - raise web.HTTPFound('/pump.cgi') + raise web.HTTPFound('pump.cgi') status = cl.status() return await render(req, 'pump', @@ -468,7 +468,7 @@ async def cams(req: web.Request): )) -@routes.get('/routing/main.cgi') +@routes.get('/routing_main.cgi') async def routing_main(req: web.Request): upstream = get_current_upstream() @@ -479,7 +479,7 @@ async def routing_main(req: web.Request): modem = mc[set_upstream_to] new_upstream = str(modem['gateway_ip'] if 'gateway_ip' in modem else modem['ip']) openwrt.set_upstream(new_upstream) - raise web.HTTPFound('/routing/main.cgi') + raise web.HTTPFound('routing_main.cgi') context = dict( upstream=upstream, @@ -489,7 +489,7 @@ async def routing_main(req: web.Request): return await render(req, 'routing_main', title=lang('routing'), context=context) -@routes.get('/routing/rules.cgi') +@routes.get('/routing_rules.cgi') async def routing_rules(req: web.Request): mc = ModemsConfig() @@ -520,7 +520,7 @@ async def routing_rules(req: web.Request): if not validate_ipv4(ip_without_mask): raise ValueError(f'invalid ip \'{ip}\'') - base_url = '/routing/rules.cgi' + base_url = 'routing_rules.cgi' if action in ('add', 'del'): try: validate_input() @@ -544,7 +544,7 @@ async def routing_rules(req: web.Request): context=context) -@routes.get('/routing/dhcp.cgi') +@routes.get('/routing_dhcp.cgi') async def routing_dhcp(req: web.Request): leases = openwrt.get_dhcp_leases() return await render(req, 'routing_dhcp', diff --git a/web/kbn_assets/app.js b/web/kbn_assets/app.js index 62e2575..0211479 100644 --- a/web/kbn_assets/app.js +++ b/web/kbn_assets/app.js @@ -238,7 +238,7 @@ class ModemStatusUpdater { } fetch() { - ajax.get('/modems/info.ajx', { + ajax.get('modems_info.ajx', { id: this.id }).then(({response}) => { const {html} = response; @@ -268,7 +268,7 @@ var Inverter = { }, _tick: function() { - ajax.get('/inverter.ajx') + ajax.get('inverter.ajx') .then(({response}) => { if (response) { var el = document.getElementById('inverter_status'); diff --git a/web/kbn_templates/base.j2 b/web/kbn_templates/base.j2 index 2ecb199..8088c19 100644 --- a/web/kbn_templates/base.j2 +++ b/web/kbn_templates/base.j2 @@ -1,7 +1,7 @@ {% macro breadcrumbs(history) %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> - <li class="breadcrumb-item"><a href="/main.cgi">{{ "main"|lang }}</a></li> + <li class="breadcrumb-item"><a href="main.cgi">{{ "main"|lang }}</a></li> {% for item in history %} <li class="breadcrumb-item"{% if loop.last %} aria-current="page"{% endif %}> {% if item.link %}<a href="{{ item.link }}">{% endif %} diff --git a/web/kbn_templates/cams.j2 b/web/kbn_templates/cams.j2 index 361b86a..5ec7279 100644 --- a/web/kbn_templates/cams.j2 +++ b/web/kbn_templates/cams.j2 @@ -5,12 +5,12 @@ {{ breadcrumbs([{'text': "cams"|lang}]) }} {% elif mode.type == 'zone' %} {{ breadcrumbs([ - {'link': '/cams.cgi', 'text': "cams"|lang}, + {'link': 'cams.cgi', 'text': "cams"|lang}, {'text': mode.zone|lang('ipcam_zones')} ]) }} {% elif mode.type == 'single' %} {{ breadcrumbs([ - {'link': '/cams.cgi', 'text': "cams"|lang}, + {'link': 'cams.cgi', 'text': "cams"|lang}, {'text': mode.cam|lang('ipcam')} ]) }} {% endif %} diff --git a/web/kbn_templates/index.j2 b/web/kbn_templates/index.j2 index 9d683e0..6f579c7 100644 --- a/web/kbn_templates/index.j2 +++ b/web/kbn_templates/index.j2 @@ -23,16 +23,16 @@ <h6>{{ "internet"|lang }}</h6> <ul class="list-group list-group-flush"> - <li class="list-group-item"><a href="/modems.cgi">{{ "modems"|lang }}</a></li> - <li class="list-group-item"><a href="/routing/main.cgi">{{ "routing"|lang }}</a></li> - <li class="list-group-item"><a href="/sms.cgi">{{ "sms"|lang }}</a></li> + <li class="list-group-item"><a href="modems.cgi">{{ "modems"|lang }}</a></li> + <li class="list-group-item"><a href="routing/main.cgi">{{ "routing"|lang }}</a></li> + <li class="list-group-item"><a href="sms.cgi">{{ "sms"|lang }}</a></li> </ul> <h6 class="mt-4">{{ "misc"|lang }}</h6> <ul class="list-group list-group-flush"> - <li class="list-group-item"><a href="/inverter.cgi">{{ "inverter"|lang }}</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li> -{# <li class="list-group-item"><a href="/pump.cgi">{{ "pump"|lang }}</a></li>#} -{# <li class="list-group-item"><a href="/sensors.cgi">{{ "sensors"|lang }}</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li>#} + <li class="list-group-item"><a href="inverter.cgi">{{ "inverter"|lang }}</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li> +{# <li class="list-group-item"><a href="pump.cgi">{{ "pump"|lang }}</a></li>#} +{# <li class="list-group-item"><a href="sensors.cgi">{{ "sensors"|lang }}</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li>#} </ul> <nav class="mt-4"> @@ -45,7 +45,7 @@ <div class="camzones" id="cam_zones"{% if tab_selected != 'zones' %} style="display: none"{% endif %}> {% for zone in camzones %} - <a href="/cams.cgi?zone={{ zone }}" class="camzone"> + <a href="cams.cgi?zone={{ zone }}" class="camzone"> <div class="camzone_text">{{ zone|lang('ipcam_zones') }}</div> </a> {% endfor %} @@ -53,7 +53,7 @@ <div class="list-group cams_list_group" id="cam_list"{% if tab_selected != 'list' %} style="display: none"{% endif %}> {% for id in allcams %} - <a href="/cams.cgi?id={{ id }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"> + <a href="cams.cgi?id={{ id }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"> {{ id|lang('ipcam') }} <span class="icon-right"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"> diff --git a/web/kbn_templates/inverter.j2 b/web/kbn_templates/inverter.j2 index e84bffc..086a047 100644 --- a/web/kbn_templates/inverter.j2 +++ b/web/kbn_templates/inverter.j2 @@ -9,7 +9,7 @@ </div> <div class="pt-3"> - <a href="/inverter.cgi?do=set-osp&value={{ 'sub' if rated.output_source_priority == 'Solar-Battery-Utility' else 'sbu' }}"> + <a href="inverter.cgi?do=set-osp&value={{ 'sub' if rated.output_source_priority == 'Solar-Battery-Utility' else 'sbu' }}"> <button type="button" class="btn btn-primary">{{ "inverter_switch_to"|lang }} <b>{{ 'Solar-Utility-Battery' if rated.output_source_priority == 'Solar-Battery-Utility' else 'Solar-Battery-Utility' }}</b></button> </a> </div> diff --git a/web/kbn_templates/modem_data.j2 b/web/kbn_templates/modem_data.j2 index f96a197..712d7b9 100644 --- a/web/kbn_templates/modem_data.j2 +++ b/web/kbn_templates/modem_data.j2 @@ -10,4 +10,4 @@ <span class="text-secondary">{{ "modem_connection_time"|lang }}:</span> {{ modem_data.connected_time }}<br> <span class="text-secondary">{{ "modem_tx_rx"|lang }}:</span> {{ modem_data.downloaded }} / {{ modem_data.uploaded }} <br> -<a href="/modems/verbose.cgi?id={{ modem }}">{{ "modem_verbose_info"|lang }}</a> +<a href="modems_verbose.cgi?id={{ modem }}">{{ "modem_verbose_info"|lang }}</a> diff --git a/web/kbn_templates/modem_verbose.j2 b/web/kbn_templates/modem_verbose.j2 index 4514451..314a8f9 100644 --- a/web/kbn_templates/modem_verbose.j2 +++ b/web/kbn_templates/modem_verbose.j2 @@ -2,7 +2,7 @@ {% block content %} {{ breadcrumbs([ - {'link': '/modems.cgi', 'text': 'modems'|lang}, + {'link': 'modems.cgi', 'text': 'modems'|lang}, {'text': modem_name} ]) }} diff --git a/web/kbn_templates/pump.j2 b/web/kbn_templates/pump.j2 index 40836ca..aab5b1a 100644 --- a/web/kbn_templates/pump.j2 +++ b/web/kbn_templates/pump.j2 @@ -3,7 +3,7 @@ {% block content %} {{ breadcrumbs([{'text': 'pump'|lang}]) }} -<form action="/pump.cgi" method="get"> +<form action="pump.cgi" method="get"> <input type="hidden" name="set" value="{{ 'off' if status == 'on' else 'on' }}" /> {{ "pump_now_is"|lang }} {% if status == 'on' %} diff --git a/web/kbn_templates/routing_header.j2 b/web/kbn_templates/routing_header.j2 index 527f154..a3af75d 100644 --- a/web/kbn_templates/routing_header.j2 +++ b/web/kbn_templates/routing_header.j2 @@ -1,9 +1,9 @@ {{ breadcrumbs([{'text': 'routing'|lang}]) }} {% set routing_tabs = [ - {'tab': 'main', 'url': '/routing/main.cgi', 'label': 'routing_main'|lang}, - {'tab': 'rules', 'url': '/routing/rules.cgi', 'label': 'routing_rules'|lang}, - {'tab': 'dhcp', 'url': '/routing/dhcp.cgi', 'label': 'DHCP'} + {'tab': 'main', 'url': 'routing_main.cgi', 'label': 'routing_main'|lang}, + {'tab': 'rules', 'url': 'routing_rules.cgi', 'label': 'routing_rules'|lang}, + {'tab': 'dhcp', 'url': 'routing_dhcp.cgi', 'label': 'DHCP'} ] %} <nav> diff --git a/web/kbn_templates/routing_main.j2 b/web/kbn_templates/routing_main.j2 index 856da78..21d0965 100644 --- a/web/kbn_templates/routing_main.j2 +++ b/web/kbn_templates/routing_main.j2 @@ -10,7 +10,7 @@ {% for modem in modems %} {% if modem != upstream %} <div class="pt-1 pb-2"> - <a href="/routing/main.cgi?set-upstream-to={{ modem }}"> + <a href="routing_main.cgi?set-upstream-to={{ modem }}"> <button type="button" class="btn btn-primary">{{ "routing_switch_to"|lang }} <b>{{ (modem|lang('modems'))['full'] }}</b></button> </a> </div> diff --git a/web/kbn_templates/routing_rules.j2 b/web/kbn_templates/routing_rules.j2 index 61b68c9..3dcc709 100644 --- a/web/kbn_templates/routing_rules.j2 +++ b/web/kbn_templates/routing_rules.j2 @@ -10,14 +10,14 @@ {% if ips %} {% for ip in ips %} - <div>{{ ip }} (<a href="/routing/rules.cgi?action=del&set={{ set }}&ip={{ ip }}" onclick="return confirm('{{ 'routing_deleting_confirmation'|lang|format(ip, set) }}')">{{ "routing_del"|lang }}</a>)</div> + <div>{{ ip }} (<a href="routing_rules.cgi?action=del&set={{ set }}&ip={{ ip }}" onclick="return confirm('{{ 'routing_deleting_confirmation'|lang|format(ip, set) }}')">{{ "routing_del"|lang }}</a>)</div> {% endfor %} {% else %} <span class="text-secondary">{{ "routing_no_records"|lang }}</span> {% endif %} <div style="max-width: 300px"> - <form method="get" action="/routing/rules.cgi"> + <form method="get" action="routing_rules.cgi"> <input type="hidden" name="action" value="add"> <input type="hidden" name="set" value="{{ set }}"> <div class="input-group mt-2"> diff --git a/web/kbn_templates/sms.j2 b/web/kbn_templates/sms.j2 index 41be6fc..720a7bd 100644 --- a/web/kbn_templates/sms.j2 +++ b/web/kbn_templates/sms.j2 @@ -6,7 +6,7 @@ <nav> <div class="nav nav-tabs" id="nav-tab"> {% for modem in modems.keys() %} - {% if selected_modem != modem %}<a href="/sms.cgi?id={{ modem }}" class="text-decoration-none">{% endif %} + {% if selected_modem != modem %}<a href="sms.cgi?id={{ modem }}" class="text-decoration-none">{% endif %} <button class="nav-link{% if modem == selected_modem %} active{% endif %}" type="button">{{ (modem|lang('modems'))['short'] }}</button> {% if selected_modem != modem %}</a>{% endif %} {% endfor %} @@ -26,7 +26,7 @@ {% endif %} <div> - <form method="post" action="/sms.cgi"> + <form method="post" action="sms.cgi"> <input type="hidden" name="modem" value="{{ selected_modem }}"> <div class="form-floating mb-3"> <input type="text" name="phone" class="form-control" id="inputPhone" placeholder="+7911xxxyyzz"> @@ -45,9 +45,9 @@ <h6 class="text-primary mt-4"> {{ "sms_latest"|lang }} {% if not is_outbox %} - <b>{{ "sms_inbox"|lang }}</b> <span class="text-black-50">|</span> <a href="/sms.cgi?id={{ selected_modem }}&outbox=1">{{ "sms_outbox"|lang }}</a> + <b>{{ "sms_inbox"|lang }}</b> <span class="text-black-50">|</span> <a href="sms.cgi?id={{ selected_modem }}&outbox=1">{{ "sms_outbox"|lang }}</a> {% else %} - <a href="/sms.cgi?id={{ selected_modem }}">{{ "sms_inbox"|lang }}</a> <span class="text-black-50">|</span> <b>{{ "sms_outbox"|lang }}</b> + <a href="sms.cgi?id={{ selected_modem }}">{{ "sms_inbox"|lang }}</a> <span class="text-black-50">|</span> <b>{{ "sms_outbox"|lang }}</b> {% endif %} </h6> |