From 8314dc42dc21185f556b4bb257ce198378d30d71 Mon Sep 17 00:00:00 2001 From: Evgeny Sorokin Date: Wed, 3 Apr 2024 01:26:41 +0300 Subject: web_kbn: relative paths --- bin/web_kbn.py | 24 ++++++++++++------------ web/kbn_assets/app.js | 4 ++-- web/kbn_templates/base.j2 | 2 +- web/kbn_templates/cams.j2 | 4 ++-- web/kbn_templates/index.j2 | 16 ++++++++-------- web/kbn_templates/inverter.j2 | 2 +- web/kbn_templates/modem_data.j2 | 2 +- web/kbn_templates/modem_verbose.j2 | 2 +- web/kbn_templates/pump.j2 | 2 +- web/kbn_templates/routing_header.j2 | 6 +++--- web/kbn_templates/routing_main.j2 | 2 +- web/kbn_templates/routing_rules.j2 | 4 ++-- 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) %}