2013-12-18 01:14:58 +01:00

172 lines
9.6 KiB
HTML

{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="nsupdate.info team">
<title>{% block title %}{{ WWW_HOST }}{% endblock %}</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
<link href="{% static 'css/nsupdate.css' %}" rel="stylesheet">
<link rel="icon" type="image/png" href="{% static 'favicon.png' %}" />
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
{% include "includes/base_head.html" %}
{% block html_head %}{% endblock %}
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% url 'home' %}"><span style="color: #00ba00">&#x2B25;</span> {{ WWW_HOST }}</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li{% if nav_home %} class="active"{% endif %}>
<a href="{% url 'home' %}"><i class="fa fa-home fa-fw"></i> Home</a>
</li>
{% if request.user.is_authenticated %}
<li{% if nav_overview %} class="active"{% endif %}>
<a href="{% url 'overview' %}"><i class="fa fa-list fa-fw"></i> Hosts</a>
</li>
<li{% if nav_domain_overview %} class="active"{% endif %}>
<a href="{% url 'domain_overview' %}"><i class="fa fa-list fa-fw"></i> Domains</a>
</li>
<li{% if nav_status %} class="active"{% endif %}>
<a href="{% url 'status' %}"><i class="fa fa-list fa-fw"></i> Status</a>
</li>
{% endif %}
<li{% if nav_about %} class="active"{% endif %}>
<a href="{% url 'about' %}"><i class="fa fa-comment fa-fw"></i> About</a>
</li>
<li>
<a href="http://nsupdateinfo.readthedocs.org/"
class="navbar-link" title="Open docs in new window" target="_blank"><i class="fa fa-eye fa-fw"></i> Documentation</a>
</li>
</ul>
<ul class="nav navbar-nav pull-right">
{% if not request.user.is_authenticated %}
<li{% if nav_register %} class="active"{% endif %}><a href="{% url 'registration_register' %}"><i class="fa fa-asterisk fa-fw"></i> Register</a></li>
<li{% if nav_login %} class="active"{% endif %}><a href="{% url 'auth_login' %}"><i class="fa fa-sign-in fa-fw"></i> Login</a></li>
{% else %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user fa-fw"></i> {{ request.user.username }} <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{% url 'account_profile' %}"><i class="fa fa-cogs fa-fw"></i> Profile</a></li>
<li><a href="{% url 'auth_password_change' %}"><i class="fa fa-key fa-fw"></i> Change password</a></li>
{% if request.user.is_staff %}
<li><a href="/admin/"><i class="fa fa-wrench fa-fw"></i> Admin</a></li>
{% endif %}
<li><a href="{% url 'auth_logout' %}?next={% url 'auth_login' %}"><i class="fa fa-sign-out fa-fw"></i> Logout</a></li>
</ul>
</li>
{% endif %}
</ul>
</div>
</div>
</div>
{% block header %}{% endblock %}
<div class="container content wrap">
<div class="row">
<div class="col-lg-12">
<div id="message_box">
{% if not request.is_secure %}
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
Your (http) connection is unencrypted and thus insecure.
{% if WE_HAVE_SSL %}
Please use our <a href="https://{{ WWW_HOST }}/">secure https site</a>.
{% endif %}
{% if COOKIE_SECURE %}
At least some of the required cookies will only work on the secure https site,
expect malfunctioning on the http site.
{% endif %}
</div>
{% endif %}
<noscript>
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
Some functionality on this site requires that you have JavaScript enabled in your browser.
</div>
</noscript>
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }}">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ message }}
</div>
{% endfor %}
{% endif %}
</div>
</div>
</div>
{% block content %}
Here goes the content.
{% endblock %}
</div>
<div class="footer">
<div class="container">
{% include "includes/base_footer.html" %}
</div>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
<div id="ip_detection" style="display: none">
{% comment %}
Why IP detection it is implemented as it is
-------------------------------------------
a) we use javascript to insert the img tags after the document (DOM) is ready.
if we just have them in the html from the beginning, the browser would be visibly
"loading" until both "images" are loaded or timed out (if e.g. you don't have ip v6).
not nice.
b) we use fake img tags because doing it with jQuery.get() would be cross-domain:
WWW_HOST -> WWW_IPV4_HOST
WWW_HOST -> WWW_IPV6_HOST
c) yes, the setTimeout is rather unpretty and might not work for slow connections
(when loading the images take more than that timeout), making the IPs appear not
on the current view, but when the next view is loaded (or the current one reloaded).
if you have a better idea, this is something to improve.
d) we detect both ipv4 and v6 in the same way. this could be optimized to use the
REMOTE_ADDR we have from the view's http request and then only detect the other
kind of ip using the fake img approach.
OTOH, doing both IPs the same way is nicer as it is more symmetric.
{% endcomment %}
{% if not request.session.ipv4 or not request.session.ipv6 %}
<script type="text/javascript">
$(document).ready(function() {
{% if not request.session.ipv4 %}
$('#ip_detection').add(
'<img src="//{{ WWW_IPV4_HOST }}/detectip/{{ request.session.session_key }}/" >');
{% endif %}
{% if not request.session.ipv6 %}
$('#ip_detection').add(
'<img src="//{{ WWW_IPV6_HOST }}/detectip/{{ request.session.session_key }}/" >');
{% endif %}
function insert_ips() {
$.getJSON("{% url 'ajax_get_ips' %}")
.done(function(data) {
$('#ipv4').text(data['ipv4']);
$('#ipv4_rdns').text(data['ipv4_rdns']);
$('#ipv6').text(data['ipv6']);
$('#ipv6_rdns').text(data['ipv6_rdns']);
});
}
setTimeout(insert_ips, 1500);
setTimeout(insert_ips, 3000);
});
</script>
{% endif %}
</div>
{% include "includes/base_body.html" %}
</body>
</html>