resolve the ugly assets_prefix hack
This commit is contained in:
parent
37d89c074b
commit
c0b7cf5f8d
@ -1,7 +1,7 @@
|
||||
<div class="webrx-top-container">
|
||||
<div class="webrx-top-bar">
|
||||
<a href="https://www.openwebrx.de/" target="_blank"><img src="${assets_prefix}static/gfx/openwebrx-top-logo.png" class="webrx-top-logo" alt="OpenWebRX Logo"/></a>
|
||||
<img class="webrx-rx-avatar openwebrx-photo-trigger" src="${assets_prefix}static/gfx/openwebrx-avatar.png" alt="Receiver avatar"/>
|
||||
<a href="https://www.openwebrx.de/" target="_blank"><img src="${document_root}static/gfx/openwebrx-top-logo.png" class="webrx-top-logo" alt="OpenWebRX Logo"/></a>
|
||||
<img class="webrx-rx-avatar openwebrx-photo-trigger" src="${document_root}static/gfx/openwebrx-avatar.png" alt="Receiver avatar"/>
|
||||
<div class="webrx-rx-texts openwebrx-photo-trigger">
|
||||
<h1 class="webrx-rx-title">${receiver_name}</h1>
|
||||
<div class="webrx-rx-desc">${receiver_location} | Loc: ${locator}, ASL: ${receiver_asl} m</div>
|
||||
@ -10,8 +10,8 @@
|
||||
<div class="button" data-toggle-panel="openwebrx-panel-status"><span class="sprite sprite-panel-status"></span><br/>Status</div>
|
||||
<div class="button" data-toggle-panel="openwebrx-panel-log"><span class="sprite sprite-panel-log"></span><br/>Log</div>
|
||||
<div class="button" data-toggle-panel="openwebrx-panel-receiver"><span class="sprite sprite-panel-receiver"></span><br/>Receiver</div>
|
||||
<a class="button" href="${assets_prefix}map" target="openwebrx-map"><span class="sprite sprite-panel-map"></span><br/>Map</a>
|
||||
<a class="button" href="${assets_prefix}settings" target="openwebrx-settings"><span class="sprite sprite-panel-settings"></span><br/>Settings</a>
|
||||
<a class="button" href="${document_root}map" target="openwebrx-map"><span class="sprite sprite-panel-map"></span><br/>Map</a>
|
||||
<a class="button" href="${document_root}settings" target="openwebrx-settings"><span class="sprite sprite-panel-settings"></span><br/>Settings</a>
|
||||
</section>
|
||||
</div>
|
||||
<div class="openwebrx-description-container">
|
||||
|
@ -2,11 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenWebRX Settings</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="${assets_prefix}static/favicon.ico" />
|
||||
<link rel="stylesheet" href="${assets_prefix}static/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="${assets_prefix}static/css/admin.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="${document_root}static/favicon.ico" />
|
||||
<link rel="stylesheet" href="${document_root}static/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="${document_root}static/css/admin.css" />
|
||||
<script src="https://unpkg.com/location-picker/dist/location-picker.min.js"></script>
|
||||
<script src="${assets_prefix}compiled/settings.js"></script>
|
||||
<script src="${document_root}compiled/settings.js"></script>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
|
@ -68,16 +68,10 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB
|
||||
def indexAction(self):
|
||||
self.serve_template("settings/general.html", **self.template_variables())
|
||||
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["content"] = self.render_sections()
|
||||
variables["title"] = self.getTitle()
|
||||
variables["assets_prefix"] = "../"
|
||||
return variables
|
||||
|
||||
def parseFormData(self):
|
||||
|
@ -10,11 +10,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BookmarksController(AuthorizationMixin, WebpageController):
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["bookmarks"] = self.render_table()
|
||||
|
@ -13,16 +13,10 @@ from abc import ABCMeta
|
||||
|
||||
|
||||
class SdrDeviceListController(AuthorizationMixin, WebpageController):
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["content"] = self.render_devices()
|
||||
variables["title"] = "SDR device settings"
|
||||
variables["assets_prefix"] = "../"
|
||||
return variables
|
||||
|
||||
def render_devices(self):
|
||||
@ -134,16 +128,6 @@ class SdrDeviceController(SdrFormController):
|
||||
def getTitle(self):
|
||||
return self.device["name"]
|
||||
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["assets_prefix"] = "../../"
|
||||
return variables
|
||||
|
||||
def render_sections(self):
|
||||
return super().render_sections() + self.render_profile_list(self.device["profiles"])
|
||||
|
||||
@ -189,16 +173,6 @@ class NewSdrDeviceController(SettingsFormController):
|
||||
self.stack.addLayer(0, id_layer)
|
||||
self.stack.addLayer(1, self.data_layer)
|
||||
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["assets_prefix"] = "../../"
|
||||
return variables
|
||||
|
||||
def getSections(self):
|
||||
return [
|
||||
Section(
|
||||
@ -251,16 +225,6 @@ class SdrProfileController(SdrFormController):
|
||||
def getTitle(self):
|
||||
return self.profile["name"]
|
||||
|
||||
def header_variables(self):
|
||||
variables = super().header_variables()
|
||||
variables["assets_prefix"] = "../../../"
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
variables = super().template_variables()
|
||||
variables["assets_prefix"] = "../../../"
|
||||
return variables
|
||||
|
||||
def indexAction(self):
|
||||
if self.profile is None:
|
||||
self.send_response("profile not found", code=404)
|
||||
|
@ -19,14 +19,19 @@ class TemplateController(Controller):
|
||||
|
||||
|
||||
class WebpageController(TemplateController):
|
||||
def get_document_root(self):
|
||||
path_parts = [part for part in self.request.path[1:].split("/")]
|
||||
levels = max(0, len(path_parts) - 1)
|
||||
return "../" * levels
|
||||
|
||||
def header_variables(self):
|
||||
variables = {"assets_prefix": ""}
|
||||
variables = {"document_root": self.get_document_root()}
|
||||
variables.update(ReceiverDetails().__dict__())
|
||||
return variables
|
||||
|
||||
def template_variables(self):
|
||||
header = self.render_template("include/header.include.html", **self.header_variables())
|
||||
return {"header": header}
|
||||
return {"header": header, "document_root": self.get_document_root()}
|
||||
|
||||
|
||||
class IndexController(WebpageController):
|
||||
|
16
owrx/http.py
16
owrx/http.py
@ -40,23 +40,23 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
logger.debug("%s - - [%s] %s", self.address_string(), self.log_date_time_string(), format % args)
|
||||
|
||||
def do_GET(self):
|
||||
self.router.route(self, self.get_request("GET"))
|
||||
self.router.route(self, self._build_request("GET"))
|
||||
|
||||
def do_POST(self):
|
||||
self.router.route(self, self.get_request("POST"))
|
||||
self.router.route(self, self._build_request("POST"))
|
||||
|
||||
def do_DELETE(self):
|
||||
self.router.route(self, self.get_request("DELETE"))
|
||||
self.router.route(self, self._build_request("DELETE"))
|
||||
|
||||
def get_request(self, method):
|
||||
url = urlparse(self.path)
|
||||
return Request(url, method, self.headers)
|
||||
def _build_request(self, method):
|
||||
return Request(self.path, method, self.headers)
|
||||
|
||||
|
||||
class Request(object):
|
||||
def __init__(self, url, method, headers):
|
||||
self.path = url.path
|
||||
self.query = parse_qs(url.query)
|
||||
parsed_url = urlparse(url)
|
||||
self.path = parsed_url.path
|
||||
self.query = parse_qs(parsed_url.query)
|
||||
self.matches = None
|
||||
self.method = method
|
||||
self.headers = headers
|
||||
|
Loading…
Reference in New Issue
Block a user