- Use bindata to package static file content in to the frontend binary
- Add golang templates to move HTML rendering out of the go code where possible - Add an endpoint for serving static files - Add URL escaping for servers and targets
This commit is contained in:
2
frontend/bindata/robots.txt
Normal file
2
frontend/bindata/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
14
frontend/bindata/templates/bgpmap
Normal file
14
frontend/bindata/templates/bgpmap
Normal file
@@ -0,0 +1,14 @@
|
||||
<h2>BGPmap: {{ html .Target }}</h2>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.min.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/lite.render.js" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
var viz = new Viz();
|
||||
viz.renderSVGElement(`{{ .Result }}`)
|
||||
.then(element => {
|
||||
document.body.appendChild(element);
|
||||
})
|
||||
.catch(error => {
|
||||
document.body.innerHTML = "<pre>"+error+"</pre>"
|
||||
});
|
||||
</script>
|
||||
2
frontend/bindata/templates/bird
Normal file
2
frontend/bindata/templates/bird
Normal file
@@ -0,0 +1,2 @@
|
||||
<h2>{{ html .ServerName }}: {{ html .Target }}</h2>
|
||||
{{ .Result }}
|
||||
68
frontend/bindata/templates/page
Normal file
68
frontend/bindata/templates/page
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>{{ .Title }}</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.1/dist/css/bootstrap.min.css" integrity="sha256-VoFZSlmyTXsegReQCNmbXrS4hBBUl/cexZvPmPWoJsY=" crossorigin="anonymous">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="/">{{ .Brand }}</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
{{ $option := .URLOption }}
|
||||
{{ $server := .URLServer }}
|
||||
{{ $target := .URLCommand }}
|
||||
{{ if .IsWhois }}
|
||||
{{ $option = "summary" }}
|
||||
{{ $server = .AllServersURL }}
|
||||
{{ $target = "" }}
|
||||
{{ end }}
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link{{ if .AllServersLinkActive }} active{{ end }}"
|
||||
href="/{{ $option }}/{{ .AllServersURL }}/{{ $target }}"> All Servers </a>
|
||||
</li>
|
||||
{{ range $k, $v := .Servers }}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link{{ if eq $server $v }} active{{ end }}"
|
||||
href="/{{ $option }}/{{ $v }}/{{ $target }}">{{ $v }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ if .IsWhois }}
|
||||
{{ $target = .WhoisTarget }}
|
||||
{{ end }}
|
||||
<form class="form-inline" action="/redir" method="GET">
|
||||
<div class="input-group">
|
||||
<select name="action" class="form-control">
|
||||
{{ range $k, $v := .Options }}
|
||||
<option value="{{ $k }}"{{ if eq $k $.URLOption }} selected{{end}}>{{ $v }}</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
<input name="server" class="d-none" value="{{ $server }}">
|
||||
<input name="target" class="form-control" placeholder="Target" aria-label="Target" value="{{ $target }}">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-success" type="submit">»</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
{{ .Content }}
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.1/dist/js/bootstrap.min.js" integrity="sha256-0IiaoZCI++9oAAvmCb5Y0r93XkuhvJpRalZLffQXLok=" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
26
frontend/bindata/templates/summary
Normal file
26
frontend/bindata/templates/summary
Normal file
@@ -0,0 +1,26 @@
|
||||
{{ $ServerName := urlquery .ServerName }}
|
||||
|
||||
<table class="table table-striped table-bordered table-sm">
|
||||
<thead>
|
||||
{{ range .Header }}
|
||||
<th scope="col">{{ html . }}</th>
|
||||
{{ end }}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .Rows }}
|
||||
<tr class="table-{{ .MappedState }}">
|
||||
<td><a href="/detail/{{ $ServerName }}/{{ urlquery .Name }}">{{ html .Name }}</a></td>
|
||||
<td>{{ .Proto }}</td>
|
||||
<td>{{ .Table }}</td>
|
||||
<td>{{ .State }}</td>
|
||||
<td>{{ .Since }}</td>
|
||||
<td>{{ .Info }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!--
|
||||
{{ .Raw }}
|
||||
-->
|
||||
|
||||
2
frontend/bindata/templates/whois
Normal file
2
frontend/bindata/templates/whois
Normal file
@@ -0,0 +1,2 @@
|
||||
<h2>whois {{ html .Target }}</h2>
|
||||
{{ .Result }}
|
||||
Reference in New Issue
Block a user