diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2014-03-05 16:56:45 -0500 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2014-03-05 16:56:45 -0500 |
commit | 3a2f43e8d5c85a116845c360902f268fd2798ffa (patch) | |
tree | 3fb05200422ac1a544d2cd93f938b8408e21e53d | |
parent | 7b49a8bed0a6c8e50adba8fc6c53c39d330bfa0c (diff) | |
download | html5ks-3a2f43e8d5c85a116845c360902f268fd2798ffa.tar.xz html5ks-3a2f43e8d5c85a116845c360902f268fd2798ffa.zip |
add (untested) php and htaccess
-rw-r--r-- | nginx.inc.conf | 13 | ||||
-rw-r--r-- | www/.htaccess | 25 | ||||
-rw-r--r-- | www/index.php | 3 | ||||
-rw-r--r-- | www/js/api.js | 17 | ||||
-rw-r--r-- | www/warn.html | 2 | ||||
-rw-r--r-- | www/warned.html | 1 | ||||
-rw-r--r-- | www/warned.php | 2 |
7 files changed, 47 insertions, 16 deletions
diff --git a/nginx.inc.conf b/nginx.inc.conf index 5b1cac7..890a674 100644 --- a/nginx.inc.conf +++ b/nginx.inc.conf @@ -11,7 +11,7 @@ location ~ ^/(css/font|js/lib)/ { expires 1d; } -location ~ ^/(index\.html)?$ { +location ~ ^/(index\.(html|php))?$ { set $warned NO; if ($http_cookie ~ "warned") { set $warned YES; @@ -24,19 +24,10 @@ location ~ ^/(index\.html)?$ { } } -location /warned.ngx { - add_header Set-Cookie "warned=1; Expires=Tue, 19 Jan 2038 00:00:00 GMT; HttpOnly"; +location /warned.php { return 301 "/warned.html?$args&language=$http_accept_language"; } -location /warn.html { - break; -} - -location /robots.txt { - break; -} - expires 5s; add_header Cache-Control public; add_header X-UA-Compatible "IE=edge,chrome=1"; diff --git a/www/.htaccess b/www/.htaccess new file mode 100644 index 0000000..b51816a --- /dev/null +++ b/www/.htaccess @@ -0,0 +1,25 @@ +<IfModule mod_expires.c> + ExpiresActive on + ExpiresDefault "access plus 1 minutes" + <Location "^/(dump|json)/"> + ExpiresDefault "access plus 1 years" + <Location "^/dump/(bgm|sfx)"> + Header set X-Content-Duration "0" + </Location> + </Location> +</IfModule> + +<IfModule mod_rewrite.c> + RewriteEngine On + RewriteCond %{HTTP:Accept-Encoding} gzip + RewriteCond %{REQUEST_FILENAME}\.gz -s + RewriteRule ^(.*)\.json $1\.json\.gz [QSA] + +# Prevent double gzip and give the correct mime-type + RewriteRule \.json\.gz$ - [T=application/json,E=no-gzip:1,E=FORCE_GZIP] + + Header set Content-Encoding gzip env=FORCE_GZIP +</IfModule> + +Header set Cache-Control "public" +Header set X-UA-Compatible "IE=edge,chrome=1" diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..49fbbec --- /dev/null +++ b/www/index.php @@ -0,0 +1,3 @@ +<?php +if (!isset($_COOKIE["warned"])) header("Location: warn.php"); +else echo file_get_contents("index.html"); diff --git a/www/js/api.js b/www/js/api.js index b74c1ae..1452074 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -50,14 +50,22 @@ window.html5ks.api = { html5ks.spin(1); el.oncanplaythrough = function () { + el.oncanplaythrough = null; el.play(); html5ks.spin(-1); }; + setTimeout(function () { + if (el.oncanplaythrough) { + console.warn("video not playing after 3 seconds"); + el.oncanplaythrough(); + } + }, 3000); + el.onerror = function (e) { if (e.code === e.MEDIA_ERR_SRC_NOT_SUPPORTED) { if (_nextType(++i)) { - console.warn("browser claimed support for " + types[i-1] + " but failed"); + console.warn("browser claimed support for " + types[i-1][0] + " but failed"); } else { console.error("no media formats supported"); } @@ -153,7 +161,7 @@ window.html5ks.api = { video.volume = html5ks.persistent.musicVolume; var done = function () { video.style.display = "none"; - video.pause(); + video.src = ""; deferred.resolve(); }; document.addEventListener("keyup", function keyupListener(e) { @@ -164,8 +172,9 @@ window.html5ks.api = { } }, false); video.onclick = function (e) { - if (e.button === 0 && skippable) { - done(); + if (e.button === 0) { + if (video.paused) video.play(); + else if (skippable) done(); } }; video.onended = done; diff --git a/www/warn.html b/www/warn.html index 8601eb7..d3ece15 100644 --- a/www/warn.html +++ b/www/warn.html @@ -12,7 +12,7 @@ This includes missing features, typos, downtime, and any other glitches of any sort. Bug me instead: <a href="https://bugzilla.happinessforme.com/">https://bugzilla.happinessforme.com/</a>, or use the official distribution until HTML5KS is feature-complete. </p> <p>FYI, this site sets a single anonymous cookie (warned=1) so that you won't have to keep seeing this page. It also sets localStorage to keep your settings and saves. The latter always stays on your computer and never goes anywhere. If you live in the EU, please don't sue me.</p> - <form method="GET" action="warned.ngx"> + <form method="GET" action="warned.php"> <p><input type="checkbox" name="hdisable" id="hdisable"><label for="hdisable">Disable adult content</label> <br> <input type="submit" value="Let's go!"> diff --git a/www/warned.html b/www/warned.html index 5d44d7c..99779ed 100644 --- a/www/warned.html +++ b/www/warned.html @@ -1,6 +1,7 @@ <!DOCTYPE html> <html><head> <script> +document.cookie = "warned=1; Expires=Tue, 19 Jan 2038 00:00:00 GMT; HttpOnly"; localStorage.persistent = { hdisable: location.search.indexOf("hdisable=on") > -1, language: location.search.search("language=.*[=,]en") > -1 ? "en" : "fr" diff --git a/www/warned.php b/www/warned.php new file mode 100644 index 0000000..04c300b --- /dev/null +++ b/www/warned.php @@ -0,0 +1,2 @@ +<?php +header("Location: /warned.html?".$_SERVER['QUERY_STRING']."&language=".$_SERVER['HTTP_ACCEPT_LANGUAGE']); |