New templates!

This commit is contained in:
Slatian 2023-02-23 21:24:35 +01:00
parent bb872bef3c
commit 67b2103f5a
8 changed files with 173 additions and 97 deletions

13
templates/404.html Normal file
View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block content %}
<section>
<p>The page you were looking for isn't here …</p>
<p>You may have been interested in …</p>
<ul>
<li><a href="{{ extra.base_url}}">The homepage</a></li>
<li>The <code>/ip/</code> or <code>/dig/</code> endpoints.</li>
<li><a href="{{ extra.base_url }}/ua">The <code>/ua</code> endpoint wich just displays your user agent.</a></li>
</ul>
</section>
{% endblock %}

42
templates/base.html Normal file
View File

@ -0,0 +1,42 @@
{% import "helpers.html" as helper %}
<!DOCTYPE html>
<html lang="{{extra.language | default(value="en")}}">
<head>
<meta charset="utf-8">
<title>{% block title %}{{ extra[view].title | default(value="…") }}{% endblock %} | {{extra.site_name|default(value="echoip")}}</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<!-- Open-Graph -->
{% block metadata %}
<meta name="description" property="og:description" content="{% block description %}{{ extra[view].description | default(value="One of the best echoip services") | escape_xml }}{% endblock %}" />
<meta property="og:title" content="{% block og_title %}{{ extra[view].title | default(value="") | escape_xml }}{% endblock %}" />
<meta property="og:type" content="website">
<meta property="og:url" content="{% block og_url %}{{ extra.base_url }}{% block og_path %}{% endblock %}{% endblock %}">
{% set og_image = extra.og_image | default(value="") %}
{% set og_image = extra[view].og_image | default(value=og_image) %}
{% if og_image %}<meta property="og:image" content="{{og_image}}">{%endif%}
{% endblock %}
<!-- Styling -->
<meta name="color-scheme" content="light dark">
{% if extra.stylesheet %}<link rel="stylesheet" href="{{extra.stylesheet}}" type="text/css" />{% endif %}
{% if extra.favicon %}<link rel="icon" href="{{extra.favicon}}" type="{{extra.favicon_mimetype|default(value="image/png")}}" \>{% endif %}
</head>
<body>
<header>
<nav>
<a href="{{ extra.base_url }}" class="sitename">{{extra.site_name|default(value="echoip")}}</a>
<form class="search" method="GET" action="{{ extra.base_url }}">
<input type="text" name="query" autocomplete="on" maxlength="260"
title="Search for an IP-Adress, Domain-Name, or ASN."
value="{% if view == "dig" %}{{ data.query }}{% elif view == "ip" %}{{ data.result.address }}{% endif %}"/>
<input type="submit" value="Query"/>
</form>
</nav>
</header>
<main>
<h1>{% block h1 %}{{ extra[view].title | default(value="…") }}{% endblock %}</h1>
{% block content %}
<p>If you see this the templating is broken. Greetings from the base template.</p>
{% endblock %}
</main>
</body>
</html>

View File

@ -1,17 +1,34 @@
<!DOCTYPE html>
{% set r = data.result %}
{% set q = data.query %}
<html>
<head>
<title>Dig: {{ q.name }}</title>
</head>
<body>
<h1>Lookup for: {{ q.name }}</h1>
{% extends "base.html" %}
{% import "helpers.html" as helper %}
{% block title %}dig {{ data.query }}{% endblock %}
{% block og_title %}dig {{ data.query }}{% endblock %}
{% block h1 %}dig <code>{{ data.query }}</code>{% endblock %}
{% block og_path %}/dig/{{ data.query | urlencode_strict }}{% endblock %}
{% block content %}
{% if data.result.idn %}
{% set idn = data.result.idn %}
<section>
<h2>Internationalized Domain Names</h2>
<p>Because of some limitations the DNS has, Unicode caracters need a special encoding.</p>
{% if idn.original_was == "unicode" %}
<p>Your Unicode query has been encoded as the <i>IDN</i> <code>{{ idn.idn }}</code> to generate the results below.</p>
{% else %}
<p>Your <i>IDN</i> would decode to <code>{{ idn.unicode }}</code>.</p>
{% endif %}
</section>
{% endif %}
{% set r = data.result.records %}
<section>
<h2>DNS Records</h2>
{% if r.a %}
<p><code>A</code> (IPv4) records:</p>
<ul>
<p id="a"><code>A</code> (IPv4) records:</p>
<ul class="link-list">
{% for address in r.a%}
<li><code><a href="/ip?ip={{address}}">{{address}}</a></code></li>
<li>{{ helper::ip(extra=extra, ip=address) }}</li>
{% endfor %}
</ul>
{% else %}
@ -19,27 +36,33 @@
{% endif %}
{% if r.aaaa %}
<p><code>AAAA</code> (IPv6) records:</p>
<ul>
<p id="aaaa"><code>AAAA</code> (IPv6) records:</p>
<ul class="link-list">
{% for address in r.aaaa%}
<li><code><a href="/ip?ip={{address}}">{{address}}</a></code></li>
<li>{{ helper::ip(extra=extra, ip=address) }}</li>
{% endfor %}
</ul>
{% else %}
<p>No <code>AAAA</code> (IPv6) Records.</p>
{% endif %}
{% if not data.result.partial_lookup %}
{% if r.mx %}
<p><code>MX</code> (Mail Exchange) records:</p>
<ul>
<p id="mx"><code>MX</code> (Mail Exchange) records:</p>
<ul class="link-list">
{% for mx in r.mx%}
<li>{{mx.preference}} <code><a href="/dig?name={{mx.exchange}}">{{mx.exchange}}</a></code></li>
<li>{{ helper::dig(extra=extra, name=mx.exchange, fqdn=true, prefix=mx.preference) }}</li>
{% endfor %}
</ul>
{% else %}
<p>No <code>MX</code> (Mail Exchange) records.</p>
{% endif %}
</body>
</html>
{% else %}{# if data.partial_lookup #}
<p>To save resources the above is only a partial lookup.</p>
<p class="button-paragraph"><a href="{{ helper::dig_link(extra=extra, name=data.query) }}">Extended DNS Lookup for <code>{{ data.query }}</code>.</a></p>
{% endif %}
</section>
{% endblock %}

View File

@ -1 +1,13 @@
site_name="echoip-slatecave"
base_url="http://localhost:3000"
# Url to the deafult opengraph preview image
# og_image=""
# Url to your stylesheet
stylesheet = "https://slatecave.net/assets/site_slatecave/slatecave_v3.css"
#Url to and mimetype of your favicon
# favicon = ""
# favicon_mimetype = "image/png"
# favicon_mimetype = "image/jpeg"

View File

@ -5,3 +5,15 @@
{% endif %}
{% endmacro place_dl %}
{% macro dig_link(extra, name) %}
{{ extra.base_url }}/dig/{{ name | trim_end_matches(pat=".") | urlencode_strict | replace(from="%2e", to=".") | safe }}
{% endmacro dig_link %}
{% macro dig(extra, name, fqdn=false, prefix="") %}
<a href="{{ self::dig_link(extra=extra, name=name) }}">{% if prefix %}{{ prefix }} {% endif %}{% if fqdn or name=="." %}{{ name }}{% else %}{{ name | trim_end_matches(pat=".") }}{% endif %}</a>
{% endmacro dig %}
{% macro ip(extra, ip) %}
<a href="{{ extra.base_url }}/ip/{{ ip | urlencode_strict | replace(from="%2e", to=".") | replace(from="%3a", to=":") | safe }}"><code>{{ ip }}</code></a>
{% endmacro dig %}

View File

@ -1,68 +1,29 @@
{% extends "ip.html" %}
{% import "helpers.html" as helper %}
<!DOCTYPE html>
<html>
<head>
<title>Your IP: {{ data.query.ip }}</title>
</head>
<body>
{% set r = data.result %}
<header>
<nav>
<a href="/" class="site-name">{{extra.site_name|default(val="echoip")}}</a>
</nav>
</header>
<h1>Your IP-Address is: {{ data.query.ip }}</h1>
<section>
<h2>Network Information</h2>
<dl>
{% if r.hostname %}
<dh>Hostname</dh>
<dd><a href="/dig?name={{r.hostname}}">{{r.hostname}}</a></dd>
{% endif %}
{% if r.asn %}
<dh><abbr="Autonomous System Number">ASN</abbr></dh>
<dd>AS{{r.asn.asn}}</dd>
<dh>AS Name</dh>
<dd>{{ r.asn.name }}</dd>
</dl>
{% endif %}
</section>
{% if r.location %}
<section>
<h2>Geolocation</h2>
<dl>
{{ helper::place_dl(place=r.location.continent, label="Continent") }}
{{ helper::place_dl(place=r.location.country, label="Country") }}
{{ helper::place_dl(place=r.location.registered_country, label="Registred in") }}
{{ helper::place_dl(place=r.location.represented_country, label="Represents") }}
{% if r.location.subdivisions %}
{% for sd in r.location.subdivisions %}
{{ helper::place_dl(place=sd, label="Subdivision", iso_code_prefix=r.location.country.iso_code|default(value="")) }}
{% endfor %}
{% endif %}
{{ helper::place_dl(place=r.location.city, label="City") }}
{% if r.location.postal_code %}
<dh>Postal Code</dh>
<dd>{{r.location.postal_code}}</dd>
{% endif %}
{% if r.location.time_zone %}
<dh>Timezone</dh>
<dd>{{r.location.time_zone}}</dd>
{% endif %}
</dl>
<!--We have to put that there to comply with maxminds licensing-->
<p><small>
The GeopIP and ASN information is provided by the GeoLite2 database created by
<a target="_blank" href="https://www.maxmind.com">MaxMind</a>.
</small></p>
</section>
{% endif %}
{% if data.user_agent %}
<section>
<h2>User Agent</h2>
<p>Independent of your IP-Address your browser sends a <a href="https://en.wikipedia.org/wiki/User_agent">User Agent</a> header with each http request.</p>
<p>Your browser sent: <code>{{data.user_agent}}</code></p>
</section>
{% endif %}
</body>
</html>
{% block title %}Your IP: {{ data.result.address }}{% endblock %}
{% block og_title %}What is my IP-Address?{% endblock %}
{% block h1 %}Your IPv{% if data.result.ip_info.is_v6_address %}6{% else %}4{% endif %}: <code>{{ data.result.address }}</code>{% endblock %}
{% block description %}
Look up Your and others public IP-Adresses. - {{ data.result.address }}
{% endblock %}
{% block og_path %}/{% endblock %}
{% block other_ip_button %}
<!-- TODO -->
{% endblock %}
{% block extra_content %}
<section>
<h2>Your User Agent</h2>
<p>The program you were using to download this page <a href="https://en.wikipedia.org/wiki/User_agent">identified itself</a> as <code>{{ data.user_agent }}</code></p>
<p>While this doesn't have to do anything with your public IP-Adress this might be useful information.</p>
<p>You can use the <code><a href="{{ extra.base_url}}/ua">/ua</a></code> endpoint to fetch this information with any client</p>
</section>
<section>
<h2>Did you know?</h2>
<p>If you share this site and the Link gets a preview. The IP-Address after the dash is the one of the machine that generated that preview</p>
</section>
{% endblock %}

View File

@ -1,18 +1,22 @@
{% extends "base.html" %}
{% import "helpers.html" as helper %}
<!DOCTYPE html>
<html>
<head>
<title>{{ data.query.ip }}</title>
</head>
<body>
{% block title %}{{ data.result.address }}{% endblock %}
{% block og_title %}Lookup {{ data.result.address }}{% endblock %}
{% block h1 %}Lookup <code>{{ data.result.address }}</code>{% endblock %}
{% block og_path %}/ip/{{ data.result.address }}{% endblock %}
{% block content %}
{% set r = data.result %}
<h1>About IP-Address: {{ data.query.ip }}</h1>
<section>
<h2>Network Information</h2>
<dl>
<dh>Type of Address</dh>
<dd>{{r.ip_info.scope}} {{r.ip_info.cast}} IPv{% if r.ip_info.is_v6_address %}6{% else %}4{% endif %}</dd>
{% if r.hostname %}
<dh>Hostname</dh>
<dd><a href="/dig?name={{r.hostname|trim_end_matches(pat=".")}}">{{r.hostname|trim_end_matches(pat=".")}}</a></dd>
<dd>{{ helper::dig(extra=extra, name=r.hostname) }}</dd>
{% endif %}
{% if r.asn %}
<dh><abbr="Autonomous System Number">ASN</abbr></dh>
@ -52,6 +56,6 @@
</small></p>
</section>
{% endif %}
</body>
</html>
{% block extra_content %}{% endblock %}
{% endblock %}

9
templates/message.html Normal file
View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}{{data.title}}{% endblock %}
{% block og_title %}{{ data.title }}{% endblock %}
{% block h1 %}{{ data.title }}{% endblock %}
{% block content %}
<p>{{data.mesage}}</p>
{% endblock %}