Merge pull request #14 from albertoxamin/dev

fix service worker and accessibility warnings
This commit is contained in:
Alberto Xamin 2020-12-13 18:44:11 +01:00 committed by GitHub
commit 485b169fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import os
import json import json
import random import random
from typing import List from typing import List
@ -8,7 +9,7 @@ from bang.game import Game
from bang.players import Player from bang.players import Player
sio = socketio.Server(cors_allowed_origins="*") sio = socketio.Server(cors_allowed_origins="*")
app = socketio.WSGIApp(sio, static_files={ static_files={
'/': {'content_type': 'text/html', 'filename': 'index.html'}, '/': {'content_type': 'text/html', 'filename': 'index.html'},
'/game': {'content_type': 'text/html', 'filename': 'index.html'}, '/game': {'content_type': 'text/html', 'filename': 'index.html'},
'/robots.txt': {'content_type': 'text/html', 'filename': 'robots.txt'}, '/robots.txt': {'content_type': 'text/html', 'filename': 'robots.txt'},
@ -17,8 +18,11 @@ app = socketio.WSGIApp(sio, static_files={
'/manifest.json': {'filename': 'manifest.json'}, '/manifest.json': {'filename': 'manifest.json'},
'/css': './css', '/css': './css',
'/js': './js', '/js': './js',
}) }
for file in [f for f in os.listdir('.') if '.js' in f or '.map' in f or '.html' in f]:
static_files[f'/{file}'] = f'./{file}'
app = socketio.WSGIApp(sio, static_files=static_files)
games: List[Game] = [] games: List[Game] = []
online_players = 0 online_players = 0

View File

@ -7,7 +7,7 @@
<h2>{{$t("warning")}}</h2> <h2>{{$t("warning")}}</h2>
<p>{{$t("connection_error")}}</p> <p>{{$t("connection_error")}}</p>
</div> </div>
<select style="position:fixed;bottom:4pt;right:4pt;" v-model="$i18n.locale" @change="storeLangPref"> <select id="lang" style="position:fixed;bottom:4pt;right:4pt;" v-model="$i18n.locale" @change="storeLangPref">
<option <option
v-for="(lang, i) in ['it.🇮🇹.Italiano', 'en.🇬🇧.English']" v-for="(lang, i) in ['it.🇮🇹.Italiano', 'en.🇬🇧.English']"
:key="`lang-${i}`" :key="`lang-${i}`"
@ -15,6 +15,7 @@
{{lang.split('.')[1]}} {{lang.split('.')[2]}} {{lang.split('.')[1]}} {{lang.split('.')[2]}}
</option> </option>
</select> </select>
<label for="lang" style="opacity:0" >Language</label>
</div> </div>
</template> </template>

View File

@ -8,7 +8,7 @@
<div v-if="!didSetUsername"> <div v-if="!didSetUsername">
<p>{{$t("choose_username")}}</p> <p>{{$t("choose_username")}}</p>
<form @submit="setUsername"> <form @submit="setUsername">
<input v-model="username" /> <input id="username" v-model="username" />
<input type="submit" :value="$t('submit')"/> <input type="submit" :value="$t('submit')"/>
</form> </form>
<p>{{$t("online_players")}}{{onlinePlayers}}</p> <p>{{$t("online_players")}}{{onlinePlayers}}</p>
@ -25,12 +25,14 @@
<form @submit="createLobby"> <form @submit="createLobby">
<h2>{{$t("create_lobby")}}</h2> <h2>{{$t("create_lobby")}}</h2>
<p>{{$t("lobby_name")}}</p> <p>{{$t("lobby_name")}}</p>
<input v-model="lobbyName"/> <input id="lobbyname" v-model="lobbyName"/>
<input type="submit" :value="$t('submit')"/> <input type="submit" :value="$t('submit')"/>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
<label for="username" style="opacity:0">Username</label>
<label for="lobbyname" style="opacity:0">Lobby Name</label>
</div> </div>
</template> </template>

View File

@ -1,6 +1,7 @@
const { GenerateSW } = require("workbox-webpack-plugin"); const { GenerateSW } = require("workbox-webpack-plugin");
module.exports = { module.exports = {
publicPath: "./",
pwa: { pwa: {
name: 'PewPew!', name: 'PewPew!',
appleMobileWebAppCache: "yes", appleMobileWebAppCache: "yes",
@ -8,7 +9,11 @@ module.exports = {
} }
}, },
configureWebpack: { configureWebpack: {
plugins: [new GenerateSW()], plugins: [new GenerateSW({
clientsClaim: true,
skipWaiting: true,
navigateFallback: 'index.html',
})],
output: { output: {
crossOriginLoading: 'anonymous' crossOriginLoading: 'anonymous'
}, },