Compare commits

..

20 Commits

Author SHA1 Message Date
7587c896b9 commented out service worker 2021-10-25 11:49:31 +03:00
8f85844161 added DOCTYPE - all pages 2021-10-25 11:45:29 +03:00
119dbe9d94 general cleanup 2021-10-25 11:44:16 +03:00
4dd6184743 added icon 2021-10-07 12:37:21 +03:00
888670cf43 added DOCTYPE - all pages 2021-10-07 12:29:24 +03:00
2c5adc30e2 test pwabuilder 2021-10-07 12:14:23 +03:00
f794f5049d fix typo 2021-10-07 11:28:02 +03:00
19a955525e added support to use as a PWA 2021-10-07 11:18:32 +03:00
dc0e4d5c57 fix stats.sh to remove trailing zeroes which make the graph fail 2021-10-07 11:17:25 +03:00
7fe3991303 fixed debug mistake in stats.sh 2021-10-07 09:54:13 +03:00
c1629af49d fixed stats.sh to work again 2021-10-07 09:52:36 +03:00
9ea8abb55b add manifest.json 2021-10-07 08:57:30 +03:00
b01b0b2f61 make site optimized for mobile - all pages 2021-10-07 08:53:19 +03:00
f73748b245 fix test script to check status 2021-10-06 14:30:31 +03:00
7d17c356fd add test script to check status 2021-10-06 14:03:38 +03:00
ffffa3b2a9 updated light_cuts.csv 2021-10-04 19:15:47 +03:00
cec9667499 fix permissions in stats 2021-10-04 10:06:21 +03:00
af63b334e6 fix grammar on page 2021-10-01 13:24:12 +03:00
74ece0f39a added date and time update stats page 2021-10-01 13:19:47 +03:00
61705c60b8 fixed relative path in output stats html page 2021-10-01 13:04:52 +03:00
12 changed files with 161 additions and 138 deletions

View File

@@ -1,9 +0,0 @@
2021/09/23,04.50
2021/09/24,05.71
2021/09/25,08.86
2021/09/26,07.53
2021/09/27,08.63
2021/09/28,08.31
2021/09/29,12.0
2021/09/30,11.65
2021/10/01,06.41
1 2021/09/23 04.50
2 2021/09/24 05.71
3 2021/09/25 08.86
4 2021/09/26 07.53
5 2021/09/27 08.63
6 2021/09/28 08.31
7 2021/09/29 12.0
8 2021/09/30 11.65
9 2021/10/01 06.41

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -60,4 +60,24 @@ OFF,2021/09/30 14:05
ON,2021/09/30 18:18
OFF,2021/09/30 23:58
OFF,2021/10/01 00:00
ON,2021/10/01 06:31
OFF,2021/10/01 10:02
ON,2021/10/01 14:04
OFF,2021/10/01 17:56
ON,2021/10/01 18:05
OFF,2021/10/01 18:05
ON,2021/10/01 21:10
ON,2021/10/02 00:00
OFF,2021/10/02 05:15
ON,2021/10/02 08:21
ON,2021/10/02 08:21
OFF,2021/10/02 23:52
OFF,2021/10/03 00:00
ON,2021/10/03 06:03
OFF,2021/10/03 13:05
ON,2021/10/03 14:05
OFF,2021/10/03 20:52
ON,2021/10/03 23:33
ON,2021/10/04 00:00
OFF,2021/10/04 04:36
ON,2021/10/04 07:57
1 status date
60 ON 2021/09/30 18:18
61 OFF 2021/09/30 23:58
62 OFF 2021/10/01 00:00
63 ON 2021/10/01 06:31
64 OFF 2021/10/01 10:02
65 ON 2021/10/01 14:04
66 OFF 2021/10/01 17:56
67 ON 2021/10/01 18:05
68 OFF 2021/10/01 18:05
69 ON 2021/10/01 21:10
70 ON 2021/10/02 00:00
71 OFF 2021/10/02 05:15
72 ON 2021/10/02 08:21
73 ON 2021/10/02 08:21
74 OFF 2021/10/02 23:52
75 OFF 2021/10/03 00:00
76 ON 2021/10/03 06:03
77 OFF 2021/10/03 13:05
78 ON 2021/10/03 14:05
79 OFF 2021/10/03 20:52
80 ON 2021/10/03 23:33
81 ON 2021/10/04 00:00
82 OFF 2021/10/04 04:36
83 ON 2021/10/04 07:57

11
manifest.json Normal file
View File

@@ -0,0 +1,11 @@
{
"background_color": "#242424",
"dir": "ltr",
"display": "standalone",
"name": "Generator Status",
"orientation": "any",
"scope": "/",
"short_name": "Generator Status",
"start_url": "/",
"theme_color": "#242424"
}

View File

@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
<!-- <script type="module">
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
const el = document.createElement('pwa-update');
document.body.appendChild(el);
</script> -->
<title>Generator Status...</title>
<style>
* {
@@ -76,7 +84,7 @@
<p>The generator is <b>ON</b> :(</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>last updated on: <b>date-n-time-placeholder</b></p>
</div>
</div>
<div class="status-bg-off nothidden">
@@ -84,7 +92,7 @@
<p>The generator is <b>OFF!</b> :)</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>last updated on: <b>date-n-time-placeholder</b></p>
</div>
</div>
<div class="credits">

View File

@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
<!-- <script type="module">
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
const el = document.createElement('pwa-update');
document.body.appendChild(el);
</script> -->
<title>Generator Status...</title>
<style>
* {
@@ -58,62 +66,16 @@
<div class="title-bg">
<div class="title-text">
<p>Generator Stats</p>
<p>You're Offline</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>please check your internet connection</p>
</div>
</div>
<div class="chart_last_week_class">
<canvas id="chart_last_week"></canvas>
</div>
<div class="credits">
<p>Made with ❤️ | Source Code: <a href="https://git.sandcastle.eu.org/thebiblelover7/generator-status">Gitea</a>
<br>
Thanks to <a href="https://matrix.to/#/@junyong_chung:tchncs.de">Junyong Chung</a> for the hardware and <a href="https://meu.edu.lb">MEU</a> for providing the domain.</p>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const labels = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
];
const data = {
labels: labels,
datasets: [{
label: 'Hours we had electricity from government',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [8.86, 7.53, 8.63, 8.31, 12., 11.65, 6.41],
fill: {
target: 'origin',
above: 'rgb(255, 0, 0)', // Area will be red above the origin
below: 'rgb(0, 0, 255)' // And blue below the origin
},
}]
};
const config = {
type: 'line',
data: data,
options: {
scales: {
y: {
beginAtZero: true,
max: 24,
}
}
}
};
var chart_last_week = new Chart(
document.getElementById('chart_last_week'),
config
);
</script>
</html>

12
on.html
View File

@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
<!-- <script type="module">
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
const el = document.createElement('pwa-update');
document.body.appendChild(el);
</script> -->
<title>Generator Status...</title>
<style>
* {
@@ -76,7 +84,7 @@
<p>The generator is <b>ON</b> :(</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>last updated on: <b>date-n-time-placeholder</b></p>
</div>
</div>
<div class="status-bg-off hidden">
@@ -84,7 +92,7 @@
<p>The generator is <b>OFF!</b> :)</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>last updated on: <b>date-n-time-placeholder</b></p>
</div>
</div>
<div class="credits">

67
pwabuilder-sw.js Normal file
View File

@@ -0,0 +1,67 @@
// This is the "Offline page" service worker
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
const CACHE = "pwabuilder-page";
// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html";
const offlineFallbackPage = "offline.html";
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
self.addEventListener('install', async (event) => {
event.waitUntil(
caches.open(CACHE)
.then((cache) => cache.add(offlineFallbackPage))
);
});
if (workbox.navigationPreload.isSupported()) {
workbox.navigationPreload.enable();
}
self.addEventListener('fetch', (event) => {
if (event.request.mode === 'navigate') {
event.respondWith((async () => {
try {
const preloadResp = await event.preloadResponse;
if (preloadResp) {
return preloadResp;
}
const networkResp = await fetch(event.request);
return networkResp;
} catch (error) {
const cache = await caches.open(CACHE);
const cachedResp = await cache.match(offlineFallbackPage);
return cachedResp;
}
})());
}
});
// This is the service worker with the Cache-first network
const CACHE = "pwabuilder-precache";
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.CacheFirst({
cacheName: CACHE
})
);

View File

@@ -1,62 +0,0 @@
ON, 2021/09/23, 06:58
ON, 2021/09/23, 07:13
OFF, 2021/09/23, 00:23
ON, 2021/09/23, 03:30
OFF, 2021/09/23, 03:01
ON, 2021/09/23, 01:49
OFF, 2021/09/23, 01:06
OFF, 2021/09/24, 00:22
ON, 2021/09/24, 03:51
OFF, 2021/09/24, 03:26
ON, 2021/09/24, 08:39
OFF, 2021/09/24, 00:49
ON, 2021/09/24, 00:55
OFF, 2021/09/24, 01:06
ON, 2021/09/24, 04:52
ON, 2021/09/25, 03:36
OFF, 2021/09/25, 02:40
ON, 2021/09/25, 05:45
OFF, 2021/09/25, 02:04
ON, 2021/09/25, 03:21
OFF, 2021/09/25, 01:04
ON, 2021/09/25, 02:26
OFF, 2021/09/25, 03:04
OFF, 2021/09/26, 00:02
ON, 2021/09/26, 03:30
OFF, 2021/09/26, 04:36
ON, 2021/09/26, 05:36
OFF, 2021/09/26, 01:20
ON, 2021/09/26, 02:17
OFF, 2021/09/26, 01:34
ON, 2021/09/26, 05:05
ON, 2021/09/27, 00:02
OFF, 2021/09/27, 06:07
ON, 2021/09/27, 04:53
OFF, 2021/09/27, 01:00
ON, 2021/09/27, 07:31
OFF, 2021/09/27, 01:31
ON, 2021/09/27, 02:56
ON, 2021/09/28, 05:59
OFF, 2021/09/28, 03:49
ON, 2021/09/28, 05:36
OFF, 2021/09/28, 00:57
ON, 2021/09/28, 00:02
OFF, 2021/09/28, 02:33
ON, 2021/09/28, 04:04
OFF, 2021/09/28, 01:00
OFF, 2021/09/29, 06:30
ON, 2021/09/29, 05:35
OFF, 2021/09/29, 01:57
ON, 2021/09/29, 06:25
OFF, 2021/09/29, 03:33
OFF, 2021/09/30, 00:05
ON, 2021/09/30, 03:39
OFF, 2021/09/30, 04:41
ON, 2021/09/30, 00:56
OFF, 2021/09/30, 02:38
ON, 2021/09/30, 02:06
OFF, 2021/09/30, 04:13
ON, 2021/09/30, 05:40
OFF, 2021/09/30, 00:02
OFF, 2021/10/01, 06:25
OFF, 2021/10/01, 00:00
1 ON 2021/09/23 06:58
2 ON 2021/09/23 07:13
3 OFF 2021/09/23 00:23
4 ON 2021/09/23 03:30
5 OFF 2021/09/23 03:01
6 ON 2021/09/23 01:49
7 OFF 2021/09/23 01:06
8 OFF 2021/09/24 00:22
9 ON 2021/09/24 03:51
10 OFF 2021/09/24 03:26
11 ON 2021/09/24 08:39
12 OFF 2021/09/24 00:49
13 ON 2021/09/24 00:55
14 OFF 2021/09/24 01:06
15 ON 2021/09/24 04:52
16 ON 2021/09/25 03:36
17 OFF 2021/09/25 02:40
18 ON 2021/09/25 05:45
19 OFF 2021/09/25 02:04
20 ON 2021/09/25 03:21
21 OFF 2021/09/25 01:04
22 ON 2021/09/25 02:26
23 OFF 2021/09/25 03:04
24 OFF 2021/09/26 00:02
25 ON 2021/09/26 03:30
26 OFF 2021/09/26 04:36
27 ON 2021/09/26 05:36
28 OFF 2021/09/26 01:20
29 ON 2021/09/26 02:17
30 OFF 2021/09/26 01:34
31 ON 2021/09/26 05:05
32 ON 2021/09/27 00:02
33 OFF 2021/09/27 06:07
34 ON 2021/09/27 04:53
35 OFF 2021/09/27 01:00
36 ON 2021/09/27 07:31
37 OFF 2021/09/27 01:31
38 ON 2021/09/27 02:56
39 ON 2021/09/28 05:59
40 OFF 2021/09/28 03:49
41 ON 2021/09/28 05:36
42 OFF 2021/09/28 00:57
43 ON 2021/09/28 00:02
44 OFF 2021/09/28 02:33
45 ON 2021/09/28 04:04
46 OFF 2021/09/28 01:00
47 OFF 2021/09/29 06:30
48 ON 2021/09/29 05:35
49 OFF 2021/09/29 01:57
50 ON 2021/09/29 06:25
51 OFF 2021/09/29 03:33
52 OFF 2021/09/30 00:05
53 ON 2021/09/30 03:39
54 OFF 2021/09/30 04:41
55 ON 2021/09/30 00:56
56 OFF 2021/09/30 02:38
57 ON 2021/09/30 02:06
58 OFF 2021/09/30 04:13
59 ON 2021/09/30 05:40
60 OFF 2021/09/30 00:02
61 OFF 2021/10/01 06:25
62 OFF 2021/10/01 00:00

View File

@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
<!-- <script type="module">
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
const el = document.createElement('pwa-update');
document.body.appendChild(el);
</script> -->
<title>Generator Status...</title>
<style>
* {
@@ -61,7 +69,7 @@
<p>Generator Stats</p>
</div>
<div class="date-time-updated">
<p>last updated at: <b>date-n-time-placeholder</b></p>
<p>last updated on: <b>date-n-time-placeholder</b></p>
</div>
</div>
<div class="chart_last_week_class">

View File

@@ -78,27 +78,31 @@ lines=$(cat days.csv | grep -c ,)
line=0
line_start=$(( $lines - 7 ))
day_num=0
#echo "$lines - lines, $line_start - line_start"
while read in
do
hours=$(echo $in | cut -d, -f2)
line=$(( $line + 1 ))
hours=10#$(echo $in | cut -d, -f2)
line=10#$(( $line + 1 ))
date_var=$(echo $in | cut -d, -f1)
if [[ $line > $line_start ]]
# echo "$line - line, $date_var - date, $hours - hours, $day_num - day_num"
if [[ $line -gt $line_start ]]
then
# echo "LINE IS GREATER"
day_num=$(( $day_num + 1 ))
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); day_date_1=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); day_date_2=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); day_date_3=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); day_date_4=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); day_date_5=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); day_date_6=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); day_date_7=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_1=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_2=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_3=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_4=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_5=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_6=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed -n -e 's/0\([0-9]\)/\1/g' -e p); day_date_7=$(echo $date_var | sed 's/\//\\\//g'); fi
fi
done < days.csv
hours_so_far=$(($(TZ='Asia/Beirut' date +'%H') - $(echo $day_7. | cut -d. -f1)))
hours_so_far=10#$((10#$(TZ='Asia/Beirut' date +'%H') - $(echo $day_7. | cut -d. -f1)))
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" | sed "s/hours_so_far_day/$hours_so_far/" | sed "s/day_date_1/$day_date_1/" | sed "s/day_date_2/$day_date_2/" | sed "s/day_date_3/$day_date_3/" | sed "s/day_date_4/$day_date_4/" | sed "s/day_date_5/$day_date_5/" | sed "s/day_date_6/$day_date_6/" | sed "s/day_date_7/$day_date_7/" > /usr/local/apache2/htdocs/stats/index.html
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" | sed "s/hours_so_far_day/$hours_so_far/" | sed "s/day_date_1/$day_date_1/" | sed "s/day_date_2/$day_date_2/" | sed "s/day_date_3/$day_date_3/" | sed "s/day_date_4/$day_date_4/" | sed "s/day_date_5/$day_date_5/" | sed "s/day_date_6/$day_date_6/" | sed "s/day_date_7/$day_date_7/" | sed "s/date-n-time-placeholder/$(TZ='Asia/Beirut' date +'%b %d, %Y at %H:%M' | sed 's/\//\\\//g')/" | sed 's/10#//g' > ../htdocs/stats/index.html
chown daemon:daemon /usr/local/apache2/htdocs/stats/index.html
sudo chown -R daemon:daemon .
sudo chown daemon:daemon ../htdocs/stats/index.html

6
status-test.cgi Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "IT WORKS"