Move nojs refresh magic numbers to config
このコミットが含まれているのは:
コミット
dc5c4db3de
|
@ -37,6 +37,7 @@ def toml_to_flask_sections(config):
|
||||||
toml_to_flask_section_chat,
|
toml_to_flask_section_chat,
|
||||||
toml_to_flask_section_flood,
|
toml_to_flask_section_flood,
|
||||||
toml_to_flask_section_captcha,
|
toml_to_flask_section_captcha,
|
||||||
|
toml_to_flask_section_nojs,
|
||||||
)
|
)
|
||||||
for toml_to_flask_section in TOML_TO_FLASK_SECTIONS:
|
for toml_to_flask_section in TOML_TO_FLASK_SECTIONS:
|
||||||
yield toml_to_flask_section(config)
|
yield toml_to_flask_section(config)
|
||||||
|
@ -110,7 +111,6 @@ def toml_to_flask_section_thresholds(config):
|
||||||
'THRESHOLD_USER_NOTWATCHING': cfg['user_notwatching'],
|
'THRESHOLD_USER_NOTWATCHING': cfg['user_notwatching'],
|
||||||
'THRESHOLD_USER_TENTATIVE': cfg['user_tentative'],
|
'THRESHOLD_USER_TENTATIVE': cfg['user_tentative'],
|
||||||
'THRESHOLD_USER_ABSENT': cfg['user_absent'],
|
'THRESHOLD_USER_ABSENT': cfg['user_absent'],
|
||||||
'THRESHOLD_NOJS_CHAT_TIMEOUT': cfg['nojs_chat_timeout'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def toml_to_flask_section_chat(config):
|
def toml_to_flask_section_chat(config):
|
||||||
|
@ -147,3 +147,12 @@ def toml_to_flask_section_captcha(config):
|
||||||
'CAPTCHA_BACKGROUND_COLOUR': color_to_colour(cfg['background_color']),
|
'CAPTCHA_BACKGROUND_COLOUR': color_to_colour(cfg['background_color']),
|
||||||
'CAPTCHA_FOREGROUND_COLOUR': color_to_colour(cfg['foreground_color']),
|
'CAPTCHA_FOREGROUND_COLOUR': color_to_colour(cfg['foreground_color']),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def toml_to_flask_section_nojs(config):
|
||||||
|
cfg = config['nojs']
|
||||||
|
return {
|
||||||
|
'NOJS_REFRESH_MESSAGES': round(cfg['refresh_messages']),
|
||||||
|
'NOJS_REFRESH_INFO': round(cfg['refresh_info']),
|
||||||
|
'NOJS_REFRESH_USERS': round(cfg['refresh_users']),
|
||||||
|
'NOJS_TIMEOUT_CHAT': round(cfg['timeout_chat']),
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ async def nojs_info(user):
|
||||||
return await render_template(
|
return await render_template(
|
||||||
'nojs_info.html',
|
'nojs_info.html',
|
||||||
csp=generate_csp(),
|
csp=generate_csp(),
|
||||||
|
refresh=CONFIG['NOJS_REFRESH_INFO'],
|
||||||
user=user,
|
user=user,
|
||||||
viewership=viewership,
|
viewership=viewership,
|
||||||
uptime=uptime,
|
uptime=uptime,
|
||||||
|
@ -48,10 +49,11 @@ async def nojs_chat_messages(user):
|
||||||
return await render_template_with_etag(
|
return await render_template_with_etag(
|
||||||
'nojs_chat_messages.html',
|
'nojs_chat_messages.html',
|
||||||
{'csp': generate_csp()},
|
{'csp': generate_csp()},
|
||||||
|
refresh=CONFIG['NOJS_REFRESH_MESSAGES'],
|
||||||
user=user,
|
user=user,
|
||||||
users_by_token=USERS_BY_TOKEN,
|
users_by_token=USERS_BY_TOKEN,
|
||||||
messages=get_scrollback(current_app.messages),
|
messages=get_scrollback(current_app.messages),
|
||||||
timeout=CONFIG['THRESHOLD_NOJS_CHAT_TIMEOUT'],
|
timeout=CONFIG['NOJS_TIMEOUT_CHAT'],
|
||||||
get_default_name=get_default_name,
|
get_default_name=get_default_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,11 +69,12 @@ async def nojs_chat_users(user):
|
||||||
return await render_template_with_etag(
|
return await render_template_with_etag(
|
||||||
'nojs_chat_users.html',
|
'nojs_chat_users.html',
|
||||||
{'csp': generate_csp()},
|
{'csp': generate_csp()},
|
||||||
|
refresh=CONFIG['NOJS_REFRESH_USERS'],
|
||||||
user=user,
|
user=user,
|
||||||
get_default_name=get_default_name,
|
get_default_name=get_default_name,
|
||||||
users_watching=users_by_presence[Presence.WATCHING],
|
users_watching=users_by_presence[Presence.WATCHING],
|
||||||
users_notwatching=users_by_presence[Presence.NOTWATCHING],
|
users_notwatching=users_by_presence[Presence.NOTWATCHING],
|
||||||
timeout=CONFIG['THRESHOLD_NOJS_CHAT_TIMEOUT'],
|
timeout=CONFIG['NOJS_TIMEOUT_CHAT'],
|
||||||
)
|
)
|
||||||
|
|
||||||
@current_app.route('/chat/form.html')
|
@current_app.route('/chat/form.html')
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
||||||
<meta http-equiv="refresh" content="4">
|
<meta http-equiv="refresh" content="{{ refresh }}">
|
||||||
<meta http-equiv="refresh" content="5; url={{ url_for('nojs_chat_messages_redirect', token=user.token) }}">
|
<meta http-equiv="refresh" content="{{ refresh + 1 }}; url={{ url_for('nojs_chat_messages_redirect', token=user.token) }}">
|
||||||
<style nonce="{{ csp }}">
|
<style nonce="{{ csp }}">
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
||||||
<meta http-equiv="refresh" content="6">
|
<meta http-equiv="refresh" content="{{ refresh }}">
|
||||||
<style nonce="{{ csp }}">
|
<style nonce="{{ csp }}">
|
||||||
html {
|
html {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
<meta http-equiv="content-security-policy" content="default-src 'none'; style-src 'nonce-{{ csp }}';">
|
||||||
<meta http-equiv="refresh" content="6">
|
<meta http-equiv="refresh" content="{{ refresh }}">
|
||||||
<style nonce="{{ csp }}">
|
<style nonce="{{ csp }}">
|
||||||
body {
|
body {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
|
@ -76,4 +76,9 @@ overwrite = true
|
||||||
user_notwatching = 8.0
|
user_notwatching = 8.0
|
||||||
user_tentative = 20.0
|
user_tentative = 20.0
|
||||||
user_absent = 360.0
|
user_absent = 360.0
|
||||||
nojs_chat_timeout = 30.0
|
|
||||||
|
[nojs]
|
||||||
|
refresh_messages = 4.0
|
||||||
|
refresh_info = 6.0
|
||||||
|
refresh_users = 6.0
|
||||||
|
timeout_chat = 30.0
|
||||||
|
|
読み込み中…
新しいイシューから参照