From ced83335a5a338cb9c24956b96da526465d94df8 Mon Sep 17 00:00:00 2001 From: ficus Date: Sat, 15 Sep 2012 22:50:14 +0200 Subject: refactor to distributable format --- torouterui/templates/base.html | 75 +++++++++++++++++++++++++++++++++ torouterui/templates/home.html | 71 +++++++++++++++++++++++++++++++ torouterui/templates/lan.html | 32 ++++++++++++++ torouterui/templates/lib.html | 84 +++++++++++++++++++++++++++++++++++++ torouterui/templates/logs.html | 9 ++++ torouterui/templates/processes.html | 28 +++++++++++++ torouterui/templates/reboot.html | 22 ++++++++++ torouterui/templates/tor.html | 19 +++++++++ torouterui/templates/wan.html | 35 ++++++++++++++++ torouterui/templates/wifi.html | 38 +++++++++++++++++ 10 files changed, 413 insertions(+) create mode 100644 torouterui/templates/base.html create mode 100644 torouterui/templates/home.html create mode 100644 torouterui/templates/lan.html create mode 100644 torouterui/templates/lib.html create mode 100644 torouterui/templates/logs.html create mode 100644 torouterui/templates/processes.html create mode 100644 torouterui/templates/reboot.html create mode 100644 torouterui/templates/tor.html create mode 100644 torouterui/templates/wan.html create mode 100644 torouterui/templates/wifi.html (limited to 'torouterui/templates') diff --git a/torouterui/templates/base.html b/torouterui/templates/base.html new file mode 100644 index 0000000..4c15c73 --- /dev/null +++ b/torouterui/templates/base.html @@ -0,0 +1,75 @@ + + + + torouter configuration interface + + + + + + + +
+
+
+ +
+
+ {% if messages %} + {{ mesages }} + {% for category, message in messages %} +
+ + {% if category == "warning" %}Warning:{% endif %} + {% if category == "error" %}Error:{% endif %} + {% if category == "info" %}Note:{% endif %} + {{ message }} +
+ {% endfor %} + {% endif %} +{% block body %}{% endblock %} +
+
+
+
+

© torouter, copyleft 2012

+
+
+ + + diff --git a/torouterui/templates/home.html b/torouterui/templates/home.html new file mode 100644 index 0000000..fa2ed2b --- /dev/null +++ b/torouterui/templates/home.html @@ -0,0 +1,71 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + + +
+
+

System

+ + + + +
Host Name + {{ status.system.hostname }} +
Current Time + {{ status.system.current_time }} +
System Uptime + {{ status.system.uptime }} +
+
+
+

Resources

+
    +
  • + CPU Load{{status.resources.cpu_load}} / {{status.resources.cpu_cores}} cores +
    +
    +
    +
  • +
  • RAM Usage{{status.resources.ram_used}} / {{status.resources.ram_avail}} +
    +
    +
    +
  • +
  • Primary Disk Space{{status.resources.disk_used}} / {{status.resources.disk_avail}} +
    +
    +
    +
  • +
+
+
+
+
+

WAN

+ {{ lib.ifstatus(status.wan) }} +
+
+

LAN

+ {{ lib.ifstatus(status.lan) }} +
+
+
+
+

WiFi

+ {{ lib.ifstatus(status.wifi) }} +
+
+

Tor

+ + +
Status + + {{ status.tor.state }} + +
+
+
+ +{% endblock %} diff --git a/torouterui/templates/lan.html b/torouterui/templates/lan.html new file mode 100644 index 0000000..09bcf0a --- /dev/null +++ b/torouterui/templates/lan.html @@ -0,0 +1,32 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + +
+Local Ethernet Configuration + +{% if not status.lan %} +Could not find the local ethernet hardware device! +{% else %} + +{{ lib.formcheckbox(form, formerr, 'ipv4enable', 'Enable this interface', 'true') }} + +Address Configuration +{{ lib.forminput(form, formerr, 'ipv4addr', 'IPv4 Address', '0.0.0.0') }} +{{ lib.forminput(form, formerr, 'ipv4netmask', 'Netmask', '255.255.0.0') }} +{{ lib.forminput(form, formerr, 'ipv4gateway', 'Gateway IP Address', '0.0.0.0') }} + +DHCP Configuration +{{ lib.forminput(form, formerr, 'dhcpbase', 'DHCP Range Base', '192.168.1.100') }} +{{ lib.forminput(form, formerr, 'dhcptop', 'DHCP Range Top', '192.168.1.200') }} +{{ lib.forminput(form, formerr, 'dhcptime', 'Lease Time', '12h') }} + +
+ + +
+
+{% endif %} + +{% endblock %} diff --git a/torouterui/templates/lib.html b/torouterui/templates/lib.html new file mode 100644 index 0000000..6ac5e12 --- /dev/null +++ b/torouterui/templates/lib.html @@ -0,0 +1,84 @@ + + +{% macro ifstatus(ifstatus) -%} +{% if not ifstatus %} + +Network hardware not detected at all! + +{% else %} + + + + + + + + + + +
Interface Name + {{ ifstatus.ifname }} +
Status + + {{ ifstatus.state }} + +
MAC Address + {{ ifstatus.mac }} +
IPv4 Addresses + + {% for addr in ifstatus.ipv4addrs %} + {{ addr.addr }}/{{ addr.prefix}} ({{ addr.scope }})
+ {% endfor %}
+
IPv6 Addresses + + {% for addr in ifstatus.ipv6addrs %} + {{ addr.addr }}/{{ addr.prefix}} ({{ addr.scope }})
+ {% endfor %}
+ {% if ifstatus.radio_state %} +
Radio State + {{ ifstatus.radio_state }} +
SSID + {{ ifstatus.ssid }} +
Frequency + {{ ifstatus.freq }} +
Signal Strength + {{ ifstatus.signal_dbm }} + {% endif %} +
+{% endif %} +{%- endmacro %} + + +{% macro logbox(name, contents) -%} +

{{name}}

+{% if contents == None %} +Access to {{name}} was denied, or file did not exist. +{% else %} +
+
+{{ contents }}
+
+
+{% endif%} +{%- endmacro %} + + +{% macro forminput(form, formerr, name, title, placeholder) -%} +
+ +
+ + {% if formerr[name] %} + {{ formerr[name] }} + {% endif %} +
+
+{%- endmacro %} + +{% macro formcheckbox(form, formerr, name, title, value) -%} + +{% endmacro %} diff --git a/torouterui/templates/logs.html b/torouterui/templates/logs.html new file mode 100644 index 0000000..c5ea52a --- /dev/null +++ b/torouterui/templates/logs.html @@ -0,0 +1,9 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + +{{ lib.logbox("dmesg", logs.dmesg) }} +{{ lib.logbox("auth.log", logs.authlog) }} +{{ lib.logbox("syslog", logs.syslog) }} + +{% endblock %} diff --git a/torouterui/templates/processes.html b/torouterui/templates/processes.html new file mode 100644 index 0000000..2e35162 --- /dev/null +++ b/torouterui/templates/processes.html @@ -0,0 +1,28 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} +

System Running Process List

+ + + +
User + PID + %CPU + %MEM + Status + Started + Time + Command +{% for proc in process_list %} +
{{ proc.user }} + {{ proc.pid}} + {{ proc.perc_cpu }} + {{ proc.perc_mem }} + {{ proc.status_code }} + {{ proc.started }} + {{ proc.time }} +
{{ proc.command }}
+{% endfor %} +
+ +{% endblock %} diff --git a/torouterui/templates/reboot.html b/torouterui/templates/reboot.html new file mode 100644 index 0000000..b9f0c54 --- /dev/null +++ b/torouterui/templates/reboot.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% block body %} +

System Reboot

+ +{% if status == 'rebooting' %} + +Rebooting! This interface will stop working in a few seconds, check back in a +minute or two... + +{% else %} +
+Are you sure you'd like to restart? This could have reprecussions! +
+ + +
+{% endif %} + +{% endblock %} diff --git a/torouterui/templates/tor.html b/torouterui/templates/tor.html new file mode 100644 index 0000000..a1f30dc --- /dev/null +++ b/torouterui/templates/tor.html @@ -0,0 +1,19 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + +
+Tor Network Configuration + +{{ lib.formcheckbox(form, formerr, 'torenable', 'Enable Tor daemon', 'true') }} +{{ lib.formcheckbox(form, formerr, 'torrelayenable', 'Enable Tor Relay', 'true') }} +{{ lib.formcheckbox(form, formerr, 'torbridgeenable', 'Enable Tor Bridge', 'true') }} + +
+ + +
+
+ +{% endblock %} diff --git a/torouterui/templates/wan.html b/torouterui/templates/wan.html new file mode 100644 index 0000000..2da2733 --- /dev/null +++ b/torouterui/templates/wan.html @@ -0,0 +1,35 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + +
+Upstream Ethernet Configuration + + + + + +{{ lib.forminput(form, formerr, 'ipv4addr', 'IPv4 Address', '0.0.0.0') }} +{{ lib.forminput(form, formerr, 'ipv4netmask', 'Netmask', '255.255.255.0') }} +{{ lib.forminput(form, formerr, 'ipv4gateway', 'Gateway IP Address', '0.0.0.0') }} + + + +
+ + +
+
+ + +{% endblock %} diff --git a/torouterui/templates/wifi.html b/torouterui/templates/wifi.html new file mode 100644 index 0000000..3e41788 --- /dev/null +++ b/torouterui/templates/wifi.html @@ -0,0 +1,38 @@ +{% import "lib.html" as lib %} +{% extends "base.html" %} +{% block body %} + +
+WiFi Configuration + +{% if not status.wifi %} +Could not find the WiFi hardware device! +{% else %} + +{{ lib.formcheckbox(form, formerr, 'wifienable', 'Enable the radio', 'true') }} +{{ lib.formcheckbox(form, formerr, 'torifylanenable', 'Transparently "Tor-ify" this network interface', 'true') }} + +Radio +{{ lib.forminput(form, formerr, 'wifissid', 'SSID name', 'internet') }} +{{ lib.forminput(form, formerr, 'wifipower', 'Transmit Power', 'high, low') }} +{{ lib.forminput(form, formerr, 'wifichannel', 'Channel', '11') }} + +Network Address +{{ lib.forminput(form, formerr, 'ipv4addr', 'IPv4 Address', '0.0.0.0') }} +{{ lib.forminput(form, formerr, 'ipv4netmask', 'Netmask', '255.255.0.0') }} +{{ lib.forminput(form, formerr, 'ipv4gateway', 'Gateway IP Address', '0.0.0.0') }} + +DHCP Server +{{ lib.forminput(form, formerr, 'dhcpbase', 'DHCP Range Base', '192.168.1.100') }} +{{ lib.forminput(form, formerr, 'dhcptop', 'DHCP Range Top', '192.168.1.200') }} +{{ lib.forminput(form, formerr, 'dhcptime', 'Lease Time', '12h') }} + +
+ + +
+
+{% endif %} + +{% endblock %} -- cgit v1.2.3