Check user-agent to serve different CSS for mobile
This commit is contained in:
parent
b08abf01c0
commit
d47683dc02
2
bashserv
2
bashserv
@ -1 +1 @@
|
|||||||
Subproject commit b408fd74161e03f3f670debf78df2473af4fb7ac
|
Subproject commit 99fcf7aa5be5210c082dd9c483717e1fb1204f93
|
@ -1,14 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "[$(date +%T)] GET $1 ($2)" >> get.log
|
echo "[$(date +%T)] GET $REQUEST_PATH_SANE ($REQUEST_PATH)" >> Get.log
|
||||||
|
|
||||||
./handle_requests.sh $@
|
./handle_requests.sh "$@"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$1" -o "$1" == "index.html" ]; then
|
while [[ $# -gt 0 ]]; do
|
||||||
body="<html>\n<head>\n<title>$WAKEBOARD_TITLE</title>\n<script type='text/javascript' src='main.js'></script>\n<link rel='stylesheet' href='main.css'></link>\n</head>\n"
|
length="$1"
|
||||||
|
key="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
|
||||||
|
value=""
|
||||||
|
for i in $(seq 1 $length); do
|
||||||
|
value+="$1 "
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
User-Agent)
|
||||||
|
if [[ $value =~ Mobile ]]; then
|
||||||
|
mobile=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
|
||||||
|
body="<html>\n<head>\n<title>$WAKEBOARD_TITLE</title>\n<script type='text/javascript' src='main.js'></script>\n"
|
||||||
|
if [ $mobile ]; then
|
||||||
|
body+="<link rel='stylesheet' href='mobile.css'></link>\n</head>\n"
|
||||||
|
else
|
||||||
|
body+="<link rel='stylesheet' href='main.css'></link>\n</head>\n"
|
||||||
|
fi
|
||||||
|
|
||||||
body+="<body>\n<table>\n<tr><td></td><td>Hostname</td><td>IP Address</td><td>MAC Address</td><td>Wakeup</td></tr>\n"
|
body+="<body>\n<table>\n<tr><td></td><td>Hostname</td><td>IP Address</td><td>MAC Address</td><td>Wakeup</td></tr>\n"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ "$1" =~ ^refresh ]]; then
|
if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then
|
||||||
ip=$(echo "$1" | cut -d '/' -f2)
|
ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
|
||||||
|
|
||||||
body="{\n\"time\": \"$(date +%T)\",\n"
|
body="{\n\"time\": \"$(date +%T)\",\n"
|
||||||
body+="\"status\": \"unknown\"\n}\n"
|
body+="\"status\": \"unknown\"\n}\n"
|
||||||
@ -30,8 +30,8 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" =~ ^status ]]; then
|
if [[ "$REQUEST_PATH_SANE" =~ ^status ]]; then
|
||||||
ip=$(echo "$1" | cut -d '/' -f2)
|
ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
|
||||||
|
|
||||||
if [ ! -r "status/$ip" ]; then
|
if [ ! -r "status/$ip" ]; then
|
||||||
body="{\n\"status\": \"unknown\"\n}\n"
|
body="{\n\"status\": \"unknown\"\n}\n"
|
||||||
@ -46,8 +46,8 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" =~ ^wol ]]; then
|
if [[ "$REQUEST_PATH_SANE" =~ ^wol ]]; then
|
||||||
mac=$(echo "$1" | cut -d '/' -f2)
|
mac=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
|
||||||
|
|
||||||
wol "$mac" > /dev/null
|
wol "$mac" > /dev/null
|
||||||
body="{\"response\": \"ok\"}\n"
|
body="{\"response\": \"ok\"}\n"
|
||||||
|
7
static/mobile.css
Normal file
7
static/mobile.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
body {
|
||||||
|
background: #aa0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
background: #bbbbbb;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user