Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Check if running on Pi 3 for ninja mode #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Huber committed Jul 27, 2016
1 parent bd86b9d commit e224b50
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 23 deletions.
1 change: 0 additions & 1 deletion roles/django/files/django-uwsgi.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ After=syslog.target

[Service]
ExecStart=/usr/local/bin/uwsgi --ini /etc/uwsgi/upri_uwsgi.ini --touch-reload /etc/uwsgi/upri_uwsgi.ini
# Requires systemd version 211 or newer
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Expand Down
2 changes: 1 addition & 1 deletion upribox_interface/lib/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
4 changes: 2 additions & 2 deletions upribox_interface/more/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -108,7 +108,7 @@ msgid "Einschalten"
msgstr "switch On"

#: more/templates/more.html:42
msgid "Software Version"
msgid "upribox Software"
msgstr ""

#: more/templates/more.html:43
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
1 change: 1 addition & 0 deletions upribox_interface/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
url(r'^silent/$', "wlan.views.silent", name="upri_silent"),
url(r'^ninja/$', "wlan.views.ninja", name="upri_ninja"),
url(r'^ninja/toggle/$', "wlan.views.ninja_toggle", name="upri_ninja_toggle"),
url(r'^ninja/check_pi3/$', "wlan.views.check_pi3", name="upri_check_pi3"),
url(r'^jobstatus/$', "www.views.jobstatus", name="upri_jobstatus"),
url(r'^jobstatus/clear/$', "www.views.clear_jobstatus", name="upri_clear_jobstatus"),

Expand Down
2 changes: 1 addition & 1 deletion upribox_interface/vpn/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion upribox_interface/vpn/templates/vpn.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>{% trans "VPN" %}</h1>
<li>{% trans "UPnP oder NAT-PMP auf Ihrem Router (Gateway) aktivieren, oder" %}</li>
<li>{% trans "eine Port-Weiterleitung auf Ihrem Router für UDP-Port 1194 zu Ihrer upribox konfigurieren!" %}</li>
</ul>
<div>
</div>
<script>
function getCookie(name) {
var value = "; " + document.cookie;
Expand Down
Binary file modified upribox_interface/wlan/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
30 changes: 17 additions & 13 deletions upribox_interface/wlan/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -131,39 +131,43 @@ msgstr ""
"result in slower connection speed and websites being displayed in foreign "
"languages."

#: wlan/templates/ninja.html:26 wlan/templates/silent.html:18
#: wlan/templates/ninja.html:39
msgid "Das Ninja WiFi kann auf dem Raspberry Pi 3 nicht aktiviert werden."
msgstr "The Ninja WiFi can not be aktived on the Raspberry Pi 3."

#: wlan/templates/ninja.html:54 wlan/templates/silent.html:18
msgid "Ein-/Ausschalten"
msgstr "enable/Off"

#: wlan/templates/ninja.html:32
#: wlan/templates/ninja.html:60
msgid "Ninja Modus läuft"
msgstr "ninja mode active"

#: wlan/templates/ninja.html:33
#: wlan/templates/ninja.html:61
msgid "Ausschalten"
msgstr "disable"

#: wlan/templates/ninja.html:37
#: wlan/templates/ninja.html:65
msgid "Ninja Modus läuft nicht"
msgstr "ninja mode inactive"

#: wlan/templates/ninja.html:38
#: wlan/templates/ninja.html:66
msgid "Einschalten"
msgstr "enable"

#: wlan/templates/ninja.html:47 wlan/templates/silent.html:26
#: wlan/templates/ninja.html:75 wlan/templates/silent.html:26
msgid "WLAN Zugangsdaten"
msgstr "WiFi configuration"

#: wlan/templates/ninja.html:55 wlan/templates/silent.html:33
#: wlan/templates/ninja.html:83 wlan/templates/silent.html:33
msgid "Information einklappen"
msgstr "hide information"

#: wlan/templates/ninja.html:55
#: wlan/templates/ninja.html:83
msgid "Was ist der Ninja Modus?"
msgstr "What's behind the ninja mode?"

#: wlan/templates/ninja.html:57
#: wlan/templates/ninja.html:85
msgid ""
"Im Ninja-Modus befinden Sie sich in einem anonymen Netzwerk (Tor), womit "
"eine Nachverfolgung Ihrer Aktivit&auml;ten im Internet erschwert wird. So "
Expand All @@ -177,11 +181,11 @@ msgstr ""
"see which websites you access. Your requests are tunneled through multiple "
"Tor relays which may cause reduction of your internet speed."

#: wlan/templates/ninja.html:59
#: wlan/templates/ninja.html:87
msgid "Im Ninja-Modus sind alle Eigenschaften des Silent Modus integriert."
msgstr "All advantages of the silent mode are integrated in the ninja mode."

#: wlan/templates/ninja.html:61
#: wlan/templates/ninja.html:89
#, python-format
msgid ""
"H&auml;ufig gestellte Fragen zur upribox finden Sie unter <a href="
Expand All @@ -190,7 +194,7 @@ msgstr ""
"Answers to frequently asked questions (FAQ) can be found here: <a href="
"\"%(faq_url)s\" title=\"FAQ\">Help</a>."

#: wlan/templates/ninja.html:62 wlan/templates/silent.html:38
#: wlan/templates/ninja.html:90 wlan/templates/silent.html:38
msgid "Information ausblenden"
msgstr "hide information"

Expand Down
29 changes: 28 additions & 1 deletion upribox_interface/wlan/templates/ninja.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,34 @@ <h1>{% trans "Ninja Modus" %}</h1>
Wir empfehlen die Nutzung des Tor-Browser-Bundle (Download f&uuml;r <a href="{{ windows }}">Windows</a>, <a href="{{ macos }}">Mac OS</a> oder <a href="{{ linux }}">Linux</a>). Sollten Sie keine M&ouml;glichkeit haben, den Tor-Browser zu nutzen, k&ouml;nnen Sie als Alternative den Ninja Modus einschalten. Dieser gew&auml;hrleistet aber nicht das volle Surferlebnis (etwa durch langsame Geschwindigkeit und Webseiten in fremder Sprache).
{% endblocktrans %}</strong></p>

<div class="row clearfix">
<script>
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
var http = new XMLHttpRequest();
var url = "{% url 'upri_check_pi3' %}"
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
result = JSON.parse(http.responseText);
if (result['pi3'].localeCompare("yes") == 0) {
document.getElementById("ninja_toggle").innerHTML = '<h2 class="warning-message">{% trans "Das Ninja WiFi kann auf dem Raspberry Pi 3 nicht aktiviert werden." %}</h2>';
}
}
}
http.send('');

</script>

<div class="row clearfix" id="ninja_toggle">
<div class="col-2 col-2-main js-col-2-main">

<form>
Expand Down
15 changes: 14 additions & 1 deletion upribox_interface/wlan/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
from wlan import jobs as wlanjobs
from django.core.urlresolvers import reverse
from lib import utils
from lib.info import HardwareInfo
from django.http import HttpResponse

# Get an instance of a logger
logger = logging.getLogger('uprilogger')


@login_required
def ninja(request):
context = RequestContext(request)
Expand All @@ -39,6 +42,7 @@ def ninja(request):

return render_to_response("ninja.html", context)


@login_required
def ninja_toggle(request):
if request.method != 'POST':
Expand Down Expand Up @@ -70,4 +74,13 @@ def silent(request):

context.push({'form': form})
context.push({'messagestore': jobs.get_messages()})
return render_to_response("silent.html", context)
return render_to_response("silent.html", context)


@login_required
def check_pi3(request):
hw = HardwareInfo()
if hw.runs_on_pi3():
return HttpResponse('{"pi3": "yes"}')
else:
return HttpResponse('{"pi3": "no"}')
2 changes: 1 addition & 1 deletion upribox_interface/www/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-25 14:14+0000\n"
"POT-Creation-Date: 2016-07-27 11:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down

0 comments on commit e224b50

Please sign in to comment.