From f9fa3aaf35b6d8a14966de204bc1ffbc3541ea46 Mon Sep 17 00:00:00 2001 From: sijanec Date: Sat, 29 Aug 2020 23:24:38 +0200 Subject: initial commit --- 192.png | Bin 0 -> 1877 bytes 512.png | Bin 0 -> 4403 bytes apache.conf | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 27 ++++++++++++++++ nginx.conf | 58 ++++++++++++++++++++++++++++++++++ offline.html | 25 +++++++++++++++ original.png | Bin 0 -> 2556 bytes redfox.js | 15 +++++++++ sw.js | 59 ++++++++++++++++++++++++++++++++++ "\305\276" | 58 ++++++++++++++++++++++++++++++++++ 10 files changed, 342 insertions(+) create mode 100644 192.png create mode 100644 512.png create mode 100644 apache.conf create mode 100644 manifest.json create mode 100644 nginx.conf create mode 100644 offline.html create mode 100644 original.png create mode 100644 redfox.js create mode 100644 sw.js create mode 100644 "\305\276" diff --git a/192.png b/192.png new file mode 100644 index 0000000..d07ebb3 Binary files /dev/null and b/192.png differ diff --git a/512.png b/512.png new file mode 100644 index 0000000..7cad0ef Binary files /dev/null and b/512.png differ diff --git a/apache.conf b/apache.conf new file mode 100644 index 0000000..fe63719 --- /dev/null +++ b/apache.conf @@ -0,0 +1,100 @@ +# substitute, proxy, headers, ssl, proxy_http, dump_io mods need enable: a2enmod + + SSLEngine On + SSLCertificateFile /etc/letsencrypt/live/teletekst.xn--jha.ga/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/teletekst.xn--jha.ga/privkey.pem + SSLProxyEngine On + SSLProxyCheckPeerCN Off + SSLProxyCheckPeerName Off + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + #ServerAdmin webmaster@localhost + #DocumentRoot /var/www/apache2 + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + RequestHeader unset Accept-Encoding + ProxyPreserveHost Off + ProxyPass "/" "https://teletext.rtvslo.si:443/" + ProxyPassReverse "/" "https://teletext.rtvslo.si:443/" + AddOutputFilterByType SUBSTITUTE text/html + Substitute "s|teletext.rtvslo.si|teletekst.xn--jha.ga|i" + Substitute "s/weird.function/console.log/i" + DumpIOInput Off + DumpIOOutput On + LogLevel dumpio:trace7 + LogLevel debug + + + +# ServerName cargova.xn--pga.ga +# SSLEngine On +# SSLCertificateFile /etc/ssl/sslforfree/sg.crt +# SSLCertificateKeyFile /etc/ssl/sslforfree/sg.key + SSLProxyEngine On + SSLProxyCheckPeerCN Off + SSLProxyCheckPeerName Off + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + #ServerAdmin webmaster@localhost + #DocumentRoot /var/www/apache2 + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + RequestHeader unset Accept-Encoding + ProxyPreserveHost Off + ProxyPass "/" "https://teletext.rtvslo.si:443/" + ProxyPassReverse "/" "https://teletext.rtvslo.si:443/" + AddOutputFilterByType SUBSTITUTE text/html + Substitute "s/teletext.rtvslo.si/teletekst.xn--jha.ga:2780/i" + Substitute "s/weird.function/console.log/i" + DumpIOInput Off + DumpIOOutput On + LogLevel dumpio:trace7 + LogLevel debug + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a93e9aa --- /dev/null +++ b/manifest.json @@ -0,0 +1,27 @@ +{ + "short_name": "Teletekst RTVSLO", + "name": "Teletekst RTV Slovenija", + "description": "Spletna aplikacija za branje teleteksta TV Slovenija", + "lang": "sl-SI", + "categories": [ + "productivity", + "utilities" + ], + "icons": [ + { + "src": "/192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "/512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": "/index.html", + "background_color": "#000000", + "display": "standalone", + "scope": "/", + "theme_color": "#000000" +} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ff71ccc --- /dev/null +++ b/nginx.conf @@ -0,0 +1,58 @@ +server { + listen 0.0.0.0:80; + listen [::]:80; + server_name .teletekst.xn--jha.ga; + return 301 https://teletekst.xn--jha.ga$request_uri; + port_in_redirect off; + server_name_in_redirect off; +} +server { + listen 0.0.0.0:443 ssl http2; + listen [::]:443 ssl http2; + ssl_certificate /etc/letsencrypt/live/teletekst.xn--jha.ga/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/teletekst.xn--jha.ga/privkey.pem; + ssl_session_cache builtin:1000 shared:SSL:10m; + ssl_prefer_server_ciphers on; + add_header Strict-Transport-Security "max-age=604800"; + index index.html; + server_name .teletekst.xn--jha.ga; + root /var/www/teletekst.xn--jha.ga; + location / { + set $cors ''; + set $both_conditions ""; + add_header "x-debug-location-gse" "triggered"; + if ($http_origin ~ \.?xn--jha\.ga$) { + set $cors 'true'; + set $both_conditions "P"; + add_header "x-debug-http-origin-check" "passed"; + } + if ($cors = 'true') { + add_header "Access-Control-Allow-Origin" $http_origin always; + add_header "Access-Control-Allow-Credentials" "true" always; + add_header "Access-Control-Allow-Methods" "GET, POST, PATCH, PUT, DELETE, OPTIONS" always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + } + if ($request_method = 'OPTIONS') { + set $both_conditions "${both_conditions}D"; + } + if ($both_conditions = PD) { + add_header "Access-Control-Allow-Origin" $http_origin always; + add_header "Access-Control-Allow-Credentials" "true" always; + add_header "Access-Control-Allow-Methods" "GET, POST, PATCH, PUT, DELETE, OPTIONS" always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Max-Age' -1; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + try_files $uri $uri/ @backend; + } + location @backend { + proxy_pass https://localhost:27443; + proxy_set_header Host teletext.rtvslo.si; + proxy_set_header Referer https://teletext.rtvslo.si/; + proxy_set_header X-Forwarded-For $remote_addr; + } +} diff --git a/offline.html b/offline.html new file mode 100644 index 0000000..bc1a403 --- /dev/null +++ b/offline.html @@ -0,0 +1,25 @@ + + + + + + Ni internetne povezave :: RTVSLO Teletekst + + + + +

RTVSLO Teletekst

+

Ni internetne povetave!

+

+ Za ogled teleteksta potrebujete povezavo s spletom. + Omogočite prenos podatkov ali se povežite na dostopno + točko WiFi. +

+ + diff --git a/original.png b/original.png new file mode 100644 index 0000000..a7325a3 Binary files /dev/null and b/original.png differ diff --git a/redfox.js b/redfox.js new file mode 100644 index 0000000..fea1579 --- /dev/null +++ b/redfox.js @@ -0,0 +1,15 @@ +// ***************************************************** +// ************** nastavitev spremenljivk ************* +// ***************************************************** +var author = "Sebastjan Dobnik"; + +// Register the service worker +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/service-worker.js') + .then(function(registration) { + console.log('sw reg succ, scope: ', registration.scope); + }) + .catch(function(err) { + console.log('ServiceWorker registration failed: ', err); + }); +} diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..756f11f --- /dev/null +++ b/sw.js @@ -0,0 +1,59 @@ +// Change version to cause cache refresh, sw.js SE NE SME CACHAT aka ne ga dat v assets! +const static_cache_name = "site-static-v0.0.0"; +const offlineUrl = "/offline.html"; +const assets = [ + "/", // proxy | proxyjan je tudi sw.js + "/index.html", // proxy | + "/512.png", // moje | redfox.js je poklican iz + "/512.png", // proxy | vsake proxyjane html strani + "/manifest.json", // moje | in vsebuje custom skripte, + "/desktop2.css", // proxy | kot na primer sw inštalacijo. + "/phone2.css", // proxy | + "/pin.svg", // proxy | + "/redfox.js", // moje | + "/slike/home100.svg", // proxy | + "/slike/prPage.svg", // proxy | + "/slike/prSubPage.svg", // proxy | + "/slike/neSubPage.svg", // proxy | + "/slike/nePage.svg", // proxy | + "/slike/keyboard.svg", // proxy | + "/slike/go.svg", // proxy | + "/favicon.png", // proxy | + "/offline.html" // moje | +]; + +self.addEventListener("install", (evt) => { + evt.waitUntil( + caches.open(static_cache_name).then((cache) => { + cache.addAll(assets); + }) + ); +}); + +// Delete old caches +self.addEventListener("activate", evt => { + evt.waitUntil( + caches.keys().then((keys) => { + return Promise.all(keys + .filter(key => key !== static_cache_name) + .map(key => caches.delete(key)) + ); + }) + ); +}); + +self.addEventListener("fetch", (evt) => { + if (event.request.mode === 'navigate' || // tole ni povsod podprto, zato + ( (event.request.method === 'GET' || // če je GET + event.request.method === 'POST') // ali POST zahteva + && event.request.headers.get('accept').includes('text/html'))) { + + event.respondWith(fetch(event.request.url).catch(error => { + return cacches.match(offlineUrl); + })); + } else { // zahteva je za nek resource (css/js/img), ne za stran + evt.respondWith(caches.match(evt.request).then((cache_res) => { + return cache_res || fetch(evt.request); + })) + } +}); diff --git "a/\305\276" "b/\305\276" new file mode 100644 index 0000000..ff71ccc --- /dev/null +++ "b/\305\276" @@ -0,0 +1,58 @@ +server { + listen 0.0.0.0:80; + listen [::]:80; + server_name .teletekst.xn--jha.ga; + return 301 https://teletekst.xn--jha.ga$request_uri; + port_in_redirect off; + server_name_in_redirect off; +} +server { + listen 0.0.0.0:443 ssl http2; + listen [::]:443 ssl http2; + ssl_certificate /etc/letsencrypt/live/teletekst.xn--jha.ga/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/teletekst.xn--jha.ga/privkey.pem; + ssl_session_cache builtin:1000 shared:SSL:10m; + ssl_prefer_server_ciphers on; + add_header Strict-Transport-Security "max-age=604800"; + index index.html; + server_name .teletekst.xn--jha.ga; + root /var/www/teletekst.xn--jha.ga; + location / { + set $cors ''; + set $both_conditions ""; + add_header "x-debug-location-gse" "triggered"; + if ($http_origin ~ \.?xn--jha\.ga$) { + set $cors 'true'; + set $both_conditions "P"; + add_header "x-debug-http-origin-check" "passed"; + } + if ($cors = 'true') { + add_header "Access-Control-Allow-Origin" $http_origin always; + add_header "Access-Control-Allow-Credentials" "true" always; + add_header "Access-Control-Allow-Methods" "GET, POST, PATCH, PUT, DELETE, OPTIONS" always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + } + if ($request_method = 'OPTIONS') { + set $both_conditions "${both_conditions}D"; + } + if ($both_conditions = PD) { + add_header "Access-Control-Allow-Origin" $http_origin always; + add_header "Access-Control-Allow-Credentials" "true" always; + add_header "Access-Control-Allow-Methods" "GET, POST, PATCH, PUT, DELETE, OPTIONS" always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Authorization' always; + add_header 'Access-Control-Max-Age' -1; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + try_files $uri $uri/ @backend; + } + location @backend { + proxy_pass https://localhost:27443; + proxy_set_header Host teletext.rtvslo.si; + proxy_set_header Referer https://teletext.rtvslo.si/; + proxy_set_header X-Forwarded-For $remote_addr; + } +} -- cgit v1.2.3